Ah, OK. H.L. Mencken wrote something like: "For every complex problem there is a solution that is simple, elegant, and wrong". I specialize in these...
I don't have a good answer for your question then. How is what you're trying failing? Best, Erick On Fri, Jan 16, 2015 at 4:59 PM, Victor Podberezski <vpodberez...@cms-medios.com> wrote: > Erik, Thanks for your reply. > > I wrote a simplification of the problem. Not only the values in the field > that can be sorted are "val1, val2,..." . they can also be "patternX1, > patternX2", etc. > > and in that case I need to sort according to different criteria. They're a > lot of differents patterns but not to much documents as result of the query > filter > For that reason I think the best way is a custom FieldComparator. > > Thanks > Víctor Podberezski > > On Fri, Jan 16, 2015 at 9:31 PM, Erick Erickson <erickerick...@gmail.com> > wrote: > >> Personally I would do this on the ingestion side with a new field. >> That is, analyze the input field when you were indexing the doc, >> extract the min value from any numbers, and put that in a >> new field. Then it's simply sorting by the new field. This is likely >> to be much more performant than reprocessing this at query >> time in a comparator. >> >> FWIW, >> Erick >> >> On Fri, Jan 16, 2015 at 4:00 PM, Victor Podberezski >> <vpodberez...@cms-medios.com> wrote: >> > 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 >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org >> For additional commands, e-mail: java-user-h...@lucene.apache.org >> >> --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org