-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add ability to set "max_analyzed_offset" implicitly to "index.highlight #118895
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
Conversation
0f3e7c9
to
cdc01a6
Compare
8fe10d5
to
11e82d3
Compare
.max_analyzed_offset", by setting it excplicitly to "-1".
11e82d3
to
2faea54
Compare
Pinging @elastic/es-search-relevance (Team:Search Relevance) |
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.
LGTM, I agree (based on our discussion earlier today) some additional testing would be good. So probably worth a +1 from Mayya when she returns. Probably worth backporting this to v8.18.0 as well; I've thrown that label on the PR and thrown on the auto-back label for when you merge this. Feel free to take those off if you have questions or concerns for any reason.
public void testMaxQueryOffsetDefault() throws Exception { | ||
assertAcked( | ||
prepareCreate("test").setMapping(type1PostingsffsetsMapping()) | ||
.setSettings(Settings.builder().put("index.highlight.max_analyzed_offset", "10").build()) |
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.
Observe index offset is 10
logger.info("--> highlighting and searching on field1"); | ||
// Specific for this test: by passing "-1" as "maxAnalyzedOffset", the index highlight setting above will be used. | ||
SearchSourceBuilder source = searchSource().query(termQuery("field1", "sentence")) | ||
.highlighter(highlight().field("field1").order("score").maxAnalyzedOffset(-1)); |
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.
Observe query offset is -1
assertThat(field1.fragments().length, equalTo(1)); | ||
assertThat( | ||
field1.fragments()[0].string(), | ||
equalTo("This <em>sentence</em> contains one match, not that short. This sentence contains zero sentence matches.") |
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.
Observe only one match
no error is returned. The <<max-analyzed-offset, `max_analyzed_offset`>> query setting | ||
no error is returned. If it is set to -1 then the value of | ||
<<index-max-analyzed-offset, `index.highlight.max_analyzed_offset`>> is used instead. | ||
For values <= -1, an error is returned. The <<max-analyzed-offset, `max_analyzed_offset`>> query setting |
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.
The formatting here doesnt seem affected by spotlessApply, is there another tool to lint?
Looking at the CI tests, it looks like the backwards compatibility tests are failing since I've changed the exception message (https://buildkite.com/elastic/elasticsearch-pull-request/builds/48659#0194292d-5312-4ee2-a6f2-a3217e270df8). Also more generally we do not throw when the value is -1 now. This seems to be running against some older branch.... What would be the way to handle this? Should we backport this commit? |
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.
@svilen-mihaylov-elastic Thanks for a great work!
server/src/main/java/org/elasticsearch/rest/action/search/SearchCapabilities.java
Outdated
Show resolved
Hide resolved
@elasticsearchmachine test this please |
1 similar comment
@elasticsearchmachine test this please |
💔 Backport failed
You can use sqren/backport to manually backport by running |
…ht (elastic#118895) Add ability to set "max_analyzed_offet" implicitly to "index.highlight .max_analyzed_offset", by setting it excplicitly to "-1". Closes elastic#112822 (cherry picked from commit 93c349c)
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
Add ability to set "max_analyzed_offet" implicitly to "index.highlight
.max_analyzed_offset", by setting it excplicitly to "-1".
Closes #112822