Grokbase Groups Lucene dev March 2006
[ ]

Daniel Naber resolved LUCENE-158:

Fix Version: 1.9
Resolution: Fixed
Assign To: (was: Lucene Developers)

This isn't an issue anymore in Lucene 1.9.

[PATCH] MultiFieldQueryParser, can't change default search operator

Key: LUCENE-158
Project: Lucene - Java
Type: Bug
Components: QueryParser
Versions: 1.0.2
Environment: Operating System: Linux
Platform: Other
Reporter: Christoph Goller
Fix For: 1.9
Attachments: multiFieldPatch.txt

Bug detected by Bernhard, submitted via Christoph
bug occured with 1.3 rc2
just played around with the MultiFieldQueryParser and didn't find a working way
to change the "operator" value.
The problem is that MultiFieldQueryParser is implementing two public static
methods "parse" only. Calling one of those, in the extended superclass, the
static method implementation for "parse" is called. Due to the fact that the
QueryParser class creates a new Instance for each call thru the static method,
the "operator" flag is simply ignored.
There would be a simple fix within MultiFieldQueryParser class without touching
the rest of the system. One have to add a new non static method "parse" which
could look like this:
public Query parse(String query, String[] fields) throws ParseException {
BooleanQuery bQuery = new BooleanQuery();
for (int i = 0; i < fields.length; i++)
QueryParser parser = new QueryParser(fields[i], analyzer);
Query q = parser.parse(query);
bQuery.add(q, false, false);
return bQuery;
To test the new implementation, following code fragment can be used:
Directory directory = FSDirectory.getDirectory("/tmp/idx-test", false);
Analyzer analyzer = new SimpleAnalyzer();
Searcher searcher = new IndexSearcher(directory);
Hits hits = null;
String[] fields = { "contents", "title" };
MultiFieldQueryParser parser = new MultiFieldQueryParser("britney
spears", analyzer);
Query query = parser.parse("britney spears", fields);
System.out.println("Query: " + query.toString());
hits =;
System.out.println ("Results: " + hits.length());
best regards
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

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

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdev @
postedMar 21, '06 at 10:46p
activeMar 21, '06 at 10:46p

1 user in discussion

Daniel Naber (JIRA): 1 post



site design / logo © 2021 Grokbase