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