QueryCraft-To-Elasticsearch
Converts a QueryCraft Filter Builder object into the body of an Elasticsearch query.
Installation
npm install --save 'querycraft-to-elasticsearch'
Examples
Suppose we have a collection of data that satisfies the interface
If we want a query the describes the logic:-
first 50 items where
fistName is bob
lastName is doyle OR is not set
assignedTo is anything
list has an item where id is item1
sorted (in ascending order) by the value property of the customField where id is custom1
created less than 5 days ago
We can build build it as easily as:-
.where'firstName', eq'bob'.where'list', findwhere'id', eq'item1'.where'lastName', any.where'createdAt', lt.where'assignedTo', neqnull.setSortFieldId'customFields', 'custom1', 'value'.setSortDirection'ASC'.setLimit50 getContactsfilter.thenconsole.log// -> filtered list of contacts