diff --git a/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesFetcher.java b/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesFetcher.java index e6d7af11d06cc..7627e863770a1 100644 --- a/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesFetcher.java +++ b/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesFetcher.java @@ -9,6 +9,7 @@ package org.elasticsearch.action.fieldcaps; +import org.elasticsearch.cluster.metadata.InferenceFieldMetadata; import org.elasticsearch.cluster.metadata.MappingMetadata; import org.elasticsearch.core.Booleans; import org.elasticsearch.core.Nullable; @@ -30,6 +31,7 @@ import org.elasticsearch.tasks.CancellableTask; import java.io.IOException; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -256,6 +258,13 @@ private static Predicate buildFilter(String[] filters, String[] Set acceptedTypes = Set.of(fieldTypes); fcf = ft -> acceptedTypes.contains(ft.familyTypeName()); } + + Collection inferenceFields = context.getMappingLookup().inferenceFields().values(); + for (InferenceFieldMetadata inferenceField : inferenceFields) { + Predicate next = ft -> ft.name().startsWith(inferenceField.getName() + ".inference") == false; + fcf = fcf == null ? next : fcf.and(next); + } + for (String filter : filters) { if ("parent".equals(filter) || "-parent".equals(filter)) { continue; @@ -269,6 +278,7 @@ private static Predicate buildFilter(String[] filters, String[] }; fcf = fcf == null ? next : fcf.and(next); } + return fcf; }