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

Fix SearchQueryIT to not depend on percentage #11233

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,19 @@ public void testCommonTermsQuery() throws Exception {
assertSecondHit(searchResponse, hasId("2"));
assertThirdHit(searchResponse, hasId("3"));

searchResponse = client().prepareSearch().setQuery(commonTermsQuery("field1", "the huge fox").lowFreqMinimumShouldMatch("2")).get();
// cutoff frequency of 1 makes all terms high frequency so the query gets rewritten as a
// conjunction of all terms (the lowFreqMinimumShouldMatch parameter is effectively ignored)
searchResponse = client().prepareSearch()
.setQuery(commonTermsQuery("field1", "the huge fox").cutoffFrequency(1).lowFreqMinimumShouldMatch("2"))
.get();
assertHitCount(searchResponse, 1L);
assertFirstHit(searchResponse, hasId("2"));

// cutoff frequency of 100 makes all terms low frequency, so lowFreqMinimumShouldMatch=3
// means all terms must match
searchResponse = client().prepareSearch()
.setQuery(commonTermsQuery("field1", "the huge fox").cutoffFrequency(100).lowFreqMinimumShouldMatch("3"))
.get();
assertHitCount(searchResponse, 1L);
assertFirstHit(searchResponse, hasId("2"));

Expand Down
Loading