luwak icon indicating copy to clipboard operation
luwak copied to clipboard

error=uk.co.flax.luwak.util.RewriteException

Open nik9839 opened this issue 7 years ago • 1 comments

I have added a query- "plans to eat" in the monitor with id "query1-plans to eat", and my document has a substring plans to eat. While iterating over the matches, this query gets matched but is unable to give the hit. During debugging i get this

"Match(doc=doc-1,query=query1-plans to eat){error=uk.co.flax.luwak.util.RewriteException: Don't know how to rewrite PhraseQuery with holes or overlaps (position must increase by 1 each time but found term document:plans at position 0 followed by term document:eat at position 2)} "

I guess this problem is because of stop words.

The code i used is like this

for (HighlightsMatch docMatch : docMatches) { Set<Hit> hits = docMatch.getHits().get("document"); List<String> phrasesMatched = new ArrayList<String>(); String phrase = ""; int oldPosition = 0; int newOffset = 0; System.out.println("hit count for "+docMatch.getQueryId().split("---")[1]+" "+docMatch.getHitCount()); if(hits != null) {
.....some code } signalPhraseMap.put(docMatch.getQueryId(), phrasesMatched); }

when the docMatch gets to "plans to eat" it is unable to give the hit.

nik9839 avatar Jun 14 '17 11:06 nik9839

SpanNearQuery actually has the ability to add defined gaps now, so it should be possible to handle stop words correctly. Do you want to work on a PR?

romseygeek avatar Jun 14 '17 19:06 romseygeek