79082484

Date: 2024-10-13 06:01:20
Score: 1.5
Natty:
Report link

Here is what I did. I have only text field for Gender.

"Gender":{
    "type":"text"
}

I want to add a keyword sub field to it. I update mapping as

"Gender": {
  "type": "text",
  "fields": {
    "keyword": {
      "type": "keyword"
    }
  }
}

I use this script to set keyword sub field. Updating the main field automatically updates all its sub-fields.

ctx._source.Gender = ctx._source.Gender.text;
Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: yulinxp