Giter Club home page Giter Club logo

lucene-query-parser's Introduction

Lucene Query Parser for Javascript

This is an implementation of the Lucene Query Parser developed using PEG.js.

Example

A quick example of how to use it:

// return the expression tree
var results = lucenequeryparser.parse('title:"The Right Way" AND text:go');

alert(results['left']['field']);      // title
alert(results['left']['term']);       // The Right Way
alert(results['operator']);           // AND
alert(results['right']['field']);     // text
alert(results['right']['term']);      // go

A slightly more complicated example:

// return the expression tree
var results = lucenequeryparser.parse('test AND (foo OR bar)');

alert(results['left']['term']);       // test
alert(results['operator']);           // AND

// the parantheses group becomes it's own nested node
var rightNode = results['right'];

alert(rightNode['left']['term']);     // foo
alert(rightNode['operator']);         // OR
alert(rightNode['right']['term']);    // bar

Unit Tests

To run the unit tests, just open SpecRunner.html in any browser. Unit tests are built with Jasmine.

Grammar

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 an abritrary query and see what the results will be like or debug a problem with the parser for a given piece of data.

Community

If you'd like to help out with the project, or if you have a question, feel free to contact Troy Howard at [email protected].

Bug reports or feature requests should go in the bitbucket issue tracker. Please include relevant sample data (the query) and a good description of the challenges you're facing.

Look to the wiki for documentation and other resources.

lucene-query-parser's People

Contributors

mahnunchik avatar matthiasg avatar thoward avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.