lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From George Abraham <george.abraham.li...@gmail.com>
Subject Re: querying multiple fields
Date Wed, 22 Jun 2005 17:24:01 GMT
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"

Thanks,
George



On 6/22/05, Otis Gospodnetic <otis_gospodnetic@yahoo.com> wrote:
> George,
> 
> You can use MultiFieldQueryParser instead of QueryParser.
> 
> Otis
> 
> 
> --- George Abraham <george.abraham.lists@gmail.com> wrote:
> 
> > All,
> > Forgive me for the basic question. When you are querying multiple
> > fields using QueryParser, what is the exact code?
> >
> > I tried QueryParser.parse(queryString, "SearchTerms", analyzer) where
> > queryString was "SearchTerms:visnu temple ImageExistsBit:1",
> > SearchTerms and ImageExistsBit being the two fields I want searched.
> > However it does not seem to do what I want it to do.
> >
> > TIA,
> > George
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message