I already found another solution: I don't use a custom SortComparator.
Another solution would be to define a default value for null.
Would be nice if lucene in future would be able
to search by null values also if a custom SortComparator is used.
To tell you more:
public class MyComparator ext
That's not true: have a look at the "else"-block.
The problem is that lucene's FieldDocSortedHitQueue does only test for null
values if uses the type FieldDoc.STRING. With FieldDoc.CUSTOM lucene assumes
ci to be never null:
FieldDocSortedHitQueue 163-166:
case SortField.CUSTOM:{
Hello,
I am using a custom SortComparator implementation where I need to override a
method in order to handle Null values:
@Override
public ScoreDocComparator newComparator (final IndexReader reader,
final
String fieldname)
throws IOException {
final Strin
By the way: if you only need to count documents (count groups) HitCollector
is a good choice. If you only count you don't need to sort anything.
ninaS wrote:
>
> Hello,
>
> yes I tried HitCollector but I am not satisfied with it because you can
> not use sorting with Hit
Hello,
yes I tried HitCollector but I am not satisfied with it because you can not
use sorting with HitCollector unless you implement a way to use
TopFieldTocCollector. I did not manage to do that in a performant way.
It is easier to first do a normal search und "group by" afterwards:
Iterate
Hey Marcus,
have you already implemented this feature?
I'm searching a group by function for lucene, too.
More precisely I need it in Compass, which is built on top of lucene.
I was thinking about using a HitCollector to get only one result per group.
How did you do it?
Cheers,
Nina
Marcus