cancel
Showing results for 
Search instead for 
Did you mean: 

Lucene Search for Category

nowhere
Champ in-the-making
Champ in-the-making
Hi all,
I have a problem with category lucene Search:

Here it's my code:


                                                        NodeRef categoria = null;
                              StoreRef store = new StoreRef("workspace://SpacesStore");   
                 SearchParameters sp1 = new SearchParameters();
                 sp1.addStore(store);
                 sp1.setLanguage(SearchService.LANGUAGE_LUCENE);
                 ResultSet results1 = null;
          
                 ArrayList<NodeRef> categories = new ArrayList<NodeRef>(cat.length);
                
            for (int i = 0; i < cat.length; i++)
            {
                  
                               sp1.setQuery("+TYPE:\"cm:category\" +@cm\\:name:\""+cat[i] +"\" +PATH:\"/cm:generalclassifiable/cm:Ricerca_x0026_Sviluppo//*\"");
                  System.out.println(sp1.getQuery()); (1)
                  
                   try
                    {
                        results1 = serviceRegistry.getSearchService().query(sp1);
                        System.out.println("numero results: " +results1.length());
                        for(ResultSetRow row : results1)
                        {
                           categoria = row.getNodeRef();
                           System.out.println("Catego trovata: " + categoria.toString());
                           categories.add(categoria);
                        }
                    }
                    finally
                    {
                        if(results1 != null)
                        {
                            results1.close();
                        }
                    }

Where (1) prints +TYPE:"cm:category" +@cm\:name:"Ambiente" +PATH:"/cm:generalclassifiable/cm:Ricerca_x0026_Sviluppo//*" for example.
This code gives me 0 results, but if I use +TYPE:"cm:category" +@cm\:name:"Ambiente" +PATH:"/cm:generalclassifiable/cm:Ricerca_x0026_Sviluppo//*" in alfresco nodebrowser (search Lucene) I get results.
Where am I in wrong?
Thanks for any suggestion!
1 REPLY 1

nowhere
Champ in-the-making
Champ in-the-making
If I search for "+TYPE:\"cm:category\" +PATH:\"/cm:generalclassifiable/cm:Ricerca_x0026_Sviluppo//*\", it works fine.
Maybe the problem is in "@cm\\:name:\""+cat +"\"" ?