lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luis Alves (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LUCENE-1768) NumericRange support for new query parser
Date Fri, 07 Aug 2009 17:35:14 GMT

    [ https://issues.apache.org/jira/browse/LUCENE-1768?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12740643#action_12740643
] 

Luis Alves commented on LUCENE-1768:
------------------------------------

Hi Yonik,

As I said before you can do that in the RangeQueryNodeBuilder.build(QueryNode queryNode),
but it's ugly and this is not what we intended when using the "new flexible query parser".

The "new flexible query parser" does not follow the concept of method overwriting has the
old one.
So solutions that worked in the old queryparser, like overwriting a method, have to be implemented
using a programmatic way.

Your approach requires creating a new class, overwrite a method.
you still need to create a instance of your QueryParser and is not reusable.

Here is a sample of what your approach is:
{code}

Class YonikQueryParser extends QueryParser{

  Query getRangeQuery(field,...) {
    if ("money".equals(field)) return new NumericRangeQuery(field,...)
    else return super.getRangeQuery(field,...)
  }
}

...
 QueryParser yqp = new YonikQueryParser(...);
yqp.parser(query);
{code}

 vs

What I am proposing:

{code}
    Map<CharSequence, RangeTools.Type> rangeTypes =  new HashMap<CharSequence, RangeTools.Type>();
    
    rangeTypes.put("money", RangeUtils.getType(RangeUtils.NUMERIC,  RangeUtils.NumericType.Type.FLOAT,
NumericUtils.PRECISION_STEP_DEFAULT) );

    StandardQueryParser qp = new StandardQueryParser();
    qp.setRangeTypes(rangeTypes);

    qp.parser(query);
{code}

The second approach is programmatic does not require a new class, 
or the overwrite of a method and is reusable by other users, and it's
backward compatible, meaning we can integrate this on the current 
"Flexible query parser" and deliver this feature on 2.9 without affecting
any current usecase.

Your approach is not compatible, it does require new class, and is not programmatic,
It's not reusable by other users (we can't commit your code to lucene), 
since fields are hard-coded.

Also the approach I proposing is very similar to setFieldsBoost setDateResolution,
already available on the old QP and the new flexible query parser.

I also want to say, that extending the old QP vs extending the "New flexible Query Parser"
approaches
are never going to be similar, they completely different implementations.



> NumericRange support for new query parser
> -----------------------------------------
>
>                 Key: LUCENE-1768
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1768
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: QueryParser
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 2.9
>
>
> It would be good to specify some type of "schema" for the query parser in future, to
automatically create NumericRangeQuery for different numeric types? It would then be possible
to index a numeric value (double,float,long,int) using NumericField and then the query parser
knows, which type of field this is and so it correctly creates a NumericRangeQuery for strings
like "[1.567..*]" or "(1.787..19.5]".
> There is currently no way to extract if a field is numeric from the index, so the user
will have to configure the FieldConfig objects in the ConfigHandler. But if this is done,
it will not be that difficult to implement the rest.
> The only difference between the current handling of RangeQuery is then the instantiation
of the correct Query type and conversion of the entered numeric values (simple Number.valueOf(...)
cast of the user entered numbers). Evenerything else is identical, NumericRangeQuery also
supports the MTQ rewrite modes (as it is a MTQ).
> Another thing is a change in Date semantics. There are some strange flags in the current
parser that tells it how to handle dates.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


Mime
View raw message