Hello everyone !
I need help.
I have boolean field "sendSMS" with many values, for exemple :
sendSMS : [true , false, true]
and i want use scripted field to count the number of "true" in my field.
Thanks in advance for your future answers.
Hello everyone !
I need help.
I have boolean field "sendSMS" with many values, for exemple :
sendSMS : [true , false, true]
and i want use scripted field to count the number of "true" in my field.
Thanks in advance for your future answers.
Painless supports for
loop, so you can easily iterate over your array of values. You would need to do something like:
int count = 0;
for (val in doc['sendSMS']) {
if (val == true) {
count++;
}
}
emit(count);
Thanks for your answer, but when i try your script, i have an error : "reason": "Unknown call [emit] with [1] arguments."
But I can't solve this error...
Do you have an idea please?
Have you tried return
?
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.