Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -256,6 +258,13 @@ private static Predicate<MappedFieldType> buildFilter(String[] filters, String[]
Set<String> acceptedTypes = Set.of(fieldTypes);
fcf = ft -> acceptedTypes.contains(ft.familyTypeName());
}

Collection<InferenceFieldMetadata> inferenceFields = context.getMappingLookup().inferenceFields().values();
for (InferenceFieldMetadata inferenceField : inferenceFields) {
Predicate<MappedFieldType> next = ft -> ft.name().startsWith(inferenceField.getName() + ".inference") == false;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if we could use SemanticTextField#getInferenceFieldName here, but I don't think hard-coding .inference here is a big deal overall

fcf = fcf == null ? next : fcf.and(next);
}

for (String filter : filters) {
if ("parent".equals(filter) || "-parent".equals(filter)) {
continue;
Expand All @@ -269,6 +278,7 @@ private static Predicate<MappedFieldType> buildFilter(String[] filters, String[]
};
fcf = fcf == null ? next : fcf.and(next);
}

return fcf;
}

Expand Down