Skip to content

Commit

Permalink
[data views] allow cross cluster index pattern negation (#147968)
Browse files Browse the repository at this point in the history
## Summary

The data views api examines comma delimited sections to see if there are
matching indices before fetching the field list. The existing code
checked for index pattern negation - patterns that started with a `-`.
However, it didn't check for this in cross cluster case -
`this_cluster:-kibana*`. The code now handles the cross cluster case
appropriately.

Still, its unclear to me whether this logic is necessary, hence why I
opened #147970 - I was able to
resolve the failed tests most familiar to me but I will need to work
with engineers from other teams to investigate other failures.

Closes #147926
  • Loading branch information
mattkime committed Dec 29, 2022
1 parent ad73935 commit e3cac21
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ describe('Index Pattern Fetcher - server', () => {
.mockResponseOnce(emptyResponse as unknown as estypes.FieldCapsResponse)
.mockResponse(response as unknown as estypes.FieldCapsResponse);
// first field caps request returns empty
const result = await indexPatterns.validatePatternListActive(['-a', 'b', 'c']);
expect(result).toEqual(['-a', 'c']);
const result = await indexPatterns.validatePatternListActive(['-a', 'b', 'c', 'a:-b']);
expect(result).toEqual(['-a', 'c', 'a:-b']);
});
it('Returns all patterns when all match indices', async () => {
esClient.fieldCaps.mockResponse(response as unknown as estypes.FieldCapsResponse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class IndexPatternsFetcher {
patternList
.map(async (index) => {
// perserve negated patterns
if (index.startsWith('-')) {
if (index.startsWith('-') || index.includes(':-')) {
return true;
}
const searchResponse = await this.elasticsearchClient.fieldCaps({
Expand Down

0 comments on commit e3cac21

Please sign in to comment.