Return-Path: X-Original-To: apmail-lucene-java-user-archive@www.apache.org Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A38049B11 for ; Wed, 14 Mar 2012 15:33:09 +0000 (UTC) Received: (qmail 40676 invoked by uid 500); 14 Mar 2012 15:33:07 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 40624 invoked by uid 500); 14 Mar 2012 15:33:07 -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 40616 invoked by uid 99); 14 Mar 2012 15:33:07 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Mar 2012 15:33:07 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of deb.lucene@gmail.com designates 209.85.215.48 as permitted sender) Received: from [209.85.215.48] (HELO mail-lpp01m010-f48.google.com) (209.85.215.48) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Mar 2012 15:33:00 +0000 Received: by lagu2 with SMTP id u2so2170679lag.35 for ; Wed, 14 Mar 2012 08:32:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=BW2Yp7Go4KIhJRoIBmWuj2UWvkBjSEbUdzYkm5hNuG8=; b=S/eh9FjFD4F/HLkzpdCx1HORxbQY5COAf1RvHM/hLvfTbyaoXOg/+StVhyYyLddOIq w2vtfUDfHruRY7lFrweNMug7RgC4V/DuKRKoRfDNxsXI79UWtzbIRTO8toUoP2GM1mjN dh0ugZqDRJ4PczCk012fYLG2PudnZK9il+tPW7MT7UJ+3LziiiBZnNDFYW37UpuItVEs qrr2fnTpIo+oIIKMfg7FEI/Ko6oHoGFWDosq8Q33tOlrgTVr4M46ytgoKxGTYHn5ZbJo koDks6tG3xrA2dT72oPMgCqOffmas2Qb1cdwu+FOFxPXngw4KJNRLawbJvtpgtKXkrtZ V05Q== MIME-Version: 1.0 Received: by 10.152.115.69 with SMTP id jm5mr2224867lab.25.1331739159439; Wed, 14 Mar 2012 08:32:39 -0700 (PDT) Received: by 10.112.23.105 with HTTP; Wed, 14 Mar 2012 08:32:39 -0700 (PDT) In-Reply-To: References: Date: Wed, 14 Mar 2012 11:32:39 -0400 Message-ID: Subject: Multi field search with values From: Deb Lucene To: java-user@lucene.apache.org Content-Type: multipart/alternative; boundary=f46d04088ee18827f704bb35af63 X-Virus-Checked: Checked by ClamAV on apache.org --f46d04088ee18827f704bb35af63 Content-Type: text/plain; charset=ISO-8859-1 Hi Group, I am working on a Lucene search solution for multiple fields. So far, if the fields are of string type I am having no difficulties in retrieving using the MultiFieldQueryParser. For example, my indexing and searching logic look like this - indexing - I am indexing a corpus on the content of the documents and some keywords of the documents. ********************************************** String doc = getText(id) ; List keywords = getKeywords(doc); document.add(new Field("content", doc, Field.Store.NO,Field.Index.ANALYZED, Field.TermVector.YES)); for ( String keyword : keywords ) { document.add(new Field("keyword", keyword, Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.YES)); } ********************************************* I am searching over the indexes using some query text and predefined keywords searching : ******************************************** String queryText = getQuery(); String keyword = getKeyword(); BooleanClause.Occur[] flags = {BooleanClause.Occur.SHOULD,BooleanClause.Occur.SHOULD}; Query query = MultiFieldQueryParser.parse(Version.LUCENE_33, new String[] {queryText, keyword}, new String[]{"content","keywords"}, flags, stAnalyzer); [stAnalyzer is the standard analyzer] TopDocs hits = isearcher.search(query, 20); ******************************************** This code is working fine. But now suppose I add one more field (a "threshold" set on some prior calculation) which is of numeric type. NumericField field = new NumericField("threshold") ; document.add(field.setDoubleValue(threhold)); Now can I search over multiple fields using the "string" type (i.e. content and keywords) with the "double" type (i.e. the threshold)? I am particularly looking for a query such as - query - "some content" and "some keywords" and threshold > 0.5. I surmise I need to use the "numeric field search" technique but not sure how to add the functionality in MultiFieldQueryParser. Thanks in advance, --d --f46d04088ee18827f704bb35af63--