Is it possible to disable auto adding new field?

I know we can disable auto index creation by setting action.auto_create_index. If I index a doc with an undefined field, the field will be auto added to the index.
Is it possible disable it? That is, if document contains undefined field, indexing should fail.

You probably want this

https://www.elastic.co/guide/en/elasticsearch/reference/5.2/dynamic.html

seems not work.

PUT /myindex
{
  "settings" : {
    "number_of_shards" : 1,
    "number_of_replicas" : 2
  },
  "mappings" : {
    "docs" : {
      "dynamic": false,
      "properties" : {
        "Title" : {
          "type" : "text"
        }
      }
    }
  }
}

POST /myindex/docs/1
{
  "DocumentId": "1033",
  "Title": "hello"
}


GET /myindex/docs/1

I got following response:

{
  "_index": "myindex",
  "_type": "docs",
  "_id": "1",
  "_version": 1,
  "found": true,
  "_source": {
    "DocumentId": "1033",
    "Title": "hello"
  }
}

Do I miss something?

Try strict

strict works as expected.
So is it bug that false does not work?

No it's not. Get the mapping and you will see that it has not been updated.

Got u. Although getting document can return the field, but mapping actually is not updated with the new field.
That makes sense.

Thanks!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.