lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Victor Podberezski <vpodberez...@cms-medios.com>
Subject Help with a fieldcomparator!
Date Sat, 17 Jan 2015 00:00:10 GMT
I need a hand with a custom comparator.

I have a field filled with words separated by spaces. Some words has
numbers inside.

 I need to extract those numbers and sort the documents by this number. I
need to get the lower if there are more than 1 number .

For example:

doc1 "val2 aaaa val3" --> 2, 3 --> 2
doc2 "val5 aaaa val1" --> 5, 1 --> 1
doc3 "val7 bbbbb val5" --> 7, 5 ---> 5

the sorted results have to be:

doc2
doc1
doc3

how can I achieve this?

I have trouble migrating a functional solution from lucene 2.4 to lucene
3.9 or higher (migration from ScoreDocComparator to fieldComparator).

I try this:

    public void setNextReader(IndexReader reader, int docBase) throws
IOException {

      currentReaderValues = FieldCache.DEFAULT.getInts(reader, field, new
FieldCache.IntParser() {
      public final int parseInt(final String val) {
     return extractNumber(val);
      }
});

and the rest equal to the IntComparator.
but this is not working

Anybody has an idea of how resolve this problem?
Thanks,

VĂ­ctor Podberezski

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message