Return-Path: Delivered-To: apmail-lucene-java-dev-archive@www.apache.org Received: (qmail 38721 invoked from network); 19 Nov 2009 20:24:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 19 Nov 2009 20:24:05 -0000 Received: (qmail 54832 invoked by uid 500); 19 Nov 2009 20:24:04 -0000 Delivered-To: apmail-lucene-java-dev-archive@lucene.apache.org Received: (qmail 54779 invoked by uid 500); 19 Nov 2009 20:24:04 -0000 Mailing-List: contact java-dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@lucene.apache.org Delivered-To: mailing list java-dev@lucene.apache.org Received: (qmail 54771 invoked by uid 99); 19 Nov 2009 20:24:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Nov 2009 20:24:04 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Nov 2009 20:24:01 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 637BA234C498 for ; Thu, 19 Nov 2009 12:23:40 -0800 (PST) Message-ID: <1754577516.1258662220406.JavaMail.jira@brutus> Date: Thu, 19 Nov 2009 20:23:40 +0000 (UTC) From: "David Kaelbling (JIRA)" To: java-dev@lucene.apache.org Subject: [jira] Issue Comment Edited: (LUCENE-2039) Regex support and beyond in JavaCC QueryParser In-Reply-To: <1096156079.1257532832431.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/LUCENE-2039?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D127= 80193#action_12780193 ]=20 David Kaelbling edited comment on LUCENE-2039 at 11/19/09 8:22 PM: ------------------------------------------------------------------- I apologize if I haven't read the comments carefully enough, but in LUCENE-= 2039_field_ext.patch why is ExtendableQueryParser final? That means (for e= xample) that ComplexPhraseQueryParser cannot subclass it. In the earlier L= UCENE-2039.patch the complex phrase parser picked up the changes for free. And would RegexParserExtension maybe be easier to use if it set the RegexCa= pabilities on the new RegexQuery it is returning? was (Author: dkaelbling@blackducksoftware.com): I apologize if I haven't read the comments carefully enough, but in LUC= ENE-2039_field_ext.patch why is ExtendableQueryParser final? That means (f= or example) that ComplexPhraseQueryParser cannot subclass it. In the earli= er LUCENE-2039.patch the complex phrase parser picked up the changes for fr= ee. =20 > Regex support and beyond in JavaCC QueryParser > ---------------------------------------------- > > Key: LUCENE-2039 > URL: https://issues.apache.org/jira/browse/LUCENE-2039 > Project: Lucene - Java > Issue Type: Improvement > Components: QueryParser > Reporter: Simon Willnauer > Assignee: Grant Ingersoll > Priority: Minor > Fix For: 3.1 > > Attachments: LUCENE-2039.patch, LUCENE-2039_field_ext.patch > > > Since the early days the standard query parser was limited to the queries= living in core, adding other queries or extending the parser in any way al= ways forced people to change the grammar file and regenerate. Even if you c= hange the grammar you have to be extremely careful how you modify the parse= r so that other parts of the standard parser are affected by customisation = changes. Eventually you had to live with all the limitation the current par= ser has like tokenizing on whitespaces before a tokenizer / analyzer has th= e chance to look at the tokens.=20 > I was thinking about how to overcome the limitation and add regex support= to the query parser without introducing any dependency to core. I added a = new special character that basically prevents the parser from interpreting = any of the characters enclosed in the new special characters. I choose the = forward slash '/' as the delimiter so that everything in between two forwa= rd slashes is basically escaped and ignored by the parser. All chars embedd= ed within forward slashes are treated as one token even if it contains othe= r special chars like * []?{} or whitespaces. This token is subsequently pas= sed to a pluggable "parser extension" with builds a query from the embedded= string. I do not interpret the embedded string in any way but leave all th= e subsequent work to the parser extension. Such an extension could be anoth= er full featured query parser itself or simply a ctor call for regex query.= The interface remains quiet simple but makes the parser extendible in an e= asy way compared to modifying the javaCC sources. > The downsides of this patch is clearly that I introduce a new special cha= r into the syntax but I guess that would not be that much of a deal as it i= s reflected in the escape method though. It would truly be nice to have mor= e than once extension an have this even more flexible so treat this patch a= s a kickoff though. > Another way of solving the problem with RegexQuery would be to move the J= DK version of regex into the core and simply have another method like: > {code} > protected Query newRegexQuery(Term t) { > ...=20 > } > {code} > which I would like better as it would be more consistent with the idea of= the query parser to be a very strict and defined parser. > I will upload a patch in a second which implements the extension based ap= proach I guess I will add a second patch with regex in core soon too. --=20 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-unsubscribe@lucene.apache.org For additional commands, e-mail: java-dev-help@lucene.apache.org