engineering.gosquared.com engineering.gosquared.com

Authoring Elasticsearch queries in Javascript

To search something in Elasticsearch, the request looks like this: POST https://es-cluster:9200/index-name/_search The query definition is sent as JSON in the body of the request. Here’s an example search body: We have found it’s quite useful to put queries together using the improved object literal syntax of more recent versions of JavaScript: This script shows how we might build the search body for the previous request. In the...