# Using update API to change the contents of a text field

**URL:** <https://discuss.elastic.co/t/using-update-api-to-change-the-contents-of-a-text-field/231418>\
**Category:** Elasticsearch\
**Created:** [May 6, 2020, 10:13pm UTC](https://discuss.elastic.co/t/using-update-api-to-change-the-contents-of-a-text-field/231418 "2020-05-06T22:13:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim\_Estes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tim_estes/32/64928_2.png) [@Tim\_Estes](https://discuss.elastic.co/u/Tim_Estes)\
**Post date:** [May 6, 2020, 10:13pm UTC](https://discuss.elastic.co/t/using-update-api-to-change-the-contents-of-a-text-field/231418/1 "2020-05-06T22:13:35Z")

</div>

Hello, I have the following schema for an index, with some example documents. My use-case is that I'm indexing a book and I am indexing by page.

I'm trying to update the contents of a page if the user decides to edit a particular page, but there's a weird error no-one else seems to have encountered.

```auto
PUT my-index
{}

PUT my-index/_mapping
{
    "properties": {
        "page": {
            "type": "long"
        },
        "title": {
            "type": "keyword"
        },
        "content": {
            "type": "text"
        }
    }
}

POST _bulk
{ "index" : { "_index" : "my-index", "_id" : "doc_1.pg_1" } }
{ "page" : 1, "title": "doc_1", "content": "a quick brown fox jumped over the lazy dog ..."}
{ "index" : { "_index" : "my-index", "_id" : "doc_1.pg_2" } }
{ "page" : 2, "title": "doc_1", "content": "... and the fox landed in a briar patch"}
{ "index" : { "_index" : "my-index", "_id" : "doc_2.pg_1" } }
{ "page" : 1, "title": "doc_2", "content": "a slow orange fox leapt over the barky dog ..."}
{ "index" : { "_index" : "my-index", "_id" : "doc_2.pg_2" } }
{ "page" : 2, "title": "doc_2", "content": "... and the dog lept and got the fox"}

```

Here's the update API call and the response:

```auto
POST my-index/_update/doc_1.pg_1
{
  "doc": {
   "content" : "a slow fox jumped over the really fast dog"
  }
}

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "cannot change field \"content\" from index options=DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS to inconsistent index options=DOCS_AND_FREQS_AND_POSITIONS"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "cannot change field \"content\" from index options=DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS to inconsistent index options=DOCS_AND_FREQS_AND_POSITIONS"
  },
  "status" : 400
}

```

I've also tried to update the content field with a script too, but I got the same error:

```auto
POST /my-index/_update/doc_1.pg_1
{
  "script": {
    "source": "ctx._source['content'] = 'a slow fox jumped over the really fast dog'"
  }
}

```

Does anyone seem to understand what's going on? Can you help me?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Luca\_Belluccini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luca_belluccini/32/33239_2.png) [@Luca\_Belluccini](https://discuss.elastic.co/u/Luca_Belluccini)\
**Post date:** [May 6, 2020, 11:42pm UTC](https://discuss.elastic.co/t/using-update-api-to-change-the-contents-of-a-text-field/231418/2 "2020-05-06T23:42:00Z")

</div>

Hello @Tim_Estes

Could you please tell us:

1. Which Elasticsearch version?
2. Can provide the output of `GET my-index`?

---

<div class="post-metadata">

**Author:** ![Tim\_Estes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tim_estes/32/64928_2.png) [@Tim\_Estes](https://discuss.elastic.co/u/Tim_Estes)\
**Post date:** [May 6, 2020, 11:44pm UTC](https://discuss.elastic.co/t/using-update-api-to-change-the-contents-of-a-text-field/231418/3 "2020-05-06T23:44:02Z")

</div>

As requested:  
Version is 7.6.0

```auto
GET /my-index
{
  "my-index" : {
    "aliases" : { },
    "mappings" : {
      "properties" : {
        "content" : {
          "type" : "text"
        },
        "date_indexed" : {
          "type" : "date",
          "format" : "yyyy-MM-dd HH:mm:ss"
        },
        "page" : {
          "type" : "long"
        },
        "title" : {
          "type" : "keyword"
        }
      }
    },
    "settings" : {
      "index" : {
        "creation_date" : "1586193744347",
        "number_of_shards" : "1",
        "number_of_replicas" : "1",
        "uuid" : "PInrq2dGQoqG9sn9Xk2CRQ",
        "version" : {
          "created" : "7060099"
        },
        "provided_name" : "my-index"
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![Luca\_Belluccini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luca_belluccini/32/33239_2.png) [@Luca\_Belluccini](https://discuss.elastic.co/u/Luca_Belluccini)\
**Post date:** [May 6, 2020, 11:56pm UTC](https://discuss.elastic.co/t/using-update-api-to-change-the-contents-of-a-text-field/231418/4 "2020-05-06T23:56:17Z")

</div>

I have other 3 questions:

1. Can you run `GET my-index?include_type_name`
2. Can you check if on the Elasticsearch node(s) you have a stacktrace/error log associated to your requests?
3. Where is the Elasticsearch `path.data` pointing to? Is it a local disk?

---

<div class="post-metadata">

**Author:** ![Tim\_Estes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tim_estes/32/64928_2.png) [@Tim\_Estes](https://discuss.elastic.co/u/Tim_Estes)\
**Post date:** [May 7, 2020, 12:10am UTC](https://discuss.elastic.co/t/using-update-api-to-change-the-contents-of-a-text-field/231418/5 "2020-05-07T00:10:14Z")

</div>

1. Running `GET my-index?include_type_name`:

```auto
#! Deprecation: [types removal] Using `include_type_name` in get indices requests is deprecated. The parameter will be removed in the next major version.
{
  "my-index" : {
    "aliases" : { },
    "mappings" : {
      "_doc" : {
        "properties" : {
          "content" : {
            "type" : "text"
          },
          "date_indexed" : {
            "type" : "date",
            "format" : "yyyy-MM-dd HH:mm:ss"
          },
          "page" : {
            "type" : "long"
          },
          "title" : {
            "type" : "keyword"
          }
        }
      }
    },
    "settings" : {
      "index" : {
        "creation_date" : "1586193744347",
        "number_of_shards" : "1",
        "number_of_replicas" : "1",
        "uuid" : "PInrq2dGQoqG9sn9Xk2CRQ",
        "version" : {
          "created" : "7060099"
        },
        "provided_name" : "my-index"
      }
    }
  }
}

```

1. I'm not sure how to check for this. I'm running on the Elastic Cloud. I checked the elasticsearch logs and there is no stacktrace or error message from the requests I've sent via Kibana.

2. I'm also not sure how to find out where the `path.data` is pointing to. The only thing I saw that might be related was under the index settings in Kibana, where the `"data_path"` field was set to `""`. I don't think its a local disk since the Elastic Cloud is hosting the deployment.

---

<div class="post-metadata">

**Author:** ![Luca\_Belluccini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luca_belluccini/32/33239_2.png) [@Luca\_Belluccini](https://discuss.elastic.co/u/Luca_Belluccini)\
**Post date:** [May 7, 2020, 12:14am UTC](https://discuss.elastic.co/t/using-update-api-to-change-the-contents-of-a-text-field/231418/6 "2020-05-07T00:14:13Z")

</div>

Hello @Tim_Estes

Sorry, I didn't know you were running on Elastic Cloud.

Could you please raise a case on [https://cloud.elastic.co/help](https://cloud.elastic.co/help) ?

---

<div class="post-metadata">

**Author:** ![Tim\_Estes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tim_estes/32/64928_2.png) [@Tim\_Estes](https://discuss.elastic.co/u/Tim_Estes)\
**Post date:** [May 7, 2020, 12:15am UTC](https://discuss.elastic.co/t/using-update-api-to-change-the-contents-of-a-text-field/231418/7 "2020-05-07T00:15:22Z")

</div>

Sure! Thanks for investigating!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 4, 2020, 12:15am UTC](https://discuss.elastic.co/t/using-update-api-to-change-the-contents-of-a-text-field/231418/8 "2020-06-04T00:15:22Z")

</div>

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