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

skip GeoPointMultiTermQuery when highlighting #20412

Merged
merged 3 commits into from
Sep 13, 2016

Conversation

brwe
Copy link
Contributor

@brwe brwe commented Sep 12, 2016

We skip GeoPointInBBoxQuery already but not when it was rewritten
it appears as GeoPointMultiTermQuery and needs to be skipped as well.

see #17537

This pull request is against the 2.4 branch and a follow up to #17537 (comment) . Unfortunately my assumption that the highlighter never gets to see a rewritten query (see #18495 (comment)) was wrong and so in some cases such as the example provided by @ajayar it does. We need to check for that as well and skip the highlighting in this case.

The tests in this pull request do not reproduce the issue #17537 on the 2.4 branch for me and I believe this is due to an unrelated change in Lucene. I still think we should merge this to 2.4 anyway to be on the safe side. On 2.3 the tests reproduce the issue. In addition the discussion on #17537 is not finished so this pull request doe not close the issue yet.

On master the problem was fixed in Lucene (see https://issues.apache.org/jira/browse/LUCENE-7293) so we can remove the check in CustomQueryScorer completely. I will open a separate pull request for that.

We skip GeoPointInBBoxQuery already but not when it was rewritten
it appears as GeoPointInBBoxQuery and needs to be skipped as well.

see elastic#17537
@jimczi
Copy link
Contributor

jimczi commented Sep 12, 2016

@brwe I opened a similar PR to fix a problem with prefix queries embedded in a function query. I think it should fix the problem you are seeing since it avoids the rewrite of the function query (and it's inner query). Can you take a look ?
#20400

@s1monw
Copy link
Contributor

s1monw commented Sep 12, 2016

@jimferenczi I am not sure if #20400 fixes this, it would still try to rewrite that inner geo query though?


static {
try {
unsupportedGeoQuery = Class.forName("org.apache.lucene.spatial.geopoint.search.GeoPointMultiTermQuery");
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a comment that this class in pkg private and that's why we are making this stunt?

@s1monw
Copy link
Contributor

s1monw commented Sep 12, 2016

LGTM

@jimczi
Copy link
Contributor

jimczi commented Sep 12, 2016

@jimferenczi I am not sure if #20400 fixes this, it would still try to rewrite that inner geo query though?

@s1monw true, but we could call extract instead of super.extract and get the expected behavior. I was just thinking about how we could avoid the class name check that this PR adds. Since this PR is for 2.x only (I've missed that point) I guess it's ok so LGTM too, in the mean time can I get a review for #20400 ? ;)

@s1monw
Copy link
Contributor

s1monw commented Sep 12, 2016

I guess it's ok so LGTM too, in the mean time can I get a review for #20400 ?

I did that before I commented here :)

@brwe
Copy link
Contributor Author

brwe commented Sep 12, 2016

@jimferenczi It seems like for this query this fixes it. But I still think it is better to check for the particular geo query when we highlight. Functionscore is just one of many and I think we should rather catch this problem for all cases even though the class check is rather ugly.

@jimczi
Copy link
Contributor

jimczi commented Sep 12, 2016

I did that before I commented here :)

he he, thanks !

Functionscore is just one of many and I think we should rather catch this problem for all cases even though the class check is rather ugly.

Not so many but I get your point. Maybe we should avoid rewrite completely ? I don't see where it could be beneficial for the highlighting. I may be completely wrong but is there examples where the rewrite solves an issue with highlighting. It seems to cause more harm than good.

@brwe
Copy link
Contributor Author

brwe commented Sep 12, 2016

Maybe we should avoid rewrite completely ?

Hm, that will be tricky as queries are rewritten in org.apache.lucene.search.highlight.WeightedSpanTermExtractor.extract() so that is rather a Lucene thing? I do not know the code well enough though to know if that can be easily avoided.

@brwe
Copy link
Contributor Author

brwe commented Sep 12, 2016

@s1monw added a comment. Thanks for the review!

brwe added a commit to brwe/elasticsearch that referenced this pull request Sep 12, 2016
brwe added a commit that referenced this pull request Sep 13, 2016
@brwe brwe merged commit 49eb377 into elastic:2.4 Sep 13, 2016
brwe added a commit that referenced this pull request Sep 13, 2016
* skip GeoPointMultiTermQuery when highlighting

We skip GeoPointInBBoxQuery already but not when it was rewritten
it appears as GeoPointInBBoxQuery and needs to be skipped as well.

see #17537
brwe added a commit that referenced this pull request Sep 13, 2016
brwe added a commit that referenced this pull request Sep 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants