From java-user-return-44838-apmail-lucene-java-user-archive=lucene.apache.org@lucene.apache.org Wed Feb 03 10:03:18 2010 Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 43842 invoked from network); 3 Feb 2010 10:03:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 3 Feb 2010 10:03:18 -0000 Received: (qmail 16885 invoked by uid 500); 3 Feb 2010 10:03:15 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 16799 invoked by uid 500); 3 Feb 2010 10:03:15 -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 16789 invoked by uid 99); 3 Feb 2010 10:03:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Feb 2010 10:03:15 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ian.lea@gmail.com designates 209.85.218.214 as permitted sender) Received: from [209.85.218.214] (HELO mail-bw0-f214.google.com) (209.85.218.214) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Feb 2010 10:03:07 +0000 Received: by bwz6 with SMTP id 6so755900bwz.11 for ; Wed, 03 Feb 2010 02:02:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=cW4mCGYElJfJmsRIXxtSCmEXxZUm30+QGJJsPYH0YxU=; b=LH3duKi/A9fuFi+IFOWWL1PyhTo0ZE6vt6/ErBubhQjQkBYD5r5N3u6wmk2dM9YyOK 8ujeTRLngFEzzeWnfnnXw/SfEjyjI8dPLNsUbaN0GzrQNEaQkoPMnohT/+qwD2VBdGAV UqzuqayPKwXTBs/Ir7kB9NVfWdK9SzOKGK4jU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=L60m972aMsa/IbFbK3DITv9E0SCkYSWeOEji5NJaFPR0ECI3zI+1yiQH7uYQeFRBb9 h4tGsfHbHMySD1zdt3xC47/vtuWgGtmo2ouOJxi54NyEj4SCrBYwlXQPaUHxfafUVJ9Y nqKovOngSEchKFsPEqd2HO4OsWf9Js6M5nal0= MIME-Version: 1.0 Received: by 10.204.23.20 with SMTP id p20mr3495280bkb.54.1265191367173; Wed, 03 Feb 2010 02:02:47 -0800 (PST) In-Reply-To: References: <3b23ce091002021159i10598263j743f9559782f5bc0@mail.gmail.com> From: Ian Lea Date: Wed, 3 Feb 2010 10:02:27 +0000 Message-ID: <8c4e68611002030202v486d78e2p6247799f75bedb3e@mail.gmail.com> Subject: Re: confused by the lucene boolean query with wildcard result To: java-user@lucene.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org You should probably be using your PerFieldAnalyzerWrapper in your calls to QueryParser but apart from that I can't see any obvious reason. General advice: use Luke to check what has been indexed and read http://wiki.apache.org/lucene-java/LuceneFAQ#Why_am_I_getting_no_hits_= .2BAC8_incorrect_hits.3F If none of these help, post again but showing what you are indexing as well as how you are searching - the smallest possible test case or self-contained program that shows the problem. Or maybe someone else will spot the problem. -- Ian. On Tue, Feb 2, 2010 at 8:56 PM, java8964 java8964 wr= ote: > > Hi, I have the following test case point to the index generated in our ap= plication. The result is confusing me and I don't know the reason. > > Lucene version: 2.9.0 > JDK 1.6.0_18 > > public class IndexTest1 { > =A0 =A0public static void main(String[] args) { > =A0 =A0 =A0 =A0try { > =A0 =A0 =A0 =A0 =A0 =A0FSDirectory directory =3D FSDirectory.open(new Fil= e("/path_to_index_files")); > =A0 =A0 =A0 =A0 =A0 =A0IndexSearcher searcher =3D new IndexSearcher(direc= tory, true); > =A0 =A0 =A0 =A0 =A0 =A0PerFieldAnalyzerWrapper wrapper =3D new PerFieldAn= alyzerWrapper(new StandardAnalyzer()); > =A0 =A0 =A0 =A0 =A0 =A0wrapper.addAnalyzer("f1string_sif", new KeywordAna= lyzer()); > =A0 =A0 =A0 =A0 =A0 =A0wrapper.addAnalyzer("f2string_ti", new StandardAna= lyzer(Version.LUCENE_CURRENT)); > =A0 =A0 =A0 =A0 =A0 =A0Query query =3D new QueryParser("f1string_sif", ne= w StandardAnalyzer(Version.LUCENE_CURRENT)).parse("f2string_ti:subbank*"); > =A0 =A0 =A0 =A0 =A0 =A0System.out.println("query =3D " + query); > =A0 =A0 =A0 =A0 =A0 =A0System.out.println("hits =3D " + searcher.search(q= uery, 100).totalHits); > =A0 =A0 =A0 =A0 =A0 =A0searcher.close(); > =A0 =A0 =A0 =A0} catch (Exception e) { > =A0 =A0 =A0 =A0 =A0 =A0System.out.println(e); > =A0 =A0 =A0 =A0} > =A0 =A0} > } > > Output: > query =3D f2string_ti:subbank* > hits =3D 6 > > If I change the line to the following: > > Query query =3D new QueryParser("f1string_sif", new StandardAnalyzer(Vers= ion.LUCENE_CURRENT)).parse("f2string_ti:rdmap*"); > > Output: > query =3D f2string_ti:rdmap* > hits =3D 4 > > The above result are both correct based on my data. > > Now if I change the line to: > > Query query =3D new QueryParser("f1string_sif", new StandardAnalyzer(Vers= ion.LUCENE_CURRENT)).parse("f2string_ti:subbank* OR f2string_ti:rdmap*"); > > Output: > query =3D f2string_ti:subbank* f2string_ti:rdmap* > hits =3D 2 > > > I assume the count in the last result should be larger than max(6,4), but= it is 2. Any reason for that? > > Thanks > > > _________________________________________________________________ > Hotmail: Trusted email with powerful SPAM protection. > http://clk.atdmt.com/GBL/go/201469227/direct/01/ --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org