cancel
Showing results for 
Search instead for 
Did you mean: 

Lucene Query with OR Keyword not returing proper result

himvj
Champ in-the-making
Champ in-the-making
I want to write a lucene query to serach contents in alfresco repository

my Query is like below

filename = "suppliername";

query.statement = "PATH:\"/app:company_home/st:sites/cmSmiley Tonguerocessing/cm:documentLibrary/cm:AAK/*\" AND TYPE:\"{http://www.alfresco.org/model/content/1.0}content\" OR   @my\\:first_supplierInvoice_comAsp1TransRef:\"" + filename + "\" OR @my\\:first_supplierInvoice_supName:\"" + filename + "\" OR @my\\:first_supplierInvoice_comAsp1Date:\"" + filename + "\"";


but here the OR key word is not working it is returning all the contents in a  particular node.but not the contents matching that metadata.


please tel me how it can be done.
5 REPLIES 5

loftux
Star Contributor
Star Contributor
What if you try with parentheses?
Something like
query.statement = "PATH:\"/app:company_home/st:sites/cm:processing/cm:documentLibrary/cm:AAK/*\" AND ( TYPE:\"{http://www.alfresco.org/model/content/1.0}content\" OR @my\\:first_supplierInvoice_comAsp1TransRef:\"" + filename + "\" OR @my\\:first_supplierInvoice_supName:\"" + filename + "\" OR @my\\:first_supplierInvoice_comAsp1Date:\"" + filename + "\")";
Where you put the parentheses is of course a matter of what you want OR:ed.

himvj
Champ in-the-making
Champ in-the-making
What if you try with parentheses?
Something like
query.statement = "PATH:\"/app:company_home/st:sites/cm:processing/cm:documentLibrary/cm:AAK/*\" AND ( TYPE:\"{http://www.alfresco.org/model/content/1.0}content\" OR @my\\:first_supplierInvoice_comAsp1TransRef:\"" + filename + "\" OR @my\\:first_supplierInvoice_supName:\"" + filename + "\" OR @my\\:first_supplierInvoice_comAsp1Date:\"" + filename + "\")";
Where you put the parentheses is of course a matter of what you want OR:ed.




I tried your suggesation that but still it is showing all the contents in that folder. I want only the contents matching any of the metadata.

himvj
Champ in-the-making
Champ in-the-making
I tried your suggesation that but still it is showing all the contents in that folder. I want only the contents matching any of the metadata.

loftux
Star Contributor
Star Contributor
That is correct if you look at the query, any content will match TYPE
Try this
query.statement = "PATH:\"/app:company_home/st:sites/cm:processing/cm:documentLibrary/cm:AAK/*\" AND TYPE:\"{http://www.alfresco.org/model/content/1.0}content\" AND (@my\\:first_supplierInvoice_comAsp1TransRef:\"" + filename + "\" OR @my\\:first_supplierInvoice_supName:\"" + filename + "\" OR @my\\:first_supplierInvoice_comAsp1Date:\"" + filename + "\")";

himvj
Champ in-the-making
Champ in-the-making
yes it is working fine thanks a lot Loftux

Thanks