Experience shows otherwise.
- Neal
-----Original Message-----
From: Nicholas Paldino [.NET/C# MVP] [mailto:[email protected]]
Sent: Thursday, January 14, 2010 2:24 PM
To: [email protected]
Subject: RE: at least one doc
DIGY,
In .NET it's more than small. Throwing and catching an exception
(which is required here) is orders of magnitude slower than just returning a
value. It has to do with the stack unwind and restoration, and I'm sure
it's similar in Java.
- Nick
-----Original Message-----
From: Digy [mailto:[email protected]]
Sent: Thursday, January 14, 2010 2:44 PM
To: [email protected]
Subject: RE: at least one doc
I also have thought many times why HitCollector.Collect doesn't return a
boolean value indicating no more results are needed.
Maybe, a small performance increment.
DIGY
-----Original Message-----
From: Nicholas Paldino [.NET/C# MVP] [mailto:[email protected]]
Sent: Thursday, January 14, 2010 8:09 PM
To: [email protected]
Subject: RE: at least one doc
Wow, that's just... Horrible from a design perspective. Doesn't
matter which language it's implemented in.
- Nick
-----Original Message-----
From: Digy [mailto:[email protected]]
Sent: Thursday, January 14, 2010 12:22 PM
To: [email protected]
Subject: RE: at least one doc
The formal way is throwing exception in the HitCollector.Collect to stop
iteration.
DIGY
-----Original Message-----
From: Artem Chereisky [mailto:[email protected]]
Sent: Thursday, January 14, 2010 1:16 AM
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