Return-Path: X-Original-To: apmail-lucene-java-user-archive@www.apache.org Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9D378100A2 for ; Sun, 18 Jan 2015 00:05:39 +0000 (UTC) Received: (qmail 34478 invoked by uid 500); 18 Jan 2015 00:05:39 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 34406 invoked by uid 500); 18 Jan 2015 00:05:39 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 34394 invoked by uid 99); 18 Jan 2015 00:05:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Jan 2015 00:05:38 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of erickerickson@gmail.com designates 209.85.220.174 as permitted sender) Received: from [209.85.220.174] (HELO mail-vc0-f174.google.com) (209.85.220.174) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Jan 2015 00:05:13 +0000 Received: by mail-vc0-f174.google.com with SMTP id id10so8495334vcb.5 for ; Sat, 17 Jan 2015 16:04:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=160as1Yn7GW4GZwQreKUG8utTz0m1yO+hsrpsRd6IAk=; b=eMzEHos9mCRmV8xCopj1zWQUh0cC3nhxXZHN5r0tunah9V3cvt7/XBO0aQqMp/MYvi xIdrCsPNh8LEz5PrcW/E31HfOLdNNCrAia/2nuDwFWNk0EWozhkjN45Ymm1T+wRi6AYq sJm/kSA/wpKf+tBvFPK0lXlzmulEgl9LEdraBhe7GFUNQVwBDDfrlaHt0gr+40hvn7gu NR6eSBFWnfo9efmPbfzTK7jZWimO4W5Om1xQsviomxamT1Ns4UtIstQwMuFBHW1fQlQA rmi2VZp1riFGi5xqFTxmSgM0qOoaVSphApxdpekJA2D6wb2P7urkT/PI3KBpP3zurTFb Iyvw== MIME-Version: 1.0 X-Received: by 10.220.196.66 with SMTP id ef2mr11429200vcb.5.1421539467080; Sat, 17 Jan 2015 16:04:27 -0800 (PST) Received: by 10.52.96.5 with HTTP; Sat, 17 Jan 2015 16:04:27 -0800 (PST) In-Reply-To: References: Date: Sat, 17 Jan 2015 16:04:27 -0800 Message-ID: Subject: Re: Help with a fieldcomparator! From: Erick Erickson To: java-user Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org 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 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 que= ry > filter > For that reason I think the best way is a custom FieldComparator. > > Thanks > V=C3=ADctor Podberezski > > On Fri, Jan 16, 2015 at 9:31 PM, Erick Erickson > 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 >> 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 luce= ne >> > 3.9 or higher (migration from ScoreDocComparator to fieldComparator). >> > >> > I try this: >> > >> > public void setNextReader(IndexReader reader, int docBase) throws >> > IOException { >> > >> > currentReaderValues =3D 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=C3=ADctor Podberezski >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org >> For additional commands, e-mail: java-user-help@lucene.apache.org >> >> --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org