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 4354B7D2F for ; Wed, 9 Nov 2011 10:30:01 +0000 (UTC) Received: (qmail 32945 invoked by uid 500); 9 Nov 2011 10:29:59 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 32889 invoked by uid 500); 9 Nov 2011 10:29:58 -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 32877 invoked by uid 99); 9 Nov 2011 10:29:58 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Nov 2011 10:29:58 +0000 X-ASF-Spam-Status: No, hits=1.8 required=5.0 tests=FREEMAIL_FROM,HTML_FONT_FACE_BAD,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of felipe.carvalho@gmail.com designates 209.85.213.48 as permitted sender) Received: from [209.85.213.48] (HELO mail-yw0-f48.google.com) (209.85.213.48) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Nov 2011 10:29:53 +0000 Received: by ywm14 with SMTP id 14so2472172ywm.35 for ; Wed, 09 Nov 2011 02:29:32 -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=IBs73rpXI+/k8zHr70zxKWwRsSzUmV23y4xqptaE474=; b=E8MZVLgP77j2JTc1wFF75ca/S0VoAkNN1RAVOsKj18iEdomLbQ/wWUpTr0GsDarNIG S4UIzvyXSHzjy8xdZvfpohacXq+/P1t98FOOOSMkfTOKEIU3FiPmhjBeGConF576IiUN qbfbwCt0oAghQsz6B4xCRFBhLVKE6f1+dODHA= Received: by 10.182.12.72 with SMTP id w8mr355843obb.13.1320834572169; Wed, 09 Nov 2011 02:29:32 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.39.3 with HTTP; Wed, 9 Nov 2011 02:29:11 -0800 (PST) In-Reply-To: <20F12225-21C9-479D-839B-A8D5D0F4BD9F@gmail.com> References: <4A5A76AB-AA58-4A5B-9DF3-4EB76C7232F0@hoplahup.net> <20F12225-21C9-479D-839B-A8D5D0F4BD9F@gmail.com> From: Felipe Carvalho Date: Wed, 9 Nov 2011 08:29:11 -0200 Message-ID: Subject: Re: Phonetic search with Lucene 3.2 To: java-user@lucene.apache.org Content-Type: multipart/alternative; boundary=f46d0444690b7b30ae04b14ac34c --f46d0444690b7b30ae04b14ac34c Content-Type: text/plain; charset=ISO-8859-1 Using PerFieldAnalyzerWrapper seems to be working for what I need! On indexing: PerFieldAnalyzerWrapper wrapper = new PerFieldAnalyzerWrapper(new StandardAnalyzer(Version.LUCENE_33)); wrapper.addAnalyzer("nome", new MetaphoneReplacementAnalyzer()); IndexWriterConfig indexWriterConfig = new IndexWriterConfig(Version.LUCENE_33, wrapper); Directory directory = FSDirectory.open(new File(indexPath)); IndexWriter indexWriter = new IndexWriter(directory, indexWriterConfig); On search: Directory directory = FSDirectory.open(new File(lastIndexDir(Calendar.getInstance()))); IndexSearcher is = new IndexSearcher(directory); PerFieldAnalyzerWrapper wrapper = new PerFieldAnalyzerWrapper(new StandardAnalyzer(Version.LUCENE_33)); wrapper.addAnalyzer("name", new MetaphoneReplacementAnalyzer()); QueryParser parser = new QueryParser(Version.LUCENE_33, "name", wrapper); Query query = parser.parse(expression); ScoreDoc[] hits = is.search(query, 1000).scoreDocs; Does anyone know any other phonetic analyzer implementation? I'm using MetaphoneReplacementAnalyzer from LIA examples. I'm looking at lucene-contrib stuff at http://lucene.apache.org/java/3_4_0/lucene-contrib/index.html but I can't seem to find other phonetic analyzers. Thanks! On Tue, Nov 8, 2011 at 12:19 PM, Erik Hatcher wrote: > > On Nov 8, 2011, at 05:42 , Felipe Carvalho wrote: > >> Yes, quite possible, including boosting on exact matches if you want. > Use > >> a BooleanQuery to wrap clauses parsed once with phonetic analysis, and > once > >> without, including fields at indexing time for both too of course. > >> > > > > Would it be possible to point to an example where this is done. The best > > example of a BooleanQuery I've found so far is this one: > > > http://www.avajava.com/tutorials/lessons/how-do-i-combine-queries-with-a-boolean-query.html > > > > But I couldn't find a boolean query using different analyzers for > different > > fields of the attribute. > > You could use two different QueryParser instances with different > analyzers. Or use the PerFieldAnalyzerWrapper, though you'll still need to > instances in order to have a different default field for each expression. > But then use the techniques you saw in that article (or in Lucene in > Action, since you mentioned having that) to combine Query objects into a > BooleanQuery. > > Erik > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > > --f46d0444690b7b30ae04b14ac34c--