-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[data views] Provide method of excluding data tiers when getting field list #167946
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d6d9b4a
first pass at excluding fields from frozen indices.
mattkime 9499fb0
Merge branch 'main' into data_views_exclude_frozen
mattkime 7fc1679
change to string, use for filter
mattkime 4a82039
Merge branch 'main' into data_views_exclude_frozen
mattkime c9cacdf
implement excluded tiers for field caps
mattkime 5e51b9d
implement excluded tiers for field caps
mattkime 318a2f6
fix tier names, include in setting description
mattkime 19cd661
update setting telemetry
mattkime 5ea87bd
Merge branch 'main' into data_views_exclude_frozen
mattkime 06a1171
Merge branch 'main' into data_views_exclude_frozen
mattkime 6447460
Merge branch 'main' into data_views_exclude_frozen
mattkime 520ef68
Update ui_settings.ts
mattkime b98deaa
Merge branch 'main' into data_views_exclude_frozen
mattkime b23aafe
apply tier filter to new fields endpoint
mattkime 2e1bbe0
Update ui_settings.ts
mattkime File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/plugins/data_views/server/rest_api_routes/internal/utils.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { getIndexFilterDsl } from './utils'; | ||
|
||
describe('getIndexFilterDsl', () => { | ||
const indexFilter = { term: { _id: '1' } }; | ||
const tiersQuery = { | ||
bool: { | ||
must_not: [ | ||
{ | ||
terms: { | ||
_tier: ['data_cold', 'data_frozen'], | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
const excludedTiers = 'data_cold, data_frozen'; | ||
|
||
it('no indexFilter, no excluded tiers', () => { | ||
expect(getIndexFilterDsl({})).toBeUndefined(); | ||
}); | ||
|
||
it('indexFilter, no excluded tiers', () => { | ||
expect(getIndexFilterDsl({ indexFilter })).toEqual(indexFilter); | ||
}); | ||
|
||
it('excluded tiers, no indexFilter', () => { | ||
expect(getIndexFilterDsl({ excludedTiers })).toEqual(tiersQuery); | ||
}); | ||
|
||
it('indexFilter and excluded tiers', () => { | ||
const combinedQuery = { | ||
bool: { | ||
must: [indexFilter, tiersQuery], | ||
}, | ||
}; | ||
|
||
expect(getIndexFilterDsl({ indexFilter, excludedTiers })).toEqual(combinedQuery); | ||
}); | ||
}); |
46 changes: 46 additions & 0 deletions
46
src/plugins/data_views/server/rest_api_routes/internal/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import type { QueryDslQueryContainer } from '../../../common/types'; | ||
|
||
const excludeTiersDsl = (excludedTiers: string) => { | ||
const _tier = excludedTiers.split(',').map((tier) => tier.trim()); | ||
return { | ||
bool: { | ||
must_not: [ | ||
{ | ||
terms: { | ||
_tier, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
}; | ||
|
||
interface GetIndexFilterDslOptions { | ||
indexFilter?: QueryDslQueryContainer; | ||
excludedTiers?: string; | ||
} | ||
|
||
export const getIndexFilterDsl = ({ | ||
indexFilter, | ||
excludedTiers, | ||
}: GetIndexFilterDslOptions): QueryDslQueryContainer | undefined => { | ||
if (!indexFilter) { | ||
return excludedTiers ? excludeTiersDsl(excludedTiers) : undefined; | ||
} | ||
|
||
return !excludedTiers | ||
? indexFilter | ||
: { | ||
bool: { | ||
must: [indexFilter, excludeTiersDsl(excludedTiers)], | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is it worth indicating the expected comma-separated format, or do we think users will know what to expect for this?