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 <jde...@gmail.com> 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: java-user-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-user-h...@lucene.apache.org
>
>

Reply via email to