AnsweredAssumed Answered

Lucene Search for Category

Question asked by nowhere on Jun 21, 2009
Latest reply on Jun 21, 2009 by nowhere
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!

Outcomes