0

I'm trying to create a scripted field in Kibana, which checks whether the field "Direction" is "I" or not.

if (doc['Direction'].value != "I") {return 1;} else {return 0;}

But for some reason, it won't work. With all other fields, that aren't explicitly mentioned in the index mapping it works that way, but I had to mention Direction in the mapping because I also have an alias pointing to it. For Direction I put the following in the mapping file:

"Direction": {
      "type": "keyword"
    }

And there is also an alias pointing to Direction:

"ISDN_Direction": {
      "path": "Direction",
      "type": "alias"
    }

but both fields can't be used in the painless script. I don't get an error, but the result preview, for the first 10 results, is just empty.

Can someone help me with this issue?

2
  • Is there a Keyword field for the same in the index pattern? Somehow in case of String columns painless is throwing error. If in Index Pattern you have .keyword column available please use that.
    – Shaleen
    Commented Jan 6, 2020 at 7:20
  • No, unfortunately I don't have a keyword field for this field in the index pattern. I guess ES automatically creates keyword fields for all fields that aren't mentioned explicitly in the mapping? With other keyword fields it works fine, it's just this one that I assigned the keyword type myself, which isn't working Commented Jan 6, 2020 at 10:35

1 Answer 1

0

I found the problem! I changed the data type mapping, but I still had indices in my ES DB that had an old mapping on "text". Kibana didn't show me a mapping conflict, since both, text and keywords, are strings.

I deleted the old indices which mapped the field to "text" and now the painless calculation works without any problem :slight_smile:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.