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

Uwe Schindler commented on LUCENE-1768:
---------------------------------------

I would propose to absorb the RangeTools/Utils and DateTools/Utils (ehat is the 
correct name???) in one configuration class (just a bigger enumeration with a 
good name, not *Utils/*.Tools. e.g. RangeQueryDataType). By that you can define 
simply the type of a range query: term, numeric-int, numeric-float, 
numeric-double, date-precision-xxx,... Based on this enumeration, the 
upper/lower terms are parsed differently and different query objects are 
created. We just need to list all possible combinations of data types, the user 
could create: We could make this class extensible, if it is a Lucene Parameter 
class also supporting the parsing and building: One could simply create a new 
constant for his specific range type and supply methods to parse and build the 
query in the constant's implementation (so each constant contains also code to 
parse/build). I am not sure how to do this with the new parser. I think of the 
same like the MTQRewriteMethod (final static singletons in MTQ that do the 
rewrite and can be passed as parameter).

Maybe we can use this also to upgrade the old query parser if it gets not 
deprecated.

bq. I think it's already happening with the "old" QP. It used to output 
RangeQuery objects and now it outputs TermRangeQuery objects. How is it going 
to be handled buy users expecting RangeQuery objects?

I was thinking about that, too. But here the API clearly defines, that 
getRangeQuery() returns a Query object without further specification. So the 
change was correct from the API/BW side. The change that another object is 
returned is documented in CHANGES.txt (as far as I know). We have here the same 
problem: You change the inner class implementations, but the abstract 
QueryParser's API is stable. The general contract when doing such things is, 
that you use instanceof checks before you try to cast some abstract return type 
to something specific, not documented.

You have the same in various factories also in the very bw-oriented JDK: XML 
factories create things like SAXParser and so on. If you cast the returned 
objects to some special implementation class, its your problem, because you 
remove the abstraction and work with implementations. This happened e.g. from 
the change between Java 1.4 to 1.5, when the internal SAX parsers were 
exchanged and their class names changed. A lot of programs broke by that, 
because the developers casted the objects returned from factories without 
instanceof checks.

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

Reply via email to