1.0.0 • Published 8 years ago

simple-dsl v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

Simple DSL

Last version Build Status Dependency status Dev Dependencies Status NPM Status Donate

Simple DSL based on <key,value> designed to work together fulltext search engines.

Why

  • Converts a unstructured input into a structued output.
  • Makes easy connect with fulltext search engines such as Solr, ElasticSearch, MongoDB, etc.
  • Less than 2KB.

I designed this solution for create a rapid and quickly DSL for fulltext search.

It is inspired in other solutions, such as Github Search Engine but out of the box.

Install

$ npm install simple-dsl --save

If you want to use in the browser (powered by Browserify):

$ bower install simple-dsl --save

and later link in your HTML:

<script src="bower_components/simple-dsl/dist/simple-dsl.js"></script>

Usage

Basically the DSL works detecting <key, value> patterns:

const dsl = require('simple-dsl')
dsl('is:issue status:closed bug fixed')
// {
//   is: 'issue',
//   status: 'closed',
//   text: 'bug fixed'
// }

When you don't provide a <key, value> pattern (in this example bug fixed don't follow the format) you are creating a text value.

You can declare multiple values with the same key:

const dsl = require('simple-dsl')
dsl('user:kiko user:javier status:closed bug fixed')
// {
//   is: 'issue',
//   status: 'closed',
//   user: ['kiko', 'javier']
//   text: 'bug fixed'
// }

If you want to use spaces, use inside quotes:

const dsl = require('simple-dsl')
dsl('user:"kiko beats" user:"javier baena" status:closed bug fixed')
// {
//   is: 'issue',
//   status: 'closed',
//   user: ['kiko beats', 'javier baena']
//   text: 'bug fixed'
// }

License

MIT © Kiko Beats