Solr has, for a long while, included a PhoneticFilter that can leverage several different algorithms. This was pulled down to Lucene, but only for trunk/4.0.
Maybe use Solr instead?! ;) Erik On Nov 9, 2011, at 02:29 , Felipe Carvalho wrote: > 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.hatc...@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-unsubscr...@lucene.apache.org >> For additional commands, e-mail: java-user-h...@lucene.apache.org >> >> --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org