lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Libbrecht <p...@hoplahup.net>
Subject Re: Phonetic search with Lucene 3.2
Date Wed, 09 Nov 2011 13:20:58 GMT
That uses Lucene 2.9.2 indeed.

paul


Le 9 nov. 2011 à 11:43, Felipe Carvalho a écrit :

> Which version of Lucene are you using? I had tried it with Lucene 3.3 and
> had some problems, did you have to do any customizations?
> 
> On Wed, Nov 9, 2011 at 8:38 AM, Paul Libbrecht <paul@hoplahup.net> wrote:
> 
>> We've been using
>>       http://www.tangentum.biz/en/products/phonetix/
>> which does double-metaphone.
>> Maybe that helps.
>> 
>> paul
>> 
>> 
>> Le 9 nov. 2011 à 11:29, Felipe Carvalho a écrit :
>> 
>>> 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 <erik.hatcher@gmail.com
>>> 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
>>>> 
>>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> 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


Mime
View raw message