-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Make sure _tier field handles missing setting #71439
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,19 +42,34 @@ public void testWildcardQuery() { | |
| assertEquals(new MatchAllDocsQuery(), ft.wildcardQuery("Data_Warm", null, true, createContext())); | ||
| assertEquals(new MatchNoDocsQuery(), ft.wildcardQuery("Data_Warm", null, false, createContext())); | ||
| assertEquals(new MatchNoDocsQuery(), ft.wildcardQuery("noSuchRole", null, createContext())); | ||
|
|
||
| assertEquals(new MatchNoDocsQuery(), ft.wildcardQuery("data_*", null, createContextWithoutSetting())); | ||
| assertEquals(new MatchNoDocsQuery(), ft.wildcardQuery("*", null, createContextWithoutSetting())); | ||
| } | ||
|
|
||
| public void testTermQuery() { | ||
| MappedFieldType ft = DataTierFieldMapper.DataTierFieldType.INSTANCE; | ||
| assertEquals(new MatchAllDocsQuery(), ft.termQuery("data_warm", createContext())); | ||
| assertEquals(new MatchNoDocsQuery(), ft.termQuery("data_hot", createContext())); | ||
| assertEquals(new MatchNoDocsQuery(), ft.termQuery("noSuchRole", createContext())); | ||
|
|
||
| assertEquals(new MatchNoDocsQuery(), ft.termQuery("data_warm", createContextWithoutSetting())); | ||
| assertEquals(new MatchNoDocsQuery(), ft.termQuery("", createContextWithoutSetting())); | ||
| } | ||
|
|
||
| public void testTermsQuery() { | ||
| MappedFieldType ft = DataTierFieldMapper.DataTierFieldType.INSTANCE; | ||
| assertEquals(new MatchAllDocsQuery(), ft.termsQuery(Arrays.asList("data_warm"), createContext())); | ||
| assertEquals(new MatchNoDocsQuery(), ft.termsQuery(Arrays.asList("data_cold", "data_frozen"), createContext())); | ||
|
|
||
| assertEquals(new MatchNoDocsQuery(), ft.termsQuery(Arrays.asList("data_warm"), createContextWithoutSetting())); | ||
| assertEquals(new MatchNoDocsQuery(), ft.termsQuery(Arrays.asList(""), createContextWithoutSetting())); | ||
| } | ||
|
|
||
| public void testExistsQuery() { | ||
| MappedFieldType ft = DataTierFieldMapper.DataTierFieldType.INSTANCE; | ||
| assertEquals(new MatchAllDocsQuery(), ft.existsQuery(createContext())); | ||
| assertEquals(new MatchNoDocsQuery(), ft.existsQuery(createContextWithoutSetting())); | ||
| } | ||
|
|
||
| public void testRegexpQuery() { | ||
|
|
@@ -102,4 +117,18 @@ private SearchExecutionContext createContext() { | |
| emptyMap() | ||
| ); | ||
| } | ||
|
|
||
| private SearchExecutionContext createContextWithoutSetting() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: maybe we could re-use the other createContext() method by adding an argument (e.g. a bool flag) to either return a context with- or without the setting?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the suggestion, I'll stick with this approach as I find it clearest right now. We can always refactor if these methods grow larger and there's more duplication! |
||
| IndexMetadata indexMetadata = IndexMetadata.builder("index") | ||
| .settings(Settings.builder() | ||
| .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) | ||
| .build()) | ||
| .numberOfShards(1) | ||
| .numberOfReplicas(0) | ||
| .build(); | ||
| IndexSettings indexSettings = new IndexSettings(indexMetadata, Settings.EMPTY); | ||
| return new SearchExecutionContext(0, 0, indexSettings, null, null, null, null, null, null, | ||
| xContentRegistry(), writableRegistry(), null, null, System::currentTimeMillis, null, | ||
| value -> true, () -> true, null, emptyMap()); | ||
| } | ||
| } | ||
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.
This check is a little unusual, but it matches how we test for the setting in other places like
DataTierAllocationDecider.