Search code examples
elasticsearchgoogle-chrome-extensionelasticsearch-painless

Update elastic document using chrome head


I am trying to update a document using a script in a query using head (chrome extension)

 {
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "documentId": "cb2d622f-d997-41c6-96ec-505d6fe656b5"
          }
        }
      ]
    }
  },
  "script": {
    "lang": "painless",
    "source": "ctx._source.versionState = 1;"
  }
}

chrome-head

But keep on getting the same response:

Unknown key for a START_OBJECT in [script].

Could someone point out what am I missing to do this?


Solution

  • You cannot update a document using the _search endpoint.

    Change the endpoint to [put your index here]/_update_by_query and maybe also pick the specific index that you want to update instead of updating all indexes.