import { getFilterField , cleanFilter , Filter } from '../filters' ; import { IIndexPattern } from '../../index_patterns' ; export const handleNestedFilter = ( filter , indexPattern ? ) => { if ( ! indexPattern ) return filter ; const fieldName = getFilterField ( filter ) ; if ( ! fieldName ) { return filter ; } const field = indexPattern . fields . find ( ( indexPatternField ) => indexPatternField . name === fieldName ) ; if ( ! field || ! field . subType || ! field . subType . nested || ! field . subType . nested . path ) { return filter ; } const query = cleanFilter ( filter ) ; return { meta : filter . meta , nested : { path : field . subType . nested . path , query : query . query || query , } , } ; } ;