New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for highlighting multi term queries using the postings highlighter #4052
Conversation
private static final IndexReader EMPTY_INDEXREADER = new MultiReader(); | ||
private static Query rewrite(Query original, IndexReader reader) throws IOException { | ||
if (original instanceof MultiTermQuery) { | ||
MultiTermQuery copy = (MultiTermQuery) original.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to clone the query you can just get the current rewrite method and set it back once you are done? If the rewrite method already allows term extraction we don't need to do anything and if so you can also set the query back into the context via updateRewriteQuery?
+1 lgtm! |
+1 looks great! |
Merged |
…level queries In elastic#4052 we added support for highlighting multi term queries using the postings highlighter. That worked only for top-level queries though, and not for multi term queries that are nested for instance within a bool query, or filtered query, or a constant score query. The way we make this work is by walking the query structure and temporarily overriding the query rewrite method with a method that allows for multi terms extraction. Closes elastic#5102
…level queries In #4052 we added support for highlighting multi term queries using the postings highlighter. That worked only for top-level queries though, and not for multi term queries that are nested for instance within a bool query, or filtered query, or a constant score query. The way we make this work is by walking the query structure and temporarily overriding the query rewrite method with a method that allows for multi terms extraction. Closes #5127
…level queries In #4052 we added support for highlighting multi term queries using the postings highlighter. That worked only for top-level queries though, and not for multi term queries that are nested for instance within a bool query, or filtered query, or a constant score query. The way we make this work is by walking the query structure and temporarily overriding the query rewrite method with a method that allows for multi terms extraction. Closes #5127
…level queries In #4052 we added support for highlighting multi term queries using the postings highlighter. That worked only for top-level queries though, and not for multi term queries that are nested for instance within a bool query, or filtered query, or a constant score query. The way we make this work is by walking the query structure and temporarily overriding the query rewrite method with a method that allows for multi terms extraction. Closes #5127
…level queries In elastic#4052 we added support for highlighting multi term queries using the postings highlighter. That worked only for top-level queries though, and not for multi term queries that are nested for instance within a bool query, or filtered query, or a constant score query. The way we make this work is by walking the query structure and temporarily overriding the query rewrite method with a method that allows for multi terms extraction. Closes elastic#5127
…level queries In elastic#4052 we added support for highlighting multi term queries using the postings highlighter. That worked only for top-level queries though, and not for multi term queries that are nested for instance within a bool query, or filtered query, or a constant score query. The way we make this work is by walking the query structure and temporarily overriding the query rewrite method with a method that allows for multi terms extraction. Closes elastic#5127
Added rewrite of the query using the current top level reader instead of an empty one, rewritten all multi term queries using
TopTermsScoringBooleanQueryRewrite(1024)
rewrite mode.As a result, postings highlighter supports now wildcard query, prefix query, fuzzy query, term range query and regexp query.
Closes #4042