Skip to content

Instantly share code, notes, and snippets.

@TheDeveloper
Created May 3, 2018 11:28
Show Gist options
  • Save TheDeveloper/2c9f822ae279b378263e5c0df3543daf to your computer and use it in GitHub Desktop.
Save TheDeveloper/2c9f822ae279b378263e5c0df3543daf to your computer and use it in GitHub Desktop.
Building up an Elasticsearch query in JS
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