please use markdown for formatting code snippets in here. It will make your example much more readable, and thus more likely to get an answer.
If you want to be able to execute queries or aggregations against elements within JSON arrays, you need to get familiar with the nested datatype and the nested query as well as the nested aggregation. Using nested stores the elements in an array in a different fashion allowing these kind of queries to work as expected.
Hey Alexander Reelsen
This is the sum aggregation i have to using to calculate the the total value. But I am getting the aggregate for both the title ( Segments and Order) . is there a way to get aggregate for the title ( Segments ) alone
"aggs": {
"Sum": {
"nested": {
"path": "interactionInfo"
},
"aggs": {
"Sum": {
"sum": {
"script": "Integer.parseInt(doc['interactionInfo.value.keyword'].value)"
}
}
}
}
}
Along with the response i am getting reason in the JSON
"reason": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)",
"java.lang.Integer.parseInt(Integer.java:592)",
"java.lang.Integer.parseInt(Integer.java:615)",
"Integer.parseInt(doc['interactionInfo.value.keyword'].value)",
" ^---- HERE"
],
"script": "Integer.parseInt(doc['interactionInfo.value.keyword'].value)",
"lang": "painless",
"caused_by": {
"type": "number_format_exception",
"reason": """For input string: """""
}
}
is there any other way to avoid the reason in the response
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.