Can phrasequery allow mismatch?
Hi, I want to implement a query like phrase query with slop 0, but I can allow one term mismatch. For example, the text is "A B C D E" I want to match this text with the query "A B C X E". X mismatches the D. i.e. Query "A B C D E" will match “W1 W2 W3 W4 W5”, the 5 words are consecutive and at most one word is mismatched.
Re: Can phrasequery allow mismatch?
Might be able to do it with some combination of SpanNearQuery, with suitable values for slop and inOrder, combined into a BooleanQuery with setMinimumNumberShouldMatch = number of SpanNearQuery instances - 1. So, making this up as I go along, you'd have SpanNearQuery sn1 = B after A, slop 0, in order SpanNearQuery sn2 = C after B, slop 0, in order SpanNearQuery sn3 = D after C, slop 0, in order SpanNearQuery sn4 = E after D, slop 0, in order BooleanQuery bq = whatever(sn1, sn2, sn3, sn4) bq.setMinimumNumberShouldMatch(3) Might work. The value 3 should perhaps be 2. Or a larger value of slop might help to match C X E rather than C D E. In that case minshouldmatch would be 4, I think, I'm getting confused so will stop. -- Ian. On Thu, Jul 17, 2014 at 8:22 AM, Yonghui Zhao wrote: > Hi, > > I want to implement a query like phrase query with slop 0, but I can allow > one term mismatch. > > For example, the text is "A B C D E" > > I want to match this text with the query "A B C X E". > > X mismatches the D. > > i.e. Query "A B C D E" will match “W1 W2 W3 W4 W5”, the 5 words are > consecutive and at most one word is mismatched. - To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org
Re: Can phrasequery allow mismatch?
I think you could express this with TermAutomatonQuery (https://issues.apache.org/jira/browse/LUCENE-5815 ) but it's likely very slow to run... Mike McCandless http://blog.mikemccandless.com On Thu, Jul 17, 2014 at 3:22 AM, Yonghui Zhao wrote: > Hi, > > I want to implement a query like phrase query with slop 0, but I can allow > one term mismatch. > > For example, the text is "A B C D E" > > I want to match this text with the query "A B C X E". > > X mismatches the D. > > i.e. Query "A B C D E" will match “W1 W2 W3 W4 W5”, the 5 words are > consecutive and at most one word is mismatched. - To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org
Lucene Query Wrong Result for phrase.
Hi I have created index with 1 field with simple message like (hello - world) now when I create for search like +body:" \"hello world\"" & I should not get any result because I have wrapped my search word in double quotes and does not specify dash(-) between (hello and world) but I am still getting that result.I am using Lucene version 3.0 & using snowball analyzer, also use Cosntruct query likeString qry="+body:\"hello world\"";Query query = new QueryParser(Version.LUCENE_30, "body", analyzer).parse(qry);Why lucene is ignoring dash(-) while search is a phrase. -- View this message in context: http://lucene.472066.n3.nabble.com/Lucene-Query-Wrong-Result-for-phrase-tp4147842.html Sent from the Lucene - Java Users mailing list archive at Nabble.com.