Elasticsearch 0.0.7

In the spirit of forking the node-red-contrib-elasticsearch features. I have created version 0.0.7

Which adds "Aggregation" Searches https://github.com/ElasticSearchCLITools/node-red-contrib-elasticsearch7

[{"id":"8adbb5ae.cd3218","type":"http in","z":"774729b7.c657f8","name":"","url":"/es-get-mobile-order-count","method":"get","upload":false,"swaggerDoc":"","x":190,"y":40,"wires":[["8c766ae8.89f7a8"]]},{"id":"ce4cd099.d1096","type":"http response","z":"774729b7.c657f8","name":"","statusCode":"200","headers":{"content-type":"text/html"},"x":490,"y":340,"wires":[]},{"id":"181bcf8d.ff021","type":"debug","z":"774729b7.c657f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":490,"y":180,"wires":[]},{"id":"75293443.b00e9c","type":"es-aggregations","z":"774729b7.c657f8","name":"","documentIndex":"index-name","documentType":"","query":"","sort":"","includeFields":"","maxResults":"5","server":"c6e5946f.39a4b8","x":290,"y":180,"wires":[["181bcf8d.ff021","5e41a540.b1fdcc"]]},{"id":"760ee5b4.45acfc","type":"debug","z":"774729b7.c657f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":490,"y":280,"wires":[]},{"id":"5e41a540.b1fdcc","type":"function","z":"774729b7.c657f8","name":"Create output","func":"\nvar pl = msg.payload.aggregations.buckets.buckets.map((b)=>{\n   return { \"host\": b.key, \"count\": b.doc_count };\n});\nmsg.payload= { \"total\": msg.payload.hits.total, hosts: pl, description: \"Elasticsearch Query count order_status=S by host\" }\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":280,"wires":[["ce4cd099.d1096","760ee5b4.45acfc"]]},{"id":"8c766ae8.89f7a8","type":"function","z":"774729b7.c657f8","name":"Set Query","func":"msg.body={\n  \"aggregations\": {\n     \"buckets\": {\n          \"terms\": {\n            \"field\": \"host\",\n            \"size\": 100,\n            \"order\": {\n              \"_count\": \"desc\"\n            }\n          }\n        }\n    \n    \n  },\n  \"query\": {\n    \"bool\": {\n      \"must\": [\n        {\n          \"query_string\": {\n            \"query\": \"some-query-string\",\n            \"analyze_wildcard\": true\n          }\n        },\n        {\n          \"match\": {\n            \"type\": {\n              \"query\": \"type: some-type\",\n              \"type\": \"phrase\"\n            }\n          }\n        },\n        {\n          \"range\": {\n            \"@timestamp\": {\n              \"gte\": \"now-10m\",\n              \"format\": \"epoch_millis\"\n            }\n          }\n        }\n      ],\n      \"must_not\": []\n    }}};\n\nreturn msg;","outputs":1,"noerr":0,"x":300,"y":120,"wires":[["75293443.b00e9c"]]},{"id":"c6e5946f.39a4b8","type":"remote-server","z":"","name":"Tribe","host":"http://es-hostname:9200","timeout":"300000","reqtimeout":"300000"}]

Flow Info

Created 7 years, 9 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • debug (x2)
  • function (x2)
  • http in (x1)
  • http response (x1)
Other

Tags

  • elasticsearch
  • aggregations
  • search
  • query
  • flow
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option