cancel
Showing results for 
Search instead for 
Did you mean: 

Search against WCM

loic
Champ in-the-making
Champ in-the-making
Hi !

I have a website which retreive content via AVMRemote etc…
Now, I'd like to search (lucene) content in my Webproject (like with the node browser) through java code.

i've red this > http://wiki.alfresco.com/wiki/WCM_Search and this > http://wiki.alfresco.com/wiki/Search#Example_API_Call but I did not succeeded.

here's my method :
public void searchAVM() {
      
      ServiceRegistry serviceRegistry = null;
      
      StoreRef myWcm = new StoreRef("avm://crhn/-1;www;avm_webapps;ROOT;contenu");
      
        SearchParameters sp = new SearchParameters();
        sp.addStore(myWcm);
        sp.setLanguage(SearchService.LANGUAGE_LUCENE);
        sp.setQuery("TEXT:*a*");
        ResultSet results = null;
        try
        {
            results = serviceRegistry.getSearchService().query(sp);
            for(ResultSetRow row : results)
            {
                NodeRef currentNodeRef = row.getNodeRef();
                System.out.println(currentNodeRef.getId());
            }
        }
        finally
        {
            if(results != null)
            {
                results.close();
            }
        }
       
   }

Anyone to help me finding out where i'm wrong ?

Thanks in advance
1 REPLY 1

d_segato
Champ in-the-making
Champ in-the-making
the query should look like this:
TEXT:"*a*"
note the double quote!

so in java you should write this:
sp.setQuery("TEXT:\"*a*\"");

anyway that search will not be very good…
try to use words of 3 or more chars when quering via lucene.