lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ankur Goel" <>
Subject Boolean Phrase Query question
Date Sat, 03 Apr 2004 17:13:58 GMT

I have to provide a functionality which provides search on both file name
and contents of the file.

For indexing I use the following code:

org.apache.lucene.document.Document doc = new org.apache.
doc.add(Field.Keyword("fileId","" + document.getFileId()));
doc.add(Field.Text("contents", new FileReader(new File(fileName)));

For searching a text say  "temp" I use the following code to look both in
file Name and contents of the file:

BooleanQuery finalQuery = new BooleanQuery();
Query titleQuery = QueryParser.parse("temp","fileName",analyzer);
Query mainQuery = QueryParser.parse("temp","contents",analyzer);

finalQuery.add(titleQuery, true, false);
finalQuery.add(mainQuery, true, false);

Hits hits =;

But I am not getting any result. I think the problem is due to searching on
two fields.
Can you please tell me how to go about it.


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

View raw message