Created
May 3, 2018 11:28
-
-
Save TheDeveloper/2c9f822ae279b378263e5c0df3543daf to your computer and use it in GitHub Desktop.
Building up an Elasticsearch query in JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const secondThing = { term: { field2: 'bar' } }; | |
const firstThing = { term: { field1: 'foo' } }; | |
const filter = [ firstThing, secondThing ]; | |
const bool = { filter }; | |
const query = { bool }; | |
const body = { query }; | |
const params = { | |
index: 'your-index', | |
body | |
}; | |
const result = await es.search(params); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment