cancel
Showing results for 
Search instead for 
Did you mean: 

Simple Searching

nyronian
Champ in-the-making
Champ in-the-making
I am trying to do some simple searching and I am having a hard time trying to figure out how…..

I am doing a simple search the works for a jpg in my repository:

           
Query query = new Query(Constants.QUERY_LANG_LUCENE, "@\\{http\\://www.alfresco.org/model/content/1.0\\}name:myimage.jpg");

this works fine but if I have mutliple "myimage.jpg" i assume it would return all references to them.  So, I would like to have a search that takes into account the space it resides in (which I know from my code).

My latest "Version" of trying to do this was:

   Query query = new Query(Constants.QUERY_LANG_LUCENE, "PATH:\"/{http://www.alfresco.org/model/application/1.0}company_home/{http://www.alfresco.org/model/applicatio..."");        

This returns some sort of node but not the node for the image.  What would this return?  This is the path I got to the image from the Node Browser. 

I get the following properties for the node that is returned (much different when I just do the name search)

row 0: {http://www.alfresco.org/model/system/1.0}store-protocol = workspace
row 0: {http://www.alfresco.org/model/content/1.0}name = 7a9faf28-f345-11db-ab71-7fa60afd44de
row 0: {http://www.alfresco.org/model/system/1.0}node-dbid = 12
row 0: {http://www.alfresco.org/model/system/1.0}store-identifier = SpacesStore
row 0: {http://www.alfresco.org/model/system/1.0}node-uuid = 7a9faf28-f345-11db-ab71-7fa60afd44de
row 0: {http://www.alfresco.org/model/content/1.0}path = /

Do I have the wrong approach here?  If I know the exact path to the image, how do I get it?  I have spent HOURS pouring through the documentation and trying different search strings and still can't get it to work.

Thanks much….
3 REPLIES 3

andy
Champ on-the-rise
Champ on-the-rise
Hi

PATH uses prefixes not full uris (as XPATH does).

This should solve your issue.

Andy

kevinr
Star Contributor
Star Contributor
The PATH specifies the path to search in and it also is not escaped correctly (the '/' character in the http:// part needs escaping for instance - as you did in your original query attempt). You can use the short qname form to make it easier with less escaping, and then you'll want something like this:

Query query = new Query(Constants.QUERY_LANG_LUCENE, "PATH:\"/app:company_home/app:dictionary/cm:Images/*\" AND @\{http\://www.alfresco.org/model/content/1.0\}name:myimage.jpg");

I think that should work.

Thanks,

Kevin

nyronian
Champ in-the-making
Champ in-the-making
Thank you so much…it worked perfectly!