lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jack Krupansky <>
Subject Re: boolean query for multiple values on a specific field
Date Wed, 27 Jan 2016 21:29:43 GMT
Do you have other code you are not showing us? For example, what could are
you using to get the text of the parsed query?

Make sure your quotes are true ASCII quotes (double quote) and not the
curly quotes that word processors like to insert.

What is this Repository Manager? I mean, I see no code that would tell the
analyzer that "tag" is a defined field.

Also, I see no value to having the single-clause BooleanQuery wrapped
around the actual query.

-- Jack Krupansky

On Wed, Jan 27, 2016 at 12:52 PM, G.Long <> wrote:

> 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:
> For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message