Using update API to change the contents of a text field

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.

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:

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:

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.

Hello @Tim_Estes

Could you please tell us:

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

As requested:
Version is 7.6.0

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"
      }
    }
  }
}

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?
  1. Running GET my-index?include_type_name:
#! 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.

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 ?

Sure! Thanks for investigating!

1 Like

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