Elasticsearch - Scenario Based  Question - Update By Query

Given an index named "addresses"
Write a query that will add a field called "full_address" to all the documents

full_address = NUMBER + <SPACE> + STREET + <SPACE> + UNIT + <SPACE> + POSTCODE

Task

GET addresses/_search

POST addresses/_update_by_query
{
  "script": {
    "source": """
    ctx._source.full_address = ctx._source.NUMBER + ' ' + ctx._source.STREET + ' ' + ctx._source.UNIT + ' ' + ctx._source.POSTCODE;
    """,
    "lang": "painless"
  },
  "query": {
    "match_all": {}
  }
}

GET addresses/_search

Solution

THANKS

FOR

WATCHING

Elasticsearch-Scenario-Based-Question-Update-By-Query

By Deepak Dubey

Elasticsearch-Scenario-Based-Question-Update-By-Query

  • 515