lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bib_lucene bib <>
Subject Query -- how to write
Date Sun, 10 Jul 2005 04:40:35 GMT
Hi All
I am indexing a document like this...
Document doc = new Document();
  doc.add(Field.Text("contents", new FileReader(f)));
  Iterator it = fields.keySet().iterator();
  String element = "";
     while (it.hasNext()) {
        element =  (String);
        doc.add(Field.Text(element,(String)fields.get(element)));  // also tried field.keyword
So the lucene doc has the text of the uploaded doc and also some params like author, date,
When I write my search 

String queryStr = request.getParameter("query");

File indexDir = new File("c:/luceneindex");

Directory fsDir = FSDirectory.getDirectory(indexDir,false);

IndexSearcher is = new IndexSearcher(fsDir);

Query query = QueryParser.parse(queryStr,"contents", new StandardAnalyzer());

Hits hits =;

Not surprisingly I get a match only if there is a word in the contents of the document.

Question: If my query should be able to search not only document contents but also the other
data added such as author how do I do that.

Please let me know.

Also if I can get a pointer this type of info I will really appreciate it.



Yahoo! Mail
 Stay connected, organized, and protected. Take the tour
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message