lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Baranczak <>
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.



             String[] fields = new String[] {"title", "description", 
             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);

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

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

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

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


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message