cancel
Showing results for 
Search instead for 
Did you mean: 

Problems about searching with Lucene/Xpath

camillo
Champ in-the-making
Champ in-the-making
Hi all,

I have an xml file stored into a space and i would like perform some searches from my web-client.
In spite of this, I read http://wiki.alfresco.com/wiki/Search_Documentation but I have some problems about understanding the way that allows me to search informations I need.
For example, if my xml file, named pets.xml, is:

<INFO>
  <ANIMALS>
   <ANIMAL>
     <NAME>CAT</NOME>
     <COLOR>BLACK</COLOR>
       </ANIMAL>
      <ANIMAL>
     <NAME>DOG</NOME>    
     <COLOR>BROWN</COLOR>
      </ANIMAL>
  <ANIMALS>
</INFO>

what's the query I must set to found the color of the dog?
I perform this query using this code:

RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
String path = "PATH:\"/app:company_home/cm:ZOO/cm:INFO/cm:pets.xml\" AND  TEXT:\"DOG*\"";
Query query = new Query(Constants.QUERY_LANG_LUCENE, path);
Store STORE = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
QueryResult queryResult;
queryResult = repositoryService.query(STORE, query, false);
org.alfresco.webservice.types.ResultSet resultSet = queryResult.getResultSet();
org.alfresco.webservice.types.ResultSetRow[] rows = resultSet.getRows();

but it doesn't work!!!!!!
Please, help me….I'm crazying! Smiley Sad
Thanks in advance!
1 REPLY 1

openpj
Elite Collaborator
Elite Collaborator
You must encode all the names of the spaces in your query with an ISO9075 encoding class:
org.alfresco.webservice.util.ISO9075
in the following way:

String path = "PATH:\"/app:company_home/cm:"+ISO9075.encode("ZOO")+"/cm:"+ISO9075.encode("INFO")+"/cm\:name:pets.xml\" AND  TEXT:\"DOG*\"";
In your query I think that you needed to add name property in your last condition of the query with cm\:name.

Hope this helps.