search-text-tokenizer
A search query tokeniser inspired by Google.
- Split a space-delimitered query string into an array of terms
- Treat quoted terms as phrases
- Support tagged terms (tag:term)
- Detect excluded terms (-term)
Examples
var tokenizer = ; console;// [ { term: 'red' }, { term: 'bull' } ] var result = console;// [ { term: 'red bull', phrase: true }, { term: 'gives you wings', phrase: true } ] result = console;// [ { term: 'tolkien', tag: 'author' } ] result = console;// [ { term: 'car', exclude: true } ]
Installation
$ npm install search-text-tokenizer
Running test
To run the test suite enter these commands in the project directory.
$ npm install
$ npm test
License
MIT © Tatsuya Oiwa, Dannii Willis, James Anthony Bruno