Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 34693 invoked from network); 21 Nov 2006 23:30:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Nov 2006 23:30:22 -0000 Received: (qmail 76041 invoked by uid 500); 21 Nov 2006 23:30:25 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 76010 invoked by uid 500); 21 Nov 2006 23:30:25 -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 75999 invoked by uid 99); 21 Nov 2006 23:30:25 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Nov 2006 15:30:25 -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 [128.230.18.29] (HELO mailer.syr.edu) (128.230.18.29) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Nov 2006 15:30:11 -0800 Received: from [128.230.84.138] (syru84-138.syr.edu) by mailer.syr.edu (LSMTP for Windows NT v1.1b) with SMTP id <0.15B19F7F@mailer.syr.edu>; Tue, 21 Nov 2006 18:29:50 -0500 Message-ID: <45638BEE.7000901@syr.edu> Date: Tue, 21 Nov 2006 18:29:50 -0500 From: Steven Rowe User-Agent: Mail/News 1.5.0.4-GroupWise-IMAP-fix (Windows/20060619) MIME-Version: 1.0 To: java-user@lucene.apache.org Subject: Re: Limiting QueryParser References: <45637D01.7080000@teamware.com> <4563899B.1030305@gmail.com> In-Reply-To: <4563899B.1030305@gmail.com> X-Enigmail-Version: 0.94.1.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org static String QueryParser.escape(String) should do the trick: Look at the bottom of the below-linked page for the list of characters that the above method will escape: Steve Mark Miller wrote: > if you scan the query and escape all colons (ie \:) then you should be > good (I have not verified). Of course you will not be able to do a field > search, but that seems to be what your after. > > Antony Bowesman wrote: >> Hi, >> >> I have a search UI that allows search criteria to be input against >> specific fields, e.g. Subject. >> >> In order to create a suitable Lucene Query, I must analyze that String >> so that it becomes a set of Tokens which I can then turn into Terms. >> QueryParser seems to fit the bill for that, however, it is too clever >> as it assumes that anything suffixes with a : is a field reference. >> >> If someone enters >> >> important:conference agenda >> >> in the subject field, I don't want QP to translate this to >> >> +important:conference +defaultfield:agenda >> >> I want to end up with >> >> +subject:important +subject:conference +subject:agenda >> >> I've written something to do this, but I know it is not as clever as >> QP as currently it can only create BooleanQueries with TermQueries and >> cannot handle PhraseQuery, so would not handle >> >> important:"conference agenda" >> >> correctly. Does anyone have any pointers on how to limit QueryParser >> so that I can force it to treat what it thinks as fields as terms. >> >> Thanks >> Antony --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org