【发布时间】:2019-04-04 14:41:39
【问题描述】:
我在 CentOs 7 机器上运行了 elasticsearch 6.7,并且从我尝试查询弹性搜索的地方运行 node-red。
当我需要将数据 POST 到服务器,或者当我需要执行简单的 GET _search 查询时,使用 httprequest 节点(红色节点)非常有用,我可以简单地在 url 中发送参数,例如:
http://xxx.xxx.xxx.xxx:9200/data/default/_search?size={{{size}}}&from={{{from}}}&q=sensor:temp
如this question中所述。
但是,如果我需要具有嵌套参数的更复杂的查询,我无法通过 url 使用参数执行它。 例如,我将如何使用 node-red 中的 httprequest 节点制作这个 cURL GET:
curl -XGET "http://xxx.xxx.xxx.xxx:9200/data/default/_search" -H 'Content-Type: application/json' -d'
{
"size": 0,
"query": {
"range":{
"created":{
"gte":"2019-03-11",
"lte":"2019-03-12"
}
}
},
"aggs": {
"status_terms": {
"terms": {
"field": "device.keyword"
},
"aggs": {
"status_stats": {
"stats": {
"field": "value"
}
}
}
}
}
}'
【问题讨论】: