Search code examples
elasticsearchdocumentupdating

Add typed additional attributes to an existing document elasticsearch


I added a field to the document:

POST /erection/shop/1/_update
{
  "doc": {
    "my_field":""
  }
}

The new field is assigned to the type of "String". how can I create a new field with the type "Boolean"/"Integer"?

and 2nd question: is it possible to add one field in all documents using one query? (without updating each document)


Solution

  • 1) Explicitly define a mapping prior to the first update you do.

    2) No, you can't. You can do it in your application using "scan" and then "bulk update"