From 3bf4f28cbfae618454acce63d299be5ae1ca5faa Mon Sep 17 00:00:00 2001 From: Jim Ferenczi Date: Wed, 30 Apr 2025 18:03:28 +0200 Subject: [PATCH] [semantic_text] Warn on inference endpoint not created This change fixes when we warn users that create a semantic_text field that points to a non-existing inference endpoint. The logging should happen only when the inference endpoint is checked against the registry and cases that don't use the registry should ignore it (recovery). --- .../inference/mapper/SemanticTextFieldMapper.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapper.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapper.java index f170f79809a59..548f65d4f93fa 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapper.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapper.java @@ -302,6 +302,13 @@ public SemanticTextFieldMapper build(MapperBuilderContext context) { * This will delay the creation of sub-fields, so indexing and querying for this field won't work * until the corresponding inference endpoint is created. */ + logger.warn( + "The field [{}] references an unknown inference ID [{}]. " + + "Indexing and querying this field will not work correctly until the corresponding " + + "inference endpoint is created.", + leafName(), + inferenceId.get() + ); } } else { resolvedModelSettings = modelSettings.get(); @@ -309,14 +316,6 @@ public SemanticTextFieldMapper build(MapperBuilderContext context) { if (modelSettings.get() != null) { validateServiceSettings(modelSettings.get(), resolvedModelSettings); - } else { - logger.warn( - "The field [{}] references an unknown inference ID [{}]. " - + "Indexing and querying this field will not work correctly until the corresponding " - + "inference endpoint is created.", - leafName(), - inferenceId.get() - ); } final String fullName = context.buildFullName(leafName());