lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: A query in multipleFields
Date Thu, 30 Jun 2005 12:35:12 GMT
On Jun 30, 2005, at 7:41 AM, Daniel Cortes wrote:
> I have 2 indexs and the structure of the elements in this index are  
> equals what in one index I have a field.Keyword "type" with value  
> "forum" and  the other index with a value "blog".
> How have I do to search in two indexs at same time?

Use MultiSearcher.  Instantiate IndexReader's for each index, and  
then construct a MultiSearcher using those two readers.  This is  
exactly how lucenebook.com works - one index for blog content, one  
for book content.

> How can I restrict the results with only "forum" or "blog" type?

Two options :

     1) Only use an IndexSearcher to the index you want to query if  
you are isolating it to only one type.
     2) Tack on a TermQuery for field "type" to the query (wrap the  
original query with BooleanQuery and add a required TermQuery clause  
for the type).

Personally I'd opt for #1 just to keep things simpler.

> For exeample:
> * I want search dog blue in forums and blogs

MultiSearcher across both indexes.

> * I want search dog blue only in forums

See above.

     Erik


---------------------------------------------------------------------
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