Return-Path: Delivered-To: apmail-jakarta-lucene-user-archive@www.apache.org Received: (qmail 24592 invoked from network); 1 Jul 2004 16:34:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 1 Jul 2004 16:34:45 -0000 Received: (qmail 55207 invoked by uid 500); 1 Jul 2004 16:34:46 -0000 Delivered-To: apmail-jakarta-lucene-user-archive@jakarta.apache.org Received: (qmail 55129 invoked by uid 500); 1 Jul 2004 16:34:45 -0000 Mailing-List: contact lucene-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Users List" Reply-To: "Lucene Users List" Delivered-To: mailing list lucene-user@jakarta.apache.org Received: (qmail 55116 invoked by uid 99); 1 Jul 2004 16:34:45 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [128.143.104.168] (HELO postfix.mail.ehatchersolutions.com) (128.143.104.168) by apache.org (qpsmtpd/0.27.1) with ESMTP; Thu, 01 Jul 2004 09:34:44 -0700 Received: from [127.0.0.1] (localhost [127.0.0.1]) by postfix.mail.ehatchersolutions.com (Postfix) with ESMTP id 80DCC7ADA91 for ; Thu, 1 Jul 2004 12:34:35 -0400 (EDT) Mime-Version: 1.0 (Apple Message framework v613) In-Reply-To: <3414790679479308471QHGHRLGOSE.tlai@trekspace.com> References: <3414790679479308471QHGHRLGOSE.tlai@trekspace.com> Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <88F01299-CB7C-11D8-A641-000393A564E6@ehatchersolutions.com> Content-Transfer-Encoding: 7bit From: Erik Hatcher Subject: Re: Building query to match a sub-string of a field Date: Thu, 1 Jul 2004 12:34:34 -0400 To: "Lucene Users List" X-Mailer: Apple Mail (2.613) X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N On Jun 29, 2004, at 5:28 PM, Terence Lai wrote: > Hi Everyone, > > I am trying to construct a query which matches a sub-string of a > field. As an illustration, I would like to search the following words > by using the sub-string "test": > > - test > - testing > - contest > - contestable > > I realize that Lucene does support wildcard searches using "*" and "?" > in the custom query. Therefore, the query string "*test*" should give > me the right result. However, the Lucene query syntax > (http://jakarta.apache.org/lucene/docs/queryparsersyntax.html) does > not allow the wildcard "*" as the first character of the search. > Therefore, the query "*test*" is invalid. Does anyone have a solution > to build the query to achieve the same result? Query query = new WildcardQuery(new Term("field", "*test*")); Careful with performance and term expansion on this though. Erik --------------------------------------------------------------------- To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: lucene-user-help@jakarta.apache.org