Sunil
Sunil

Reputation:

lucene query issue

I am using Lucene with Alfresco. Here is my query:

( TYPE:"{com.company.customised.content.model}test"  &&  (@\{com.company.customised.content.model\}testNo:111 && (@\{com.company.customised.content.model\}skill:or))

I have to search documents which are having property skill of value "or". The above query is not giving any results (I am getting failed to parse query).

If I use the query up until testNo (ignoring skill), I am getting proper results:

 ( TYPE:"{com.company.customised.content.model}test"  &&  (@\{com.company.customised.content.model\}testNo:111))

Can you please help me?

Thanks

Upvotes: 0

Views: 1442

Answers (2)

Vikash Patel
Vikash Patel

Reputation: 1346

Yes , or is reserved keyword in lucene but if you are trying to query by property which is of type number then you can give your value directly else if of type d:text or string so that you have to gave your value in double quote " " .

( TYPE:"{com.company.customised.content.model}test" && (@{com.company.customised.content.model}testNo:111 && (@{com.company.customised.content.model}skill:"or"))

Upvotes: 0

Adam Paynter
Adam Paynter

Reputation: 46938

Unfortunately, "or" is a reserved keyword in Lucene. Therefore, Lucene fails to properly interpret your query, because Lucene thinks you are referring to the OR boolean operator. You may want to try wrapping the or in double quotes:

( TYPE:"{com.company.customised.content.model}test"  &&  (@\{com.company.customised.content.model\}testNo:111 && (@\{com.company.customised.content.model\}skill:"or"))

I am not familiar with Alfresco, so you may not be able to do this.

Upvotes: 2

Related Questions