cancel
Showing results for 
Search instead for 
Did you mean: 

best way to include categories in luceneSearch?

targa2000
Champ in-the-making
Champ in-the-making
How do we search by categories with luceneSearch(string query)?
2 REPLIES 2

openpj
Elite Collaborator
Elite Collaborator
Here all the informations about query for categories:
http://wiki.alfresco.com/wiki/Search#Category_Queries
Hope this helps.

salvatore_amtin
Champ in-the-making
Champ in-the-making
Hi All,

i've the problem with alfresco subcategory query. i use alfresco client and when i search document through advanced search whit category and subcategory all ok.But when i try use, through embedded API,  don't have any result.

I build lucene quey string so :


//Impostazione della directory radice della ricerca all'interno dello spazio di lavoro di Alfresco
query.append("PATH:\"/" + spaceStoreNodePath);
         
query.append(ricDoc.isRicercaInSottospazi() ? "//*\" " : "/*\" ");
….
….


if( ricDoc.isRicercaInSottocategorie() ){
         //fuzione ricorsiva che gestisce l'albero delle categorie
         query.append("&& PATH:\\\"/cm:categories:" + alfrescoCore.getStoreRef().toString() + "/" + ricDoc.getUuidCategoria() + "/*\"");                  
}else{
   query.append("&& @cm\\:categories:\"" + alfrescoCore.getStoreRef().toString() + "/" + ricDoc.getUuidCategoria() + "\" ");
}         
….
….
….

SearchParameters sp = new SearchParameters();
      sp.addStore(new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"));
      sp.setLanguage(SearchService.LANGUAGE_LUCENE);
      org.alfresco.service.cmr.search.ResultSet results = null;

sp.setBulkFetchSize(20);
sp.setQuery(query);

results = alfrescoServiceRegistry.getSearchService().query(sp);
                    


If i'dont search whit subcategory all is OK, but if i search to subcategory i'ven't result.

How i can do it?

Thanks
Salvatore