Skip to content

Conversation

@Mikep86
Copy link
Contributor

@Mikep86 Mikep86 commented Jun 2, 2025

Excludes semantic_text subfields from fields caps. Also handles if semantic_text fields have multi-fields:

PUT _inference/text_embedding/my-e5-model
{
  "service": "elasticsearch",
  "service_settings": {
    "num_allocations": 1,
    "num_threads": 1,
    "model_id": ".multilingual-e5-small"
  }
}

PUT test-field-caps
{
    "mappings": {
        "properties": {
            "test_field": {
                "type": "semantic_text",
                "inference_id": ".elser-2-elasticsearch"
            },
            "object": {
              "properties": {
                "test_field_dense": {
                    "type": "semantic_text",
                    "inference_id": "my-e5-model",
                    "fields": {
                      "text": {
                        "type": "text"
                      }
                    }
                }
              }
            },
            "non_infer_field": {
                "type": "text"
            },
            "sparse_vector": {
                "type": "sparse_vector"
            },
            "dense_vector": {
                "type": "dense_vector",
                "dims": 3,
                "similarity": "l2_norm"
            }
        }
    }
}

PUT test-field-caps/_doc/doc1
{
    "test_field": "these are not the droids you're looking for. He's free to go around",
    "object.test_field_dense": "these are not the droids you're looking for. He's free to go around",
    "sparse_vector": {
        "these": 1,
        "are": 2,
        "not": 3
    },
    "dense_vector": [1, 2, 3]
}

GET /_field_caps?allow_no_indices=true&fields=*&index=test*&ignore_unavailable=true&expand_wildcards=open

@Mikep86 Mikep86 added >non-issue :SearchOrg/Relevance Label for the Search (solution/org) Relevance team labels Jun 2, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>non-issue :SearchOrg/Relevance Label for the Search (solution/org) Relevance team v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants