Hi guys,
I have some query(witch works fine in kibana debugger), my goal is to make this query work from curl command line(windows). i have other queries with no issues.
I think the problem is with the """ in the "reduce_script" part. it breaks the json structure.
The working query:
{
"id":"index_compare",
"source":{
"index":[
"mitre",
"winlogbeat-7.14.0-2022.01.06-000001"
],
"query":{
"match_all":{
}
}
},
"dest":{
"index":"compare"
},
"pivot":{
"group_by":{
"unique-id":{
"terms":{
"field":"winlog.event_id"
}
}
},
"aggregations":{
"compare":{
"scripted_metric":{
"map_script":"state.doc = new HashMap(params['_source'])",
"combine_script":"return state",
"reduce_script":"""
if (states.size() != 2) {
return ""count_mismatch""
}
return ""match""
"""
}
}
}
}
}
What i have tried:
command :
curl -XPOST --header "Content-Type: application/json" "http://localhost:9200/_transform/_preview?pretty" -d @2.json
json file:
{
"id": "index_compare",
"source": {
"index": [
"mitre",
"winlogbeat-7.14.0-2022.01.06-000001"
],
"query": {
"match_all": {}
}
},
"dest": {
"index": "compare"
},
"pivot": {
"group_by": {
"unique-id": {
"terms": {
"field": "winlog.event_id"
}
}
},
"aggregations": {
"compare": {
"scripted_metric": {
"map_script": "state.doc = new HashMap(params['_source'])",
"combine_script": "return state",
"reduce_script": """
if (states.size() != 2) {
return "count_mismatch"
}
return "match"
"""
}
}
}
}
}
Any ideas?