Update null_value property

I created a new property in my mapping, with the following characteristics.

{
  "allow_to_buy": {
    "type": "text",
    "fields": {
      "keyword": {
        "type": "keyword",
        "null_value": "N",
        "ignore_above": 256
      }
    }
  }
}

To update the documents I used the function update by query.

http://localhost:9200/twitter/tweet/_update_by_query

http://localhost:9200/twitter/tweet/_update_by_query?conflicts=proceed

However, even looking for the new property when the value is N, nothing returns.

{
    "size": 1000,
    "query": {
        "term": {
            "allow_to_buy.keyword": {
                "value": "N",
                "boost": 1.0
            }
        }
    }
}

What should I do?

can you show a sample document? The null_value feature only works, if the field is part of your JSON but explicitely marked as null, i.e. foo: null - if the field does not exist, than this will not work. You would need to write a small script in the update by query call, that checks for the existence of the field and sets this field by default.

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