Skip to content

Unable to update semantic text field in object using Update API #117258

Open
@Mikep86

Description

@Mikep86

Elasticsearch Version

8.15.x, 8.16.x, 8.17.x

Installed Plugins

No response

Java Version

bundled

OS Version

N/A

Problem Description

Under certain scenarios, you are unable to update a semantic text field using the Update API when the semantic text field is in an object field.

Steps to Reproduce

  1. Create an index with a semantic text field in an object:
PUT _inference/sparse_embedding/my-elser-endpoint
{
  "service": "elser",
  "service_settings": {
    "num_allocations": 1,
    "num_threads": 1
  }
}

PUT my-index
{
  "mappings": {
    "properties": {
      "object": {
        "properties": {
          "inference_field": {
            "type": "semantic_text",
            "inference_id": "my-elser-endpoint"
          }
        }
      }
    }
  }
}
  1. Add a document to the index, defining the semantic text field value using a nested structure
PUT my-index/_doc/doc1
{
  "object": {
    "inference_field": "test value"
  }
}
  1. Update the document using the Update API, defining the semantic text field value using a flat structure
POST my-index/_update/doc1
{
  "doc": { 
    "object.inference_field": "updated value"
  }
}

The update fails with the error:

{
    "error": {
        "root_cause": [
            {
                "type": "status_exception",
                "reason": "Invalid format for field [object.inference_field], expected [String] got [ArrayList]"
            }
        ],
        "type": "status_exception",
        "reason": "Invalid format for field [object.inference_field], expected [String] got [ArrayList]"
    },
    "status": 400
}

Logs (if relevant)

No response

Activity

self-assigned this
on Nov 21, 2024
elasticsearchmachine

elasticsearchmachine commented on Nov 21, 2024

@elasticsearchmachine
Collaborator

Pinging @elastic/search-eng (Team:SearchOrg)

elasticsearchmachine

elasticsearchmachine commented on Nov 21, 2024

@elasticsearchmachine
Collaborator

Pinging @elastic/search-relevance (Team:Search - Relevance)

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @Mikep86@elasticsearchmachine

      Issue actions

        Unable to update semantic text field in object using Update API · Issue #117258 · elastic/elasticsearch