Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 11175 invoked from network); 22 Nov 2006 09:15:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Nov 2006 09:15:49 -0000 Received: (qmail 40513 invoked by uid 500); 22 Nov 2006 09:15:50 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 40476 invoked by uid 500); 22 Nov 2006 09:15:50 -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 40464 invoked by uid 99); 22 Nov 2006 09:15:50 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Nov 2006 01:15:50 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [69.55.225.129] (HELO ehatchersolutions.com) (69.55.225.129) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Nov 2006 01:15:37 -0800 Received: by ehatchersolutions.com (Postfix, from userid 504) id 2336F30EFC16; Wed, 22 Nov 2006 04:15:17 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on javelina X-Spam-Level: Received: from [10.0.1.3] (va-71-53-203-135.dhcp.embarqhsd.net [71.53.203.135]) by ehatchersolutions.com (Postfix) with ESMTP id 9FE6430EFC16 for ; Wed, 22 Nov 2006 04:15:09 -0500 (EST) Mime-Version: 1.0 (Apple Message framework v752.3) In-Reply-To: <4563C54A.2010907@teamware.com> References: <45637D01.7080000@teamware.com> <4563C54A.2010907@teamware.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <3CCDA72B-667B-4EC7-B4C0-EAF80842C87B@ehatchersolutions.com> Content-Transfer-Encoding: 7bit From: Erik Hatcher Subject: Re: Limiting QueryParser Date: Wed, 22 Nov 2006 04:15:07 -0500 To: java-user@lucene.apache.org X-Mailer: Apple Mail (2.752.3) X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=-0.8 required=5.0 tests=AWL,BAYES_00, RCVD_IN_SORBS_DUL autolearn=no version=3.1.1 On Nov 21, 2006, at 10:34 PM, Antony Bowesman wrote: > On the field specific fields, I want to control the parsing to > ensure that the parser will not interpret fields in the user > entered string, so in those fields it treats : as : all of the > time. However, in the "free form" field, anything goes and : is a > field delimeter all of the time. So, a user can seach for > > Subject - important:conference agenda > FieldA - blah:abc > FreeForm - fieldX:Xdata fieldY:Ydata > > in the above, the Subject and Field A would have been indexed using > configurable analysers and would have indexed "important" and > "blah", so these are relevant to the search. > > This should come out as a > > (+subject:important +subject:conference +subject:agenda) > (+fielda:blah +fielda:abc) (+fieldx:xdata +fieldy:ydata) > > My framework allows for field specific parsers as well as field > specific analysers, so having a different query parser for the > named fields and the free form field is fine. It doesn't seem like you need a "parser" at all for your field- specific search fields. Simply tokenize, using a Lucene Analyzer, the text field and build up a BooleanQuery of all the tokens. QueryParser is over prescribed - and is often not the best fit for the job. It's only a few lines of code to tokenize (look at the QueryParser code in how it creates a PhraseQuery, for example) and build a Query from the tokens. If you need to support +/-/AND/OR syntax in your field-specific inputs that's a different story - though your example does not show this need. If so, copying the QueryParser.jj file and removing the "field:" syntax and fixing all created Query objects to a specified single field might be the trick. Erik --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org