lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <...@thetaphi.de>
Subject RE: How to use 'PhraseQuery' with Fuzzy?!
Date Tue, 23 Sep 2014 10:32:52 GMT
Hi,

You should use a SpanQuery for this use-case. SpanQueries are a generalization of PhraseQuery.
You can include a FuzzyQuery using a MTQ wrapper query into a span:
SpanNearQuery is the "phrase", consisting of several "SpanMultiTermQueryWrapper(FuzzyQuery)"
nodes.

Be aware, that SpanQueries are expensive and may take a lot of time! 

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de


> -----Original Message-----
> From: teko [mailto:tecozc@gmail.com]
> Sent: Monday, September 22, 2014 8:45 PM
> To: java-user@lucene.apache.org
> Subject: How to use 'PhraseQuery' with Fuzzy?!
> 
> Hello,
> 
> Well, I need do a query to locate Phrases like that:
> Petruz Augusto
> Petruz Auguzto
> Petrs Augusto
> ...
> 
> Well, in a single word, I can use fuzzy, but, how I can use it in phrases?
> I think that I need use PhraseQuery, but, I never get any result.. (code
> below). Thanks
> 
> [code]
> IndexReader reader = DirectoryReader.open(dir); IndexSearcher searcher =
> new IndexSearcher(reader);
> 
> Term term1 = new Term("contents", string1); Term term2 = new
> Term("contents", string2); PhraseQuery phraseQuery = new PhraseQuery();
> phraseQuery.add(term1); phraseQuery.add(term2);
> phraseQuery.setSlop(50);
> 
> final TopDocs results = searcher.search(phraseQuery, Integer.MAX_VALUE);
> System.out.println(results.totalHits);
> [/code]
> 
> 
> 
> --
> View this message in context: http://lucene.472066.n3.nabble.com/How-to-
> use-PhraseQuery-with-Fuzzy-tp4160519.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> 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