lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vladimir Yuryev" <vyur...@rambler.ru>
Subject Re: MultiSearcher to Indexing.
Date Fri, 13 Aug 2004 04:45:01 GMT
Natarajan,

MultiSeacher - it is well, but this a way have pickles.

Example, but it is not sample:

public Query combine(Query[] queries) throws IOException { 
     if (expandedQueries.length < 2) {
         return queries[0];
     }
     Query[] combined = new Query[2];
     combined[0] = new BooleanQuery();
     BooleanQuery.setMaxClauseCount(10000);
     for (int i = 0; i < queries.length; i++) {
         combined[1] = queries[i];
         if (queries[i] instanceof BooleanQuery ||
	queries[i] instanceof MultiTermQuery ||
	queries[i] instanceof PrefixQuery ||
	queries[i] instanceof RangeQuery) {
	combined[0] = Query.mergeBooleanQueries(combined);
         } else if (queries[i] instanceof PhraseQuery) {
             Term[] queryTerms = ((PhraseQuery)queries[i]).getTerms();
             for (int j = 0; j < queryTerms.length; j++) {
                 TermQuery q = new TermQuery(queryTerms[j]);
                 ((BooleanQuery)combined[0]).add(q, true, false);
             }
         } else ((BooleanQuery)combined[0]).add(queries[i], true, 
false);
     }
     return combined[0];
} 

...
     Searcher[] searchers = new IndexSearcher[indexName.length];
     for(int i=0;i<indexName.length;i++) {
         searchers[i] = new IndexSearcher(indexName[i]);
     }
     MultiSearcher multiSearcher=new MultiSearcher(searchers);
     QueryParser qp = new QueryParser(FIELD_CONTENTS, analyzer);
     query = QueryParser.parse(queryString, FIELD_CONTENTS, analyzer);
     hits = multiSearcher.search(query);
     IndexReader reader[] = new IndexReader[indexName.length];
     Query[] expandedQueries=new Query[indexName.length];
     for(int i=0;i<indexName.length;i++){
         reader[i] = IndexReader.open(indexName[i]);
         expandedQueries[i]=query.rewrite(reader[i]);
     }
     query=combine(expandedQueries);
...

Best regards,
Vladimir.





On Thu, 12 Aug 2004 20:51:13 +0530
  "Natarajan.T" <natarajant@crimsonlogic.co.in> wrote:
>Thanks for your response.
>Ok I can understand the concept ..... if you have any sample code pls
>sent it to me.
>
>You have any idea about Parallel Searcher pls share to me.
>
>-----Original Message-----
>From: Terence Lai [mailto:tlai@trekspace.com] 
>Sent: Thursday, August 12, 2004 8:40 PM
>To: Lucene Users List
>Subject: RE: MultiSearcher to Indexing.
>
>This is how I do it:
>
>IndexSearcher[] is = new IndexSearcher[2];
>
>is[0] = new IndexSearcher(IndexDir1); // first index folder
>is[1] = new IndexSearcher(IndexDir2); // second index folder
>
>MultiSearcher searcher = new MultiSearcher(is);
>
>searcher.search(query);
>
>I think that the MulitSearcher is only doing sequential search.
>Alternately, you can use ParallelMultiSearcher which allows you to do
>the search in parallel.
>
>Hope this helps,
>Terence
>
>
>
>> FYI
>>  
>> I have an Indexing files in different folders, in this time how can 
>>I
>> doing  the Searching process using MultiSearcher.
>>  
>> Thanks,
>> Natarajan.
>>  
>>  
>>  
>>  
>>  
>> 
>
>
>
>
>----------------------------------------------------------
>Get your free email account from http://www.trekspace.com
>          Your Internet Virtual Desktop!
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>


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


Mime
View raw message