lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "G.Long" <>
Subject boolean query for multiple values on a specific field
Date Wed, 27 Jan 2016 17:52:37 GMT
Hi :)

I would like to retrieve a document from my index which must have a 
field called "tag" for which the value must be "(01) value1" or 
"value2". I'm using the lucene java api.

My code is the following:

String expression = "tag:(\"(01) value1\" value2)"
QueryParser parser = new QueryParser(Version.LUCENE_35, field, 
Query query = parser.parse(expression);
BooleanQuery bQuery = new BooleanQuery();
bQuery.add(query, Occur.MUST);

The tag field is associated to a keyword analyzer.

My problem is that the query parser removes the " characters. It returns 
the query tag:(01) value1 tag:value2 which becomes
+(tag:(01) value1 tag:value2) when added to the boolean query and when 
the query is executed it becomes +(tag:(UE) default_field:value1 

So it will return documents which have their tag field having the value 
"value2" but not those with "(01) value1".

In the end I would like to obtain the query +(tag:"(01) value1" 


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message