paul:
I visited the site you provide and explore the example,but i can not
understand the results from the following example.I thought
the phonetix is an tel-no analyzer like 010-134323434,400-2343-2342-3234,could
you tell me some more info about this,i need to index phone number in my
project.thanks.
public class PhoneticTest
{
public static void main(String[] argv)
{
Metaphone metaphone = new Metaphone();
String original = "Phonetix";
String encoded = metaphone.generateKey(original);
System.out.println("original="+original+", encoded="+encoded);
}
}
After compiling and running this example program you will get an output like
this:
original=Phonetix, encoded=FNTK
2011-11-10
janwen | China
website : http://www.qianpin.com/
发件人: Paul Libbrecht <[email protected]>
发送时间: 2011-11-09 18:38
主 题: Re: Phonetic search with Lucene 3.2
收件人: [email protected]
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 <[email protected]>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: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]