Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including lucene with all npm packages installed. Try it out:

var lucene = require("lucene")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

lucene v2.1.1

Lucene query parser and formatter for JavaScript created using PEG.js

lucene   Build Status Dependency Status Coverage Status npm version

Parse, modify and stringify lucene queries.

Installation | Try It | Usage | Grammar | History


npm install --save lucene
yarn add lucene


const lucene = require('lucene');

const ast = lucene.parse('name:frank OR job:engineer');
// {
//   left: {
//     field: 'name',
//     term: 'frank'
//   },
//   operator: 'OR',
//   right: {
//     field: 'job',
//     term: 'engineer'
//   }
// }

// name:frank OR job:engineer


The parser is auto-generated from a PEG implementation in JavaScript called PEG.js.

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.


This project is based on thoward/lucene-query-parser.js and its forks (most notably xomyaq/lucene-queryparser). The project is forked to allow some broader changes to the API surface area, project structure and additional capabilities.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free