The proposed RangeTools seems like a good approach, and I like how it
cleanly absorbs the Date precisions that the old queryParser also
You meant DateTools, right?! I don't see so much difference to use this same approach over the "option1". You have a map based from field name to the DateTools.Resolution used for that field. Which is the same feature we want to implement on this JIRA, something you could configure how you are going to resolve the value defined on a range query based on the field name. The only difference is that we are expanding the options the user will have to resolve the values: RangeUtils.NUMERIC, RangeUtils.DATE, RangeUtils.FLOAT, etc...let me know if I missed or missunderstood something on this part.
Here's one side-question, about back compat promises for the new
QueryParser: we are suggesting the users can start from all the
building blocks in StandardQueryParser, and override the processors,
create new nodes, builders, etc. with their own. But this is
potentially dangerous, in that the next version of Lucene might change
things up such that your custom code doesn't work anymore? It's alot
like a core class being subclassed externally, and then change to the
core class break those external subclasses.
EG say we had not handled numerics for 2.9, and users go and do
"option 2" (the quick & dirty, but simplest, way to get
NumericRangeQueries out). Then, say in 3.1 we implement the proposed
fix here ("option 1"). Suddenly, we've altered what nodes come out of
the processor pipeline, because we've created a new NumericRangeQuery
node, and so the builders that users had added, for the RangeQuery
node, will no loner be invoked. How are we going to handle
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?
The "new" QP builder, delegates a query node based on its class to a builder, if there is no builder that knows how to build an object from that class it keeps looking up in the class hierarchy until it finds a builder that knows how to. Query nodes are supposed to be conceptual objects, they just represent some concept X, and ideally anything that fits in this concept should inherit from it, this way the user can create their own specific query nodes with no need to change how they are built (if there is no need for that). What I'm trying to say here is that if I create a node Y which extends X, I don't need to specify a new YBuilder for it, the XBuilder will be used. So, ideally, NumericRangeQueryNode should extends RangeQueryNode, the problem here is that we also need to specify a builder for the NumericRangeNode, and if the user sets a builder for RangeNode it will never be invoked for NumericRangeNode objects. Maybe it shouldn't at all, because if a new builder was specified for NumericRangeNode, it means a new kind of object should be built from it, something the user probably don't know yet, since it's a new kind of node, and his custom code needs to be updated anyway to support it.
Howerver, there is a solution for this kind of back-compat problem (which I don't think it is). In a future release, if a new XRangeQueryNode is created, instead of set
luceneBuilderMap.setBuilder(RangeQueryNode.class, new RangeQueryNodeBuilder());
luceneBuilderMap.setBuilder(XRangeQueryNode.class, new XRangeQueryNodeBuilder());
We could do:
rangeBuilderMap.setBuilder(RangeQueryNode.class, new RangeQueryNodeBuilder());
rangeBuilderMap.setBuilder(XRangeQueryNode.class, new XRangeQueryNodeBuilder());
This way, if the user reset the RangeQueryNode builder to its own builder, it will still be called for XRangeQueryNode and RangeQueryNode objects.
Let me know if there is any question about what I just described.