Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

esq

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esq - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

esq.js

27

bower.json
{
"name": "esq",
"main": "index.js",
"version": "0.0.11",
"homepage": "https://github.com/holidayextras/esq",
"version": "0.0.12",
"description": "Easily build elasticsearch queries",
"authors": [
"Rahul Patel <rahul.patel@holidayextras.com>"
],
"description": "Easily build elasticsearch queries",
"moduleType": [
"amd",
"globals",
"node"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "http://github.com/holidayextras/esq"
},
"main": "esq.js",
"keywords": [

@@ -20,13 +19,13 @@ "elasticsearch",

"queries",
"query",
"elastic",
"search"
"search",
"dsl"
],
"license": "GPL",
"ignore": [
"**/.*",
"examples",
"node_modules",
"bower_components",
"test",
"tests"
"test"
]
}
//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-common-terms-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-constant-score-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-dis-max-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-filtered-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-flt-field-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-flt-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-fuzzy-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-has-child-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-has-parent-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-ids-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-indices-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-match-all-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-match-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-mlt-field-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-prefix-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-range-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-span-first-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-span-multi-term-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-span-near-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-span-not-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-span-or-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-span-term-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-template-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-term-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-top-children-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

//http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html
var ESQ = require('../lib/esq');
var ESQ = require('../esq');
var esq = new ESQ();

@@ -5,0 +5,0 @@

{
"name": "esq",
"version": "0.0.11",
"version": "0.0.12",
"description": "Easily build elasticsearch queries",
"keywords": [
"elasticsearch",
"query",
"querying"
],
"main": "index.js",
"author": "Rahul Patel <rahul.patel@holidayextras.com>",
"license": "MIT",
"repository": {
"type": "git",
"url": "http://github.com/holidayextras/esq"
},
"directories": {
"example": "examples",
"lib": "lib",
"test": "test"
},
"repository": {
"type": "git",
"url": "http://github.com/holidayextras/esq"
},
"main": "esq.js",
"scripts": {
"test": "mocha"
"test": "mocha",
"prepublish": "./node_modules/.bin/uglifyjs ./esq.js --compress --output ./esq.min.js"
},
"author": "Rahul Patel <rahul.patel@holidayextras.com>",
"license": "GPL"
"keywords": [
"elasticsearch",
"esq",
"querying",
"queries",
"query",
"elastic",
"search",
"dsl"
],
"devDependencies": {
"mocha": "^2.1.0",
"uglify-js": "^2.4.16"
}
}

@@ -1,9 +0,17 @@

# ESQ
# ESQ (Elasticsearch Query)
[![Build Status](https://travis-ci.org/holidayextras/esq.png?branch=master)](https://travis-ci.org/holidayextras/esq)
ESQ is a helper module for elasticsearch. It aims to provide an easy way of creating elasticsearch queries. Run `node examples` to see all of the examples from the [elasticsearch docs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-queries.html) generated using esq!
I wanted an easy way to build elasticsearch queries without having to writing lots and lots of code just for the structure of the query. For that reason I created ESQ, a very simple but powerful tool that will do all of the object creation for you.
## Quick Examples
---
## Download
`npm install esq` or `bower intall esq`
---
## Quick Example
__Example__
```javascript

@@ -14,91 +22,32 @@ var ESQ = require('esq');

esq.query('bool', ['must'], { match: { user: 'kimchy' } });
esq.query('bool', ['must_not'], { range: { age: { from: 10, to: 20 } } });
esq.query('bool', ['should'], { term: { tag: 'wow' } });
esq.query('bool', ['should'], { term: { tag: 'elasticsearch' } });
esq.query('bool', 'minimum_should_match', 1);
esq.query('bool', 'boost', 1.0);
// query == {
// "bool": {
// "must": [
// {
// "match": {
// "user": "kimchy"
// }
// }
// ],
// "must_not": [
// {
// "range": {
// "age": {
// "from": 10,
// "to": 20
// }
// }
// }
// ],
// "should": [
// {
// "term": {
// "tag": "wow"
// }
// },
// {
// "term": {
// "tag": "elasticsearch"
// }
// }
// ],
// "minimum_should_match": 1,
// "boost": 1
// }
// }
```
---
```javascript
var ESQ = require('esq');
var esq = new ESQ();
esq.query('query', 'match', 'foo', 'bar');
esq.query('query', 'range', 'x', { gte: 1, lte: 5 });
esq.query('query', 'wildcard', 'test', 'value', 'what*');
var query = esq.getQuery();
// query == {
// "query": {
// "match": {
// "foo": "bar"
// },
// "range": {
// "x": {
// "gte": "1",
// "lte": "5"
// }
// },
// "wildcard": {
// "test": {
// "value": "what*"
// }
// }
// }
// }
```
## Download
__Generates__
```json
{
"bool": {
"must": [
{
"match": {
"user": "kimchy"
}
}
],
"minimum_should_match": 1
}
}
```
npm install esq
```
## In the Browser
---
Currently it's not been tested in any browsers, but i'm sure it'll work with most modern browsers.
## In the browser
Usage:
```
```html
<script src="esq.js"></script>
<script>
var esq = new ESQ();
esq.query('query', { match: { foo: 'bar' } });
esq.query('bool', ['must'], { match: { user: 'kimchy' } });
var query = esq.getQuery();

@@ -108,2 +57,4 @@ </script>

---
## Documentation

@@ -116,3 +67,3 @@

```javascript
esq.query('query', 'match', 'foo', 'bar');
esq.query('bool', ['must'], { match: { foo: 'bar' } });
var query = esq.getQuery();

@@ -122,8 +73,12 @@ ```

__Generates__
```javascript
```json
{
query: {
match: {
foo: 'bar'
}
"bool": {
"must": [
{
"match": {
"foo": "bar"
}
}
]
}

@@ -136,16 +91,16 @@ }

### esq.query(str, ..., str, value);
You can pass this function as many strings as you want and you'll receive a nested object with the arguments as keys. The final argument should always be the value you want to assign to the second to last argument. This function will always return the query at its current state.
You can pass this function as many strings as you want and you'll receive a nested object with the arguments as keys. The final argument should always be the object you want to assign to the second to last argument. This function will always return the query at its current state.
__Example__
```javascript
esq.query('filtered', 'query', { match: { foo: 'bar' } });
```
esq.query('filtered', 'query', 'match', 'foo', 'bar');
```
__Generates__
```javascript
```json
{
filtered: {
query: {
match: {
foo: 'bar'
"filtered": {
"query": {
"match": {
"foo": "bar"
}

@@ -157,19 +112,21 @@ }

The function also allows you to pass in an argument as an array (this array should only be one element). This tells the function that you want that key to be an array and so it'll push the following arguments into the array.
#### Array Arguments
The function also allows you to pass in an argument as an array (e.g. `['must']`). This tells the function that you want that key to be an array and so it'll push the following arguments into the array.
__Example__
```javascript
esq.query('filtered', 'query', 'bool', ['must'], { match: { 'foo': 'bar' } });
```
esq.query('filtered', 'query', 'bool', ['must'], 'match', 'foo', 'bar');
```
__Generates__
```javascript
```json
{
filtered: {
query: {
bool: {
must: [
"filtered": {
"query": {
"bool": {
"must": [
{
match: {
foo: 'bar'
"match": {
"foo": "bar"
}

@@ -183,1 +140,7 @@ }

```
---
## Tests
This module is fully tested, run the tests using `mocha`.
var assert = require('assert');
var ESQ = require('../lib/esq');
var ESQ = require('../esq');

@@ -4,0 +4,0 @@ describe('Testing ESQ', function() {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc