Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/joeybaker/lucene-escape-query

Escape a string for a lucene query. Effectively removes all special characters.
https://github.com/joeybaker/lucene-escape-query

Last synced: 6 days ago
JSON representation

Escape a string for a lucene query. Effectively removes all special characters.

Awesome Lists containing this project

README

        

# lucene-escape-query [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-url]][daviddm-image]

Escape a string for a lucene query. Effectively removes all special characters.

**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*

- [Install](#install)
- [Usage](#usage)
- [Methods](#methods)
- [escape `( string)`](#escape-string-string)
- [Tests](#tests)
- [Developing](#developing)
- [Requirements](#requirements)
- [License](#license)

## Install

```sh
npm i -S lucene-escape-query
```

## Usage

```js
var luceneEscapeQuery = require('lucene-escape-query')

luceneEscapeQuery.escape('+Rainbow') // \+Rainbow
```

## Methods
### escape `( string)`
Returns the string passed to it, with [special characters](https://lucene.apache.org/core/2_9_4/queryparsersyntax.html#Escaping Special Characters) escaped.

## Tests
Tests are in [tape](https://github.com/substack/tape) and code coverage is run though [covert](https://github.com/substack/covert).

* `npm test` will run both server and browser tests
* `npm run test-browser` and `npm run test-server` run their respective tests
* `npm run tdd` will run the server tests on every file change.

## Developing
To publish, run `npm run release -- [{patch,minor,major}]`

_NOTE: you might need to `sudo ln -s /usr/local/bin/node /usr/bin/node` to ensure node is in your path for the git hooks to work_

### Requirements
* **npm > 2.0.0** So that passing args to a npm script will work. `npm i -g npm`
* **git > 1.8.3** So that `git push --follow-tags` will work. `brew install git`

## License

Artistic 2.0 © [Joey Baker](https://byjoeybaker.com)

[npm-url]: https://npmjs.org/package/lucene-escape-query
[npm-image]: https://badge.fury.io/js/lucene-escape-query.svg
[travis-url]: https://travis-ci.org/joeybaker/lucene-escape-query
[travis-image]: https://travis-ci.org/joeybaker/lucene-escape-query.svg?branch=master
[daviddm-url]: https://david-dm.org/joeybaker/lucene-escape-query.svg?theme=shields.io
[daviddm-image]: https://david-dm.org/joeybaker/lucene-escape-query