lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Muir <rcm...@gmail.com>
Subject Re: Quoted search on Analyzed fields
Date Tue, 29 Nov 2011 16:15:02 GMT
Again there is nothing wrong with the quotes: its instead how you are
configuring the analysis for this field.

If you put stuff in quotes and your analyzer breaks it into multiple
tokens, then queryparser forms a phrase query. You must index
positions to support phrase queries.

Normally DOCS_ONLY is only used for fields that contain a *single
term*, like a numeric field. If you want to exclude positions for a
field but at the same time allow tokenized queries against it like you
are doing, then you need to adjust your queryparsing to do the right
thing if someone enters quoted text like "john doe", such as forming a
boolean query (john AND doe) instead.

The way to do this is to subclass the queryparser and do something like:
@Override
protected Query getFieldQuery(String field, String queryText, boolean
quoted)  throws ParseException {
 if (quoted && field.equals("myfieldwithoutpositions") {
    // my special logic to form boolean queries or something else
 } else {
    return super.getFieldQuery(field, queryText, quoted);
 }
}


On Tue, Nov 29, 2011 at 10:58 AM, Mihai Caraman <caraman.mihai@gmail.com> wrote:
> Still no difference, it may be because of some other hidden
> bug.<java-user-help@lucene.apache.org>Anyway, adding freq and
> positions will be a no - no because of space :) so
> bye bye quotes.
>
> Thank you
>



-- 
lucidimagination.com

---------------------------------------------------------------------
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