Home | About | Sematext search-lucene.com search-hadoop.com
 Search Lucene and all its subprojects:

Switch to Plain View
Lucene.Net, mail # user - at least one doc


+
Artem Chereisky 2010-01-13, 23:16
+
Andrew C. Smith 2010-01-14, 01:09
+
Digy 2010-01-14, 17:21
+
Nicholas Paldino [.NET/C#... 2010-01-14, 18:09
+
Digy 2010-01-14, 19:44
+
Nicholas Paldino [.NET/C#... 2010-01-14, 20:24
+
Granroth, Neal V. 2010-01-14, 20:37
+
Nicholas Paldino [.NET/C#... 2010-01-14, 21:35
+
Digy 2010-01-14, 22:16
+
Nicholas Paldino [.NET/C#... 2010-01-14, 23:10
+
Franklin Simmons 2010-01-14, 23:32
+
Michael Garski 2010-01-15, 00:03
+
Ben Martz 2010-01-14, 23:54
+
Michael Garski 2010-01-14, 23:56
+
Ben Martz 2010-01-15, 00:54
+
Ciaran Roarty 2010-01-14, 21:16
+
Todd Carrico 2010-01-14, 21:18
+
Nicholas Paldino [.NET/C#... 2010-01-14, 18:10
Copy link to this message
-
RE: at least one doc
Franklin Simmons 2010-01-14, 19:02
HitCollector is the wrong tool to use because you're clearly not interested in collecting hits. Try the Scorer class.  For example

Lucene.Net.Search.Weight weight = query.Weight(searcher);
Lucene.Net.Search.Scorer scorer = weight.Scorer(searcher.GetIndexReader());
bool hasHits = scorer.Next();
-----Original Message-----
From: Artem Chereisky [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 13, 2010 6:16 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: at least one doc

Hi,

Given a boolean query and/or a filter, what is the best way to see if there
is at least one matching document?

I tried a simple hit collector which sets a flag on the first Collect
method. Ideally I would want to stop collecting at that point but I couldn't
find a way of doing that.
I also tried: TopDocs docs = _searcher.Search(query, filter, 1), but it
seems to iterate through all matches as docs.totalHits is set the the actual
number of matches.

So, is there a better way

Regards,
Art
+
Todd Carrico 2010-01-14, 17:23