Get a length/size of message field value

Hi, I try to make a scripted fields with size of message field value. I tried

doc['message'].value.getSize() 
doc['message'].value.size()

I tried also with ['message.keyword'] but nothing. I have in preview. Where am I wrong?
Thank you

Hi @EugeneZ,

I tried with a sample data and it works with length: doc['category.keyword'].value.length()

Let me know if that fixed your problem!

Hmm...
I try return doc['message.keyword'].value.length() and in preview I have

[
 {
  "_id": "R7h8RXUBp5UPtyZb69B4",
  "sf_msg_size": [
   63
  ]
 },
 {
  "_id": "SLh8RXUBp5UPtyZb69B4",
  "sf_msg_size": [
   63
  ]
 },

It is somethig but not 'message' length.

What's the expected outcome then? For me it works perfectly, eg. for the example I gave, it returns

[
 {
  "_id": "WmrTl3UB9Atbtm2uF-nb",
  "scripted_len": [
   13
  ]
 }...
 ]

And my first result is Women's Clothing which is 13 characters long.

Yes, it's working. Thank you.

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