import { SavedObjectMigrationFn } from 'kibana/server' ; import { get } from 'lodash' ; import { DEFAULT_QUERY_LANGUAGE } from '../../../data/common' ; link link export const migrateMatchAllQuery = ( doc ) => { const searchSourceJSON = get ( doc , 'attributes.kibanaSavedObjectMeta.searchSourceJSON' ) ; if ( searchSourceJSON ) { let searchSource ; try { searchSource = JSON . parse ( searchSourceJSON ) ; } catch ( e ) { return doc ; } if ( searchSource . query ?. match_all ) { return { ... doc , attributes : { ... doc . attributes , kibanaSavedObjectMeta : { searchSourceJSON : JSON . stringify ( { ... searchSource , query : { query : '' , language : DEFAULT_QUERY_LANGUAGE , } , } ) , } , } , } ; } } return doc ; } ;