From general-return-8-apmail-lucene-general-archive=lucene.apache.org@lucene.apache.org Tue Apr 26 19:02:06 2005 Return-Path: Delivered-To: apmail-lucene-general-archive@www.apache.org Received: (qmail 66987 invoked from network); 26 Apr 2005 19:02:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 26 Apr 2005 19:02:06 -0000 Received: (qmail 6367 invoked by uid 500); 26 Apr 2005 19:02:50 -0000 Delivered-To: apmail-lucene-general-archive@lucene.apache.org Received: (qmail 6338 invoked by uid 500); 26 Apr 2005 19:02:50 -0000 Mailing-List: contact general-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: general@lucene.apache.org Delivered-To: mailing list general@lucene.apache.org Received: (qmail 6291 invoked by uid 99); 26 Apr 2005 19:02:49 -0000 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=FORGED_RCVD_HELO X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from smtp-vbr11.xs4all.nl (HELO smtp-vbr11.xs4all.nl) (194.109.24.31) by apache.org (qpsmtpd/0.28) with ESMTP; Tue, 26 Apr 2005 12:02:49 -0700 Received: from k8l.lan (porta.xs4all.nl [80.127.24.69]) by smtp-vbr11.xs4all.nl (8.12.11/8.12.11) with ESMTP id j3QJ20n7085023 for ; Tue, 26 Apr 2005 21:02:00 +0200 (CEST) (envelope-from paul.elschot@xs4all.nl) From: Paul Elschot To: general@lucene.apache.org Subject: Re: searching between two fields Date: Tue, 26 Apr 2005 21:02:00 +0200 User-Agent: KMail/1.5.4 References: <78A2AFE317F5AD48B823BE740D4A8152240723@flexbe01.crcpress.com> In-Reply-To: <78A2AFE317F5AD48B823BE740D4A8152240723@flexbe01.crcpress.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200504262102.00089.paul.elschot@xs4all.nl> X-Virus-Scanned: by XS4ALL Virus Scanner X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N On Tuesday 26 April 2005 20:18, Kipping, Peter wrote: > Suppose I have a document with two fields, min_temp = 100 and max_temp = > 200. If a user inputs a search value of 150 the document should be > returned. Is it possible to make this happen with lucene? > > Thanks, > Peter Yes, but it would require some extra investments. The query would be a BooleanQuery of two required RangeQuery's, with the numbers indexed as strings with zero prefixes to make the numerical comparison identical to the string comparison used in by the index. In case there are a lot of different temperature values to be indexed, it would probably be good to also index prefixes of some well chosen lengths of the indexed minimum and maximum temperatures and adapt the term enumeration in the RangeQuery to use the prefixes whenever possible. Regards, Paul Elschot.