lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "G.Long" <jde...@gmail.com>
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, 
RepositoryManager.getPerFieldAnalyzerWrapper(Version.LUCENE_35));
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 
tag:value2)

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" 
tag:"value2").

Thanks,
Gary




---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message