Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bripkens/lucene
Node.js lib to transform: lucene query → syntax tree → lucene query
https://github.com/bripkens/lucene
formatter grammar lucene parser peg querystring stringify
Last synced: 4 days ago
JSON representation
Node.js lib to transform: lucene query → syntax tree → lucene query
- Host: GitHub
- URL: https://github.com/bripkens/lucene
- Owner: bripkens
- License: mit
- Created: 2017-01-09T08:30:06.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-07-11T06:55:56.000Z (5 months ago)
- Last Synced: 2024-11-30T07:08:28.439Z (12 days ago)
- Topics: formatter, grammar, lucene, parser, peg, querystring, stringify
- Language: JavaScript
- Homepage:
- Size: 416 KB
- Stars: 74
- Watchers: 5
- Forks: 33
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome - lucene - Node.js lib to transform: lucene query → syntax tree → lucene query (JavaScript)
README
# lucene [![Build Status](https://travis-ci.org/bripkens/lucene.svg?branch=master)](https://travis-ci.org/bripkens/lucene) [![Coverage Status](https://img.shields.io/coveralls/bripkens/lucene.svg)](https://coveralls.io/r/bripkens/lucene?branch=master) [![npm version](https://badge.fury.io/js/lucene.svg)](https://badge.fury.io/js/lucene)
Parse, modify and stringify lucene queries.
**[Installation](#installation) |**
**[Try It](https://runkit.com/npm/lucene) |**
**[Usage](#usage) |**
**[Grammar](#grammar) |**
**[History](#history)**---
## Installation
```
npm install --save lucene
-or-
yarn add lucene
```## Usage
```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
```## Grammar
The parser is auto-generated from a PEG implementation in JavaScript called [PEG.js](https://pegjs.org/).To test the grammar without using the generated parser, or if you want to modify it, try out [PEG.js online](http://pegjs.org/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.
## History
This project is based on [thoward/lucene-query-parser.js](https://github.com/thoward/lucene-query-parser.js) and its forks (most notably [xomyaq/lucene-queryparser](https://github.com/xomyaq/lucene-queryparser)). The project is forked to allow some broader changes to the API surface area, project structure and additional capabilities.