Hi all. I've been playing a lot with the new query parser framework, primarily as a means of converting a query structure back into a string. I was hoping that I would be able to use it for the parsing direction as well a bit later, to simply our customisations on the older query parser, and that much certainly does seem possible.
But I've noticed what might be some strange behaviour with range queries, specifically with what happens when I try to convert them back into the original query string. StandardQueryParser queryParser = new StandardQueryParser(); QueryNode node = queryParser.getSyntaxParser().parse("size:[0 TO 1000]", null); System.out.println(node.toString()); Prints this: <parametricRange> <parametric field='size' operator='<=' text='1000'/> <parametric field='size' operator='>=' text='0'/> </parametricRange> And this is fine (though the order of the inner elements is surprising), but this: System.out.println(node.toQueryString(new EscapeQuerySyntaxImpl())); Prints this: size>="0" AND size<="1000" This is nothing like the original query string passed in, and on top of that, if you parse it a second time through the same query parser, you get something completely new again, showing that the parser itself doesn't understand this syntax: <boolean operation='default'> <field start='1' end='6' field='null' text='size>='/> <boolean operation='and'> <quotedfield start='8' end='8' field='null' term='0'/> <field start='15' end='20' field='null' text='size<='/> </boolean> <quotedfield start='22' end='25' field='null' term='1000'/> </boolean> So what I would like to know is: 1. What is the simplest way for me to have a range query which I can convert back into the original string? 2. Is the current model of the new query parser going to work for everyone? I had a bit of a think about this and it would seem that as soon as someone defines a new SyntaxParser which uses a completely different format, the QueryNode objects which come out would no longer know how to convert themselves back into that original syntax. It would seem that Lucene would also need a corresponding SyntaxFormatter to convert from QueryNode back to String. 3. What about going all the way from Query back to String? (My naive answer to my own question here is that some QueryNodeProcessor may perform an irreversible operation, making it impossible to do this, but I thought I would throw the question in anyway.) Daniel -- Daniel Noll Forensic and eDiscovery Software Senior Developer The world's most advanced Nuix email data analysis http://nuix.com/ and eDiscovery software --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org