elastic-particles
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -5,3 +5,3 @@ 'use strict'; | ||
/** | ||
* Base elasticsearch aggregation. | ||
* Base elastic aggregation. | ||
* {@link http://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-aggregations.html} | ||
@@ -8,0 +8,0 @@ * TODO: Add script option. |
@@ -5,3 +5,3 @@ 'use strict'; | ||
/** | ||
* Elasticsearch metrics aggregation that calculates an approximate count of distinct values for a field. | ||
* Elastic metrics aggregation that calculates an approximate count of distinct values for a field. | ||
* {@link http://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-aggregations-metrics-cardinality-aggregation.html} | ||
@@ -8,0 +8,0 @@ * @param {string} field Name of field to aggregate on. |
@@ -6,3 +6,3 @@ 'use strict'; | ||
/** | ||
* Elasticsearch multi-bucket aggregation that groups by dates. | ||
* Elastic multi-bucket aggregation that groups by dates. | ||
* {@link http://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-aggregations-bucket-datehistogram-aggregation.html} | ||
@@ -9,0 +9,0 @@ * @param {string} field Name of field to aggregate on. |
@@ -5,3 +5,3 @@ 'use strict'; | ||
/** | ||
* Elasticsearch Filtered Aggregation. | ||
* Elastic Filtered Aggregation. | ||
* {@link http://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-aggregations-bucket-filter-aggregation.html} | ||
@@ -8,0 +8,0 @@ * TODO: Inherit from Aggregation using node util when prototype funcs needed. |
@@ -5,3 +5,3 @@ 'use strict'; | ||
/** | ||
* Elasticsearch Geo Distance Aggregation. | ||
* Elastic Geo Distance Aggregation. | ||
* Abstracted to create concentric rings of uniform radius. | ||
@@ -8,0 +8,0 @@ * TODO: Optionally pass in "ranges" array directly. |
@@ -5,3 +5,3 @@ 'use strict'; | ||
/** | ||
* Elasticsearch metrics aggregation that calculates the max value for the field. | ||
* Elastic metrics aggregation that calculates the max value for the field. | ||
* {@link http://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-aggregations-metrics-max-aggregation.html} | ||
@@ -8,0 +8,0 @@ * @param {string} field Name of field to aggregate on. |
@@ -6,3 +6,3 @@ 'use strict'; | ||
/** | ||
* Elasticsearch Nested Aggregation. | ||
* Elastic Nested Aggregation. | ||
* Wraps other aggregation instances. | ||
@@ -9,0 +9,0 @@ * TODO: allow multiple 'this.aggs' |
@@ -5,3 +5,3 @@ 'use strict'; | ||
/** | ||
* Elasticsearch multi-bucket aggregation that groups by defined ranges. | ||
* Elastic multi-bucket aggregation that groups by defined ranges. | ||
* {@link http://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-aggregations-bucket-range-aggregation.html} | ||
@@ -8,0 +8,0 @@ * @param {string} field Name of field to aggregate on. |
@@ -5,3 +5,3 @@ 'use strict'; | ||
/** | ||
* Elasticsearch metrics aggregation that executes map-reduce style scripts. | ||
* Elastic metrics aggregation that executes map-reduce style scripts. | ||
* {@link http://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-aggregations-metrics-scripted-metric-aggregation.html} | ||
@@ -8,0 +8,0 @@ * @param {object} scripts Scripts object containing map-reduce logic. |
@@ -5,3 +5,3 @@ 'use strict'; | ||
/** | ||
* Elasticsearch metrics aggregation that calculates an approximate count of distinct values for a field. | ||
* Elastic metrics aggregation that calculates an approximate count of distinct values for a field. | ||
* {@link http://www.elastic.co/guide/en/elasticsearch/reference/1.x/search-aggregations-metrics-cardinality-aggregation.html} | ||
@@ -8,0 +8,0 @@ * @param {string} field Name of field to aggregate on. |
@@ -33,2 +33,17 @@ 'use strict'; | ||
/** | ||
* Sends a query to elasticsearch _search endpoint for given index and type. | ||
* Does not parse | ||
* @param {string} index Elasticsearch index used. | ||
* @param {string} type Elasticsearch type to query. | ||
* @param {string} body Elasticsearch query body. String-form JSON. | ||
* @param {string} queryString Querystring to append to _search. Include the '?'. | ||
* @return {Promise(string)} Unparsed JSON response from elastic. | ||
*/ | ||
function executeQuickSearch(index, type, body, queryString) { | ||
var path = index + '/' + type + '/_search' + (queryString || ''); | ||
return Promise.resolve(httpPost(path, body)) | ||
.then(readRawBytes); | ||
} | ||
/** | ||
@@ -185,2 +200,3 @@ * Sends a count query to elasticsearch _search endpoint for given index and type. | ||
executeSearch: executeSearch, | ||
executeQuickSearch: executeQuickSearch, | ||
executeCount: executeCount, | ||
@@ -187,0 +203,0 @@ executeScroll: executeScroll, |
'use strict'; | ||
function ElasticQuery() { | ||
this._filter = null; | ||
this._query = undefined; | ||
@@ -20,2 +21,11 @@ this._size = undefined; | ||
*/ | ||
ElasticQuery.prototype.setQuery = function setQuery(query) { | ||
this._query = query; | ||
return this; | ||
}; | ||
/** | ||
* Sets the query filter to an instance of an Elastic Filter.] | ||
* @param {Filter} filter instance of ./elasticsearch/filters filter. | ||
*/ | ||
ElasticQuery.prototype.setFilter = function setFilter(filter) { | ||
@@ -88,2 +98,5 @@ this._filter = filter; | ||
// TODO: Implement filtered query. | ||
// Currently creates a filtered query if a filter is set. | ||
if (this._filter) { | ||
@@ -93,2 +106,8 @@ q.query = { 'filtered': { 'filter': this._filter }}; | ||
if (this._query && this._filter) { | ||
q.query.filtered.query = this._query; | ||
} else if (this._query) { | ||
q.query = this._query; | ||
} | ||
if (this._source || typeof this._source === 'boolean') { | ||
@@ -98,3 +117,4 @@ q._source = this._source; | ||
//TODO: Better serialization (without unnecessary whitespace?) | ||
return JSON.stringify(q, null, 4); | ||
}; |
@@ -6,4 +6,4 @@ 'use strict'; | ||
* ElasticSearch boolean filter. | ||
* @param {string} termName If provided, creates a "must" condition on this term. | ||
* @param {any} value If provided, termName must equal this value. | ||
* @param {string} field If provided, creates a "must" condition on this term. | ||
* @param {any} value If provided, field must equal this value. | ||
*/ | ||
@@ -17,7 +17,7 @@ function BoolFilter() { | ||
BoolFilter.prototype.mustEqualTerm = function filterMustEqual(termName, value) { | ||
BoolFilter.prototype.mustEqualTerm = function filterMustEqual(field, value) { | ||
if (value === undefined || value === null) return this; | ||
if (!this.bool.must) this.bool.must = []; | ||
this.bool.must.push(new TermFilter(termName, value)); | ||
this.bool.must.push(new TermFilter(field, value)); | ||
@@ -27,7 +27,7 @@ return this; | ||
BoolFilter.prototype.mustNotEqualTerm = function filterMustNotEqual(termName, value) { | ||
BoolFilter.prototype.mustNotEqualTerm = function filterMustNotEqual(field, value) { | ||
if (value === undefined || value === null) return this; | ||
if (!this.bool.must_not) this.bool.must_not = []; | ||
this.bool.must_not.push(new TermFilter(termName, value)); | ||
this.bool.must_not.push(new TermFilter(field, value)); | ||
@@ -55,7 +55,7 @@ return this; | ||
BoolFilter.prototype.shouldEqual = function shouldEqual(termName, value) { | ||
BoolFilter.prototype.shouldEqual = function shouldEqual(field, value) { | ||
if (value === undefined || value === null) return this; | ||
if (!this.bool.should) this.bool.should = []; | ||
this.bool.should.push(new TermFilter(termName, value)); | ||
this.bool.should.push(new TermFilter(field, value)); | ||
@@ -72,4 +72,2 @@ return this; | ||
return this; | ||
}; | ||
//Add remaining methods for the should section of the bool query. It is the most logical place for us to put geographies. | ||
}; |
@@ -6,2 +6,6 @@ 'use strict'; | ||
exports.MultiMatchQuery = require('./queries/multiMatchQuery'); | ||
exports.BoolQuery = require('./queries/boolQuery'); | ||
exports.MatchQuery = require('./queries/matchQuery'); | ||
exports.AndFilter = require('./filters/andFilter'); | ||
@@ -8,0 +12,0 @@ exports.BoolFilter = require('./filters/boolFilter'); |
{ | ||
"name": "elastic-particles", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Building blocks for Elastic queries, filters, and aggregations which can be re-used, combed, and nested.", | ||
@@ -5,0 +5,0 @@ "author": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39975
28
986