Skip to content

[Tests] Fix rare edge case in SimpleQueryStringBuilderTests #35201

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

Merged
merged 1 commit into from
Nov 5, 2018
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 @@ -104,6 +104,12 @@ protected SimpleQueryStringBuilder doCreateTestQueryBuilder() {
fields.put(STRING_FIELD_NAME_2, 2.0f / randomIntBetween(1, 20));
}
}
// special handling if query is "now" and no field specified. This hits the "mapped_date" field which leads to the query not being
// cacheable and trigger later test failures (see https://github.com/elastic/elasticsearch/issues/35183)
if (fieldCount == 0 && result.value().equalsIgnoreCase("now")) {
fields.put(STRING_FIELD_NAME_2, 2.0f / randomIntBetween(1, 20));
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't like really like adding so many lines for a relatively rare case, but every other way (e.g. disallowing "now" altogether as a query string) would have been worse IMHO.


result.fields(fields);
if (randomBoolean()) {
result.autoGenerateSynonymsPhraseQuery(randomBoolean());
Expand Down