Skip to content
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

Fixed multi term queries support in postings highlighter for non top-level queries #5143

Merged
merged 1 commit into from Feb 21, 2014

Conversation

javanna
Copy link
Member

@javanna javanna commented Feb 17, 2014

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 can 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

@javanna javanna self-assigned this Feb 17, 2014
@jpountz
Copy link
Contributor

jpountz commented Feb 17, 2014

The change looks good to me.

On a related node: should we have an option to not rewrite queries in order to ensure highlighting remains fast? cc @s1monw

@javanna
Copy link
Member Author

javanna commented Feb 17, 2014

Makes sense to me, I also plan to look at the upcoming changes in Lucene 4.7 aka faster ways to highlight multi term queries.

@roytmana
Copy link

Does it also fixes wildcard highlighting issue?

@jpountz
Copy link
Contributor

jpountz commented Feb 17, 2014

@roytmana yes, this change will make wildcard queries highlighted

@roytmana
Copy link

thank you @jpountz
Looks like it is still in @javanna repository. I will test it once it has been committed to ES repo

@nik9000
Copy link
Member

nik9000 commented Feb 17, 2014

If this change would make multi term queries highlight at the speed they do with the plain highlighter then please. I'd prefer the default be the faster option with an option to do the highlighting for multi term queries. If not that then at least a prominent warning. Or something.

Sent from my iPhone

On Feb 17, 2014, at 8:55 AM, Adrien Grand notifications@github.com wrote:

The change looks good to me.

On a related node: should we have an option to not rewrite queries in order to ensure highlighting remains fast? cc @s1monw


Reply to this email directly or view it on GitHub.

@javanna
Copy link
Member Author

javanna commented Feb 18, 2014

Hi @nik9000 I see your point... on the other hand if one wants to highlight multi term queries that's what it takes at this time. It feels pretty bad not to return any snippet by default to keep highlighting fast. My take is that the best way to keep highlighting fast is not to highlight multi term queries, that's it. I'd add a warning to the docs that explains what we do with multi term queries and the fact that it can slow things down.

Also we might be able to improve this once lucene 4.7 gets released, as mentioned above.

@nik9000
Copy link
Member

nik9000 commented Feb 18, 2014

Sounds good to me.

Sent from my iPhone

On Feb 18, 2014, at 4:34 AM, Luca Cavanna notifications@github.com wrote:

Hi @nik9000 I see your point... on the other hand if one wants to highlight multi term queries that's what it takes at this time. It feels pretty bad not to return any snippet by default to keep highlighting fast. My take is that the best way to keep highlighting fast is not to highlight multi term queries, that's it. I'd add a warning to the docs that explains what we do with multi term queries and the fact that it can slow things down.

Also we might be able to improve this once lucene 4.7 gets released, as mentioned above.


Reply to this email directly or view it on GitHub.

@roytmana
Copy link

Hi @javanna, will it be merged into 1.0 branch so I can test it?

}
}

if (query instanceof XFilteredQuery) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be FilteredQuery rather than XFilteredQuery same goes for the XConstantScore

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point I think we should have both then... XFilteredQuery and XConstantScore needs to be there otherwise this doesn't work for our filtered query and our constant score query?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true for XFilteredQuery used to subclass FilteredQuery but not for Constant:

public class XConstantScoreQuery extends ConstantScoreQuery {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

@s1monw
Copy link
Contributor

s1monw commented Feb 21, 2014

ok LGTM in general while I really don't like how this works in general :(

@javanna
Copy link
Member Author

javanna commented Feb 21, 2014

Neither do I. One other option is to remove the setRewriteMethod call in any case and let users set the rewrite_method themselves as it's exposed in the query DSL. Even better, as soon as lucene 4.7 is out we can look into LUCENE-5415 and hopefully replace our current logic when it comes to multi term queries.

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Postings Highlighter does not highlight trailing wildcard matches
6 participants