From fc26aa4889ad24c8bf86e68e12672981c9ab27e9 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Tue, 27 Feb 2024 14:36:01 -0300 Subject: [PATCH] Make sure the mapping exists before trying to change it --- includes/classes/Feature/Search/Synonyms.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/includes/classes/Feature/Search/Synonyms.php b/includes/classes/Feature/Search/Synonyms.php index a45955ea2b..de26fec2f9 100644 --- a/includes/classes/Feature/Search/Synonyms.php +++ b/includes/classes/Feature/Search/Synonyms.php @@ -463,7 +463,12 @@ public function update_synonyms() { function( $success, $index ) { $filter = $this->get_synonym_filter(); $mapping = Elasticsearch::factory()->get_mapping( $index ); - $filters = $mapping[ $index ]['settings']['index']['analysis']['analyzer']['default_search']['filter']; + + if ( empty( $mapping ) || empty( $mapping[ $index ] ) ) { + return false; + } + + $filters = (array) $mapping[ $index ]['settings']['index']['analysis']['analyzer']['default_search']['filter']; /* * Due to limitations in Elasticsearch, we can't remove the filter and analyzer