Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 78141 invoked from network); 29 Nov 2009 22:27:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 29 Nov 2009 22:27:55 -0000 Received: (qmail 49334 invoked by uid 500); 29 Nov 2009 22:27:52 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 49245 invoked by uid 500); 29 Nov 2009 22:27:52 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 49235 invoked by uid 99); 29 Nov 2009 22:27:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 29 Nov 2009 22:27:52 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [209.85.222.176] (HELO mail-pz0-f176.google.com) (209.85.222.176) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 29 Nov 2009 22:27:42 +0000 Received: by pzk6 with SMTP id 6so1993694pzk.29 for ; Sun, 29 Nov 2009 14:27:20 -0800 (PST) MIME-Version: 1.0 Received: by 10.143.129.7 with SMTP id g7mr405410wfn.241.1259533640290; Sun, 29 Nov 2009 14:27:20 -0800 (PST) Date: Mon, 30 Nov 2009 09:27:19 +1100 Message-ID: Subject: New Query Parser: converting a QueryNode back into a String? From: Daniel Noll To: java-user@lucene.apache.org Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org 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: 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: 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-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org