lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Lea <ian....@gmail.com>
Subject Re: confused by the lucene boolean query with wildcard result
Date Wed, 03 Feb 2010 10:02:27 GMT
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 <java8964@hotmail.com> wrote:
>
> Hi, I have the following test case point to the index generated in our application. 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 {
>    public static void main(String[] args) {
>        try {
>            FSDirectory directory = FSDirectory.open(new File("/path_to_index_files"));
>            IndexSearcher searcher = new IndexSearcher(directory, true);
>            PerFieldAnalyzerWrapper wrapper = new PerFieldAnalyzerWrapper(new StandardAnalyzer());
>            wrapper.addAnalyzer("f1string_sif", new KeywordAnalyzer());
>            wrapper.addAnalyzer("f2string_ti", new StandardAnalyzer(Version.LUCENE_CURRENT));
>            Query query = new QueryParser("f1string_sif", new StandardAnalyzer(Version.LUCENE_CURRENT)).parse("f2string_ti:subbank*");
>            System.out.println("query = " + query);
>            System.out.println("hits = " + searcher.search(query, 100).totalHits);
>            searcher.close();
>        } catch (Exception e) {
>            System.out.println(e);
>        }
>    }
> }
>
> Output:
> query = f2string_ti:subbank*
> hits = 6
>
> If I change the line to the following:
>
> Query query = new QueryParser("f1string_sif", new StandardAnalyzer(Version.LUCENE_CURRENT)).parse("f2string_ti:rdmap*");
>
> Output:
> query = f2string_ti:rdmap*
> hits = 4
>
> The above result are both correct based on my data.
>
> Now if I change the line to:
>
> Query query = new QueryParser("f1string_sif", new StandardAnalyzer(Version.LUCENE_CURRENT)).parse("f2string_ti:subbank*
OR f2string_ti:rdmap*");
>
> Output:
> query = f2string_ti:subbank* f2string_ti:rdmap*
> hits = 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


Mime
View raw message