lucene-dev mailing list archives

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


Luis Alves commented on LUCENE-1768:

You could still do something similar by simply override
queryNode), but this is not clean (it is kind of a hack).

A clean implementation would allow the user to configure the field types (which the "new flexible
queryparser" does).
I'm new to NumericRange Queries and Rangequeries in general, but here is what I think it should
look like.

Here is a seudo java example:
    final String defaultField = "default";
    final String monthField = "month";
    final String hourField = "hour";
    final String distanceField = "distance";
    final String moneyField = "money";

    Map<CharSequence, RangeTools.Type> rangeTypes =  new HashMap<CharSequence, RangeTools.Type>();
    // set a field specific range type per field
    rangeTypes.put(monthField, new RangeTools.Type(RangeUtils.DATE, DateTools.Resolution.MONTH)
    rangeTypes.put(hourField, new RangeUtils.Type(RangeUtils.DATE,  DateTools.Resolution.HOUR)
    rangeTypes.put(distanceField, RangeUtils.getType(RangeUtils.NUMERIC,  RangeUtils.NumericType.LONG,
    rangeTypes.put(moneyField, RangeUtils.getType(RangeUtils.NUMERIC,  RangeUtils.NumericType.Type.FLOAT,

    StandardQueryParser qp = new StandardQueryParser();

    // set default range type to Int default precision
    qp.setDefaultRangeType(RangeUtils.getType(RangeUtils.NUMERIC,  RangeUtils.NumericType.INT,

    // set field range types

   Query q = qp.parser(" month:[01/01/2004 TO 01/01/2005]  distance:[1000 to 2000] money:
[23.50 to 50.99]");


> NumericRange support for new query parser
> -----------------------------------------
>                 Key: LUCENE-1768
>                 URL:
>             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:
For additional commands, e-mail:

View raw message