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 7C29379B0 for ; Wed, 23 Nov 2011 10:03:46 +0000 (UTC) Received: (qmail 39992 invoked by uid 500); 23 Nov 2011 10:03:44 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 39799 invoked by uid 500); 23 Nov 2011 10:03:44 -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 39791 invoked by uid 99); 23 Nov 2011 10:03:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Nov 2011 10:03:43 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ian.lea@gmail.com designates 209.85.210.176 as permitted sender) Received: from [209.85.210.176] (HELO mail-iy0-f176.google.com) (209.85.210.176) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Nov 2011 10:03:38 +0000 Received: by iaqq3 with SMTP id q3so848334iaq.35 for ; Wed, 23 Nov 2011 02:03:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=faBb4owMfjPiRs8ucHvQpKsLW+YWDXtzdkxhVRNdovI=; b=Jg4Zy6sLz5LaJkcGZZxEqu3v+oF7gE1VatqYwE4MCxfEGE9PwLNNq4uxSuu0DtV+bV twqAWMVydxb5vHmFPsdCUYqEjcDo4zdOQKnwMd/TKXZwkfEPmbPUNyQqWn2xA7QEwmse 32qh1kinrBfe5Nt5v7kBarma7ywa/GHcPkauw= Received: by 10.42.162.130 with SMTP id y2mr930113icx.26.1322042598083; Wed, 23 Nov 2011 02:03:18 -0800 (PST) MIME-Version: 1.0 Received: by 10.231.171.72 with HTTP; Wed, 23 Nov 2011 02:02:57 -0800 (PST) In-Reply-To: References: From: Ian Lea Date: Wed, 23 Nov 2011 10:02:57 +0000 Message-ID: Subject: Re: Fuzzy Search Sorting To: java-user@lucene.apache.org Content-Type: text/plain; charset=ISO-8859-1 You'll have to delve in to the output from IndexSearcher.explain, or the details of the Levenshtein (edit distance) algorithm used by FuzzyQuery to figure out why Smath is beating Smith. But the general way of making sure that exact matches come top is to add an exact match clause to your query, FamilyName:smith^16 GivenName:smith^4 FamilyName:smith~^8 GivenName:smith~^2 You'll want to play with the boosts. Also be aware that in lucene 3.x, Fuzzy queries can be slow. -- Ian. On Tue, Nov 22, 2011 at 10:21 PM, Romiko Derbynew wrote: > Hi Guys, > > I am using Lucene with neo4j database. > > Currently if I do a fuzzy search via a rest call using the Query API with this data > > GivenName: John > FamilyName: Smith > > GivenName: Bob > FamilyName: Smith > > > GivenName: Adam > FamilyName: Smith > > GivenName: Bill > FamilyName: Smath > > If I query the index like this +(FamilyName:smith~) > > The query results shows Smath on the top > e.g. > Smath, Bill > Smith, Adam > Smith, Bob > Smith, John > > I thought lucene would automatically sort the fuzzy search result with most relevant on the top, why in this case is Smath on the top, it should be on the bottom, no? > > Also, if I have two index keys (FamilyName, GivenName), and I search like this: > +(FamilyName:smith~^8 GivenName:smith~^2) > > And I have this data set > GivenName: John > FamilyName: Smith > > GivenName: Bob > FamilyName: Smith > > GivenName: Adam > FamilyName: Smith > > GivenName: Bill > FamilyName: Smath > > GivenName: Smith > FamilyName: Harry > > GivenName: Smath > FamilyName: Sally > > I would want the result to first sort by Highest match and then by booster priority > Adam Smith > Bob Smith > John Smith > Smith Harry > Bill Smath > Smath Sally > > How, can I achieve this with the Query Parser (http://lucene.apache.org/java/3_1_0/queryparsersyntax.html) > > Much Appreciated. > Romiko > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org