开发者

Lucene.NET MultiSearcher

My sample code is:

            Searchable[] remoteSearch = new Searchable[sindexes.Length];
            for (int i = 0; i < sindexes.Length; i++)
            {
                if(sindexes[i].Trim().Length>0)
                    remoteSearch[i] = new IndexSearcher(sindexes[i]);
            }
            searcherPM = new ParallelMultiSearcher(remoteSearch);
            QueryParser qp = new QueryParser("text", new
            Lucene.Net.Analysis.Standard.StandardAnalyzer());
            Query query = qp.Parse(InputText);

            hits = searcherPM.Search(query);

Her开发者_JAVA百科e I use hits = searcherPM.Search(query);

but as recommended I need to use this call

            TopDocs result = searcherPM.Search(query, null, nTo);

Who can say me how to retrieve Document from the result TopDocs when I use ParallelMultiSearch?

Thanx.


I assume there should not be difference between parallel multisearcher and the normal one. Should be like bellow I think:

for (int i = 0; i < results.totalHits; i++)
{
   var doc = searcherPM.Doc(results.scoreDocs[i].doc);
}

The best result is the first one in the results. In the snippet I fould this doc was after checked if it is not null. However I don't know why and unfortunately I cannot mention the source.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜