npm

Check out our latest tech talk, "JavaScript Supply Chain Security" presented by VP of Security, Adam Baldwin.Watch it here »

queryparser

1.0.0 • Public • Published

ElasticSearch Query Parser

Library for convert text expression to Query DSL format

Usage

code
const parser = require('./index');
console.log(parser('apple'));
console.log(parser('fruit: apple'));
console.log(parser('cherry AND NOT avocado'));
console.log(parser('olive OR (peach AND NOT "sugar-apple")'));
console.log(parser('NOT "Name field": mango'));
result
{"query":{"match_all":{}},"filter":{"fquery":{"query":{"match":{"_all":{"query":"apple"}}}}}}
{"query":{"match_all":{}},"filter":{"fquery":{"query":{"match":{"fruit":{"query":"apple"}}}}}}
{"query":{"match_all":{}},"filter":{"and":{"filters":[{"fquery":{"query":{"match":{"_all":{"query":"cherry"}}}}},{"not":{"fquery":{"query":{"match":{"_all":{"query":"avocado"}}}}}}]}}}
{"query":{"match_all":{}},"filter":{"or":{"filters":[{"fquery":{"query":{"match":{"_all":{"query":"olive"}}}}},{"and":{"filters":[{"fquery":{"query":{"match":{"_all":{"query":"peach"}}}}},{"not":{"fquery":{"query":{"match":{"_all":{"query":"sugar-apple"}}}}}}]}}]}}}
{"query":{"match_all":{}},"filter":{"not":{"fquery":{"query":{"match":{"Name field":{"query":"mango"}}}}}}}

License

MIT Copyright (c) 2016 Yaroslav Gaponov yaroslav.gaponov@gmail.com

install

npm i queryparser

Downloadsweekly downloads

4

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability