cnd
cnd

Reputation: 33744

Search is obsolete?

Hits hits = searcher.Search(query);

Warning 1 'Lucene.Net.Search.Hits' is obsolete: 'see Searcher.Search(Query, int), Searcher.Search(Query, Filter, int) and Searcher.Search(Query, Filter, int, Sort)' \Archives.cs 65

So how will I search? with TopDocs?

if so then

TopDocs hits = searcher.Search(query, 10);

How will I know how many nodes it has found? And how to get a single?

Upvotes: 0

Views: 570

Answers (1)

L.B
L.B

Reputation: 116108

1- Hits is deprecated since it silently makes background searches in every 100 results read , to be able to make document caching. Therefore it is inefficient in speed.

2- TopDocs has TotalHits field

3- indexReader.Document(td.ScoreDocs[i].Doc)

Upvotes: 2

Related Questions