Lucene query parser and formatter for JavaScript created using PEG.js
npm install luceneParse, modify and stringify lucene queries.
Installation |
Try It |
Usage |
Grammar |
History
---
```
npm install --save lucene
-or-
yarn add lucene
`javascript
const lucene = require('lucene');
const ast = lucene.parse('name:frank OR job:engineer');
console.log(ast);
// {
// left: {
// field: 'name',
// term: 'frank'
// },
// operator: 'OR',
// right: {
// field: 'job',
// term: 'engineer'
// }
// }
console.log(lucene.toString(ast));
// name:frank OR job:engineer
``
To test the grammar without using the generated parser, or if you want to modify it, try out PEG.js online. This is a handy way to test arbitrary queries and see what the results will be like or debug a problem with the parser for a given piece of data.