lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Baranczak <mbara...@twcny.rr.com>
Subject Results ranking on filtered multi-field query
Date Sun, 01 May 2005 17:05:39 GMT
I'm building a search engine that searches multiple document fields by 
default. Given a query string like "Bruce Lee", I would expect the 
results list to first show the documents containing both "Bruce" and 
"Lee", and then the documents which only contain one of those names. 
Most of the time, this is indeed what happens, but I've noticed that in 
certain circumstances, Lucene doesn't rank the results in the expected 
order. Specifically, it happens when I enter a query containing 
multiple words, searching multiple fields, AND try to put the results 
of that through a filter.

Code example is below. Is this a bug, or am I doing something wrong?

Thanks in advance. I can provide more information, if needed.

-MB

------------------------

             String[] fields = new String[] {"title", "description", 
"body"};
             IndexSearcher index = new IndexSearcher(INDEX_DIR);
             Analyzer analyzer = new StandardAnalyzer();
             String queryStr = "Bruce Lee";

             // OK
             System.out.println("\n\n - test run 0:");
             Query q0 = QueryParser.parse(queryStr, "title", analyzer);
             printResults(index.search(q0));

             // OK
             System.out.println("\n\n - test run 1:");
             Query q1 = MultiFieldQueryParser.parse(queryStr, fields, 
analyzer);
             printResults(index.search(q1));

             // WRONG!
             System.out.println("\n\n - test run 2:");
             Query q2 = MultiFieldQueryParser.parse(queryStr, fields, 
analyzer);
             Filter filt0 = new QueryFilter(new TermQuery(new 
Term("category", "movies")));
             Query q2f = new FilteredQuery(q2, filt0);
             printResults(index.search(q2f));

             // OK
             System.out.println("\n\n - test run 3:");
             Query q3 = QueryParser.parse(queryStr, "description", 
analyzer);
             Query q3f = new FilteredQuery(q3, filt0);
             printResults(index.search(q3f));

             // WRONG!
             System.out.println("\n\n - test run 4:");
             printResults(index.search(q1, filt0));


--------------------------


---------------------------------------------------------------------
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