On Jun 22, 2005, at 1:24 PM, George Abraham wrote:
Otis,
I think MultiFieldQueryParser (if I am not mistaken) uses the same
query string to search multiple fields. Let me know if it is
otherwise.
Erik,
Let me see if I can answer those questions. Here are some code
snippets, by the way.
FOR INDEX
IndexWriter writer = new IndexWriter(indexDir, new StopAnalyzer(),
true);
while (rs.next()){ //rs is a database resultset I am looping over
Document doc = new Document();
doc.add(Field.Keyword("ObjectID", ObjectID));
doc.add(Field.Keyword("ImageExistsBit",
ImageExistsBit));//ImageExistsBit is 1 or 0
doc.add(Field.Text("SearchTerms", SearchTerms));
writer.addDocument(doc);
writer.optimize();
writer.close();
}
FOR SEARCH
searcher = new IndexSearcher(IndexReader.open(indexPath) );
Analyzer analyzer = new StopAnalyzer();
luceneQuery = QueryParser.parse(queryString, "SearchTerms", analyzer);
hits = searcher.search(luceneQuery);
System.out.println("Found " + hits.length() + " document(s).");
What I want: I want all the ObjectIDs that have the term 'visnu
temple' in the SearchTerms field and has ImageExistsBit=1. So the
queryString above is: SearchTerms:\"visnu temple\" ImageExistsBit:1".
The .toString() for this query is SearchTerms:"visnu temple"
Your analyzer is eating the ImageExistsBit:1 because "1" returns no
tokens through StopAnalyzer. Here's a solution, adapted from the
code that powers lucenebook.com. Use this as your analyzer:
PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper
(new StopAnalyzer());
analyzer.addAnalyzer("ImageExistsBit", new WhitespaceAnalyzer());
That should do the trick.
Erik
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]