diff --git a/dist/elastic.js b/dist/elastic.js index 726d076..35717f9 100644 --- a/dist/elastic.js +++ b/dist/elastic.js @@ -1,4 +1,4 @@ -/*! elastic.js - v1.1.1 - 2014-03-20 +/*! elastic.js - v1.1.1 - 2014-03-21 * https://github.com/fullscale/elastic.js * Copyright (c) 2014 FullScale Labs, LLC; Licensed MIT */ @@ -9342,567 +9342,161 @@ /** @class -
A query allows to wrap another query and multiply its score by the - provided boost_factor. This can sometimes be desired since boost value set - on specific queries gets normalized, while this query boost factor does not.
+ A query that generates the union of documents produced by its subqueries, and + that scores each document with the maximum score for that document as produced + by any subquery, plus a tie breaking increment for any additional matching + subqueries. - @name ejs.CustomBoostFactorQuery + @name ejs.DisMaxQuery @ejs query @borrows ejs.QueryMixin.boost as boost @borrows ejs.QueryMixin._type as _type @borrows ejs.QueryMixin.toJSON as toJSON @desc - Boosts a queries score without that boost being normalized. + A query that generates the union of documents produced by its subqueries such + astermQuerys, phraseQuerys
, boolQuerys
, etc.
- @param {Object} qry A valid query object.
*/
- ejs.CustomBoostFactorQuery = function (qry) {
+ ejs.DisMaxQuery = function () {
- if (!isQuery(qry)) {
- throw new TypeError('Argument must be a Query');
- }
-
- var
- _common = ejs.QueryMixin('custom_boost_factor'),
+ var
+ _common = ejs.QueryMixin('dis_max'),
query = _common.toJSON();
-
- query.custom_boost_factor.query = qry.toJSON();
return extend(_common, {
/**
- Sets the query to be apply the custom boost to.
+ Updates the queries. If passed a single Query, it is added to the
+ list of existing queries. If passed an array of Queries, it
+ replaces all existing values.
- @member ejs.CustomBoostFactorQuery
- @param {Object} q A valid Query object
+ @member ejs.DisMaxQuery
+ @param {(Query|Query[])} qs A single Query or an array of Queries
@returns {Object} returns this
so that calls can be chained.
*/
- query: function (q) {
- if (q == null) {
- return query.custom_boost_factor.query;
- }
-
- if (!isQuery(q)) {
- throw new TypeError('Argument must be a Query');
- }
+ queries: function (qs) {
+ var i, len;
- query.custom_boost_factor.query = q.toJSON();
- return this;
- },
-
- /**
- Sets the language used in the script.
-
- @member ejs.CustomBoostFactorQuery
- @param {Double} boost The boost value.
- @returns {Object} returns this
so that calls can be chained.
- */
- boostFactor: function (boost) {
- if (boost == null) {
- return query.custom_boost_factor.boost_factor;
+ if (qs == null) {
+ return query.dis_max.queries;
}
-
- query.custom_boost_factor.boost_factor = boost;
- return this;
- }
-
- });
- };
-
- /**
- @class
- A custom_filters_score query allows to execute a query, and if the hit - matches a provided filter (ordered), use either a boost or a script - associated with it to compute the score.
- -This can considerably simplify and increase performance for parameterized - based scoring since filters are easily cached for faster performance, and - boosting / script is considerably simpler.
- - @name ejs.CustomFiltersScoreQuery - @ejs query - @borrows ejs.QueryMixin.boost as boost - @borrows ejs.QueryMixin._type as _type - @borrows ejs.QueryMixin.toJSON as toJSON - - @desc - Returned documents matched by the query and scored based on if the document - matched in a filter. - - @param {Query} qry A valid query object. - @param {(Object|Object[])} filters A single object or array of object. Each - object must have a 'filter' property and either a 'boost' or 'script' - property. - */ - ejs.CustomFiltersScoreQuery = function (qry, filters) { - - if (!isQuery(qry)) { - throw new TypeError('Argument must be a Query'); - } - - var - _common = ejs.QueryMixin('custom_filters_score'), - query = _common.toJSON(), - - // generate a valid filter object that can be inserted into the filters - // array. Returns null when an invalid filter is passed in. - genFilterObject = function (filter) { - var obj = null; - - if (filter.filter && isFilter(filter.filter)) { - obj = { - filter: filter.filter.toJSON() - }; - if (filter.boost) { - obj.boost = filter.boost; - } else if (filter.script) { - obj.script = filter.script; - } else { - // invalid filter, must boost or script must be specified - obj = null; - } - } - - return obj; - }; - - query.custom_filters_score.query = qry.toJSON(); - query.custom_filters_score.filters = []; - - each((isArray(filters) ? filters : [filters]), function (filter) { - var fObj = genFilterObject(filter); - if (fObj !== null) { - query.custom_filters_score.filters.push(fObj); - } - }); - - return extend(_common, { - - /** - Sets the query to be apply the custom boost to. - - @member ejs.CustomFiltersScoreQuery - @param {Object} q A valid Query object - @returns {Object} returnsthis
so that calls can be chained.
- */
- query: function (q) {
- if (q == null) {
- return query.custom_filters_score.query;
- }
-
- if (!isQuery(q)) {
- throw new TypeError('Argument must be a Query');
- }
-
- query.custom_filters_score.query = q.toJSON();
- return this;
- },
-
- /**
- Sets the filters and their related boost or script scoring method.
- -Takes an array of objects where each object has a 'filter' property - and either a 'boost' or 'script' property. Pass a single object to - add to the current list of filters or pass a list of objects to - overwrite all existing filters.
- -
- {filter: someFilter, boost: 2.1}
-
-
- @member ejs.CustomFiltersScoreQuery
- @param {(Object|Object[])} fltrs An object or array of objects
- contining a filter and either a boost or script property.
- @returns {Object} returns this
so that calls can be chained.
- */
- filters: function (fltrs) {
- if (fltrs == null) {
- return query.custom_filters_score.filters;
- }
-
- if (isArray(fltrs)) {
- query.custom_filters_score.filters = [];
+ if (query.dis_max.queries == null) {
+ query.dis_max.queries = [];
}
- each((isArray(fltrs) ? fltrs : [fltrs]), function (f) {
- var fObj = genFilterObject(f);
- if (fObj !== null) {
- query.custom_filters_score.filters.push(fObj);
+ if (isQuery(qs)) {
+ query.dis_max.queries.push(qs.toJSON());
+ } else if (isArray(qs)) {
+ query.dis_max.queries = [];
+ for (i = 0, len = qs.length; i < len; i++) {
+ if (!isQuery(qs[i])) {
+ throw new TypeError('Argument must be array of Queries');
+ }
+
+ query.dis_max.queries.push(qs[i].toJSON());
}
- });
-
- return this;
- },
-
- /**
- A score_mode can be defined to control how multiple matching - filters control the score.
- -
By default, it is set to first which means the first matching filter
- will control the score of the result. It can also be set to
- min/max/total/avg/multiply
which will aggregate the result from all
- matching filters based on the aggregation type.
-
- @member ejs.CustomFiltersScoreQuery
- @param {String} s The scoring type as a string.
- @returns {Object} returns this
so that calls can be chained.
- */
- scoreMode: function (s) {
- if (s == null) {
- return query.custom_filters_score.score_mode;
+ } else {
+ throw new TypeError('Argument must be a Query or array of Queries');
}
- s = s.toLowerCase();
- if (s === 'first' || s === 'min' || s === 'max' || s === 'total' || s === 'avg' || s === 'multiply') {
- query.custom_filters_score.score_mode = s;
- }
-
return this;
},
-
- /**
- Sets parameters that will be applied to the script. Overwrites
- any existing params.
- @member ejs.CustomFiltersScoreQuery
- @param {Object} q An object where the keys are the parameter name and
- values are the parameter value.
- @returns {Object} returns this
so that calls can be chained.
- */
- params: function (p) {
- if (p == null) {
- return query.custom_filters_score.params;
- }
-
- query.custom_filters_score.params = p;
- return this;
- },
-
/**
- Sets the language used in the script.
-
- @member ejs.CustomFiltersScoreQuery
- @param {String} l The script language, defatuls to mvel.
- @returns {Object} returns this
so that calls can be chained.
- */
- lang: function (l) {
- if (l == null) {
- return query.custom_filters_score.lang;
- }
+
The tie breaker value.
- query.custom_filters_score.lang = l; - return this; - }, +The tie breaker capability allows results that include the same term in multiple + fields to be judged better than results that include this term in only the best of those + multiple fields, without confusing this with the better case of two different terms in + the multiple fields.
- /** - Sets the maximum value a computed boost can reach. +Default: 0.0.
- @member ejs.CustomFiltersScoreQuery - @param {Double} max A positivedouble
value.
+ @member ejs.DisMaxQuery
+ @param {Double} tieBreaker A positive double
value.
@returns {Object} returns this
so that calls can be chained.
*/
- maxBoost: function (max) {
- if (max == null) {
- return query.custom_filters_score.max_boost;
+ tieBreaker: function (tieBreaker) {
+ if (tieBreaker == null) {
+ return query.dis_max.tie_breaker;
}
- query.custom_filters_score.max_boost = max;
+ query.dis_max.tie_breaker = tieBreaker;
return this;
}
});
};
+
/**
@class
- A query that wraps another query and customize the scoring of it - optionally with a computation derived from other field values in the - doc (numeric ones) using script expression.
+Wrapper to allow SpanQuery objects participate in composite single-field + SpanQueries by 'lying' about their search field. That is, the masked + SpanQuery will function as normal, but when asked for the field it + queries against, it will return the value specified as the masked field vs. + the real field used in the wrapped span query.
- @name ejs.CustomScoreQuery + @name ejs.FieldMaskingSpanQuery @ejs query @borrows ejs.QueryMixin.boost as boost @borrows ejs.QueryMixin._type as _type @borrows ejs.QueryMixin.toJSON as toJSON @desc - Scores a query based on a script. + Wraps a SpanQuery and hides the real field being searched across. - @param {Object} qry A valid query or filter object. - @param {String} script A valid script expression. + @param {Query} spanQry A valid SpanQuery + @param {Integer} field the maximum field position in a match. + */ - ejs.CustomScoreQuery = function (qry, script) { + ejs.FieldMaskingSpanQuery = function (spanQry, field) { - if (!isQuery(qry) && !isFilter(qry)) { - throw new TypeError('Argument must be a Query or Filter'); + if (!isQuery(spanQry)) { + throw new TypeError('Argument must be a SpanQuery'); } - + var - _common = ejs.QueryMixin('custom_score'), + _common = ejs.QueryMixin('field_masking_span'), query = _common.toJSON(); - query.custom_score.script = script; + query.field_masking_span.query = spanQry.toJSON(); + query.field_masking_span.field = field; - if (isQuery(qry)) { - query.custom_score.query = qry.toJSON(); - } else if (isFilter(qry)) { - query.custom_score.filter = qry.toJSON(); - } - return extend(_common, { /** - Sets the query to apply the custom score to. - - @member ejs.CustomScoreQuery - @param {Object} q A valid Query object - @returns {Object} returnsthis
so that calls can be chained.
- */
- query: function (q) {
- if (q == null) {
- return query.custom_score.query;
- }
-
- if (!isQuery(q)) {
- throw new TypeError('Argument must be a Query');
- }
-
- query.custom_score.query = q.toJSON();
- return this;
- },
-
- /**
- Sets the filter to apply the custom score to.
+ Sets the span query to wrap.
- @member ejs.CustomScoreQuery
- @param {Object} f A valid Filter object
+ @member ejs.FieldMaskingSpanQuery
+ @param {Query} spanQuery Any valid span type query.
@returns {Object} returns this
so that calls can be chained.
*/
- filter: function (f) {
- if (f == null) {
- return query.custom_score.filter;
- }
-
- if (!isFilter(f)) {
- throw new TypeError('Argument must be a Filter');
+ query: function (spanQuery) {
+ if (spanQuery == null) {
+ return query.field_masking_span.query;
}
-
- query.custom_score.filter = f.toJSON();
- return this;
- },
-
- /**
- Sets the script that calculates the custom score
-
- @member ejs.CustomScoreQuery
- @param {String} s A valid script expression
- @returns {Object} returns this
so that calls can be chained.
- */
- script: function (s) {
- if (s == null) {
- return query.custom_score.script;
+
+ if (!isQuery(spanQuery)) {
+ throw new TypeError('Argument must be a SpanQuery');
}
- query.custom_score.script = s;
+ query.field_masking_span.query = spanQuery.toJSON();
return this;
},
/**
- Sets parameters that will be applied to the script. Overwrites
- any existing params.
+ Sets the value of the "masked" field.
- @member ejs.CustomScoreQuery
- @param {Object} p An object where the keys are the parameter name and
- values are the parameter value.
+ @member ejs.FieldMaskingSpanQuery
+ @param {String} f A field name the wrapped span query should use
@returns {Object} returns this
so that calls can be chained.
*/
- params: function (p) {
- if (p == null) {
- return query.custom_score.params;
- }
-
- query.custom_score.params = p;
- return this;
- },
-
- /**
- Sets the language used in the script.
-
- @member ejs.CustomScoreQuery
- @param {String} l The script language, defatuls to mvel.
- @returns {Object} returns this
so that calls can be chained.
- */
- lang: function (l) {
- if (l == null) {
- return query.custom_score.lang;
- }
-
- query.custom_score.lang = l;
- return this;
- }
-
- });
- };
-
- /**
- @class
- A query that generates the union of documents produced by its subqueries, and
- that scores each document with the maximum score for that document as produced
- by any subquery, plus a tie breaking increment for any additional matching
- subqueries.
-
- @name ejs.DisMaxQuery
- @ejs query
- @borrows ejs.QueryMixin.boost as boost
- @borrows ejs.QueryMixin._type as _type
- @borrows ejs.QueryMixin.toJSON as toJSON
-
- @desc
- A query that generates the union of documents produced by its subqueries such
- as termQuerys, phraseQuerys
, boolQuerys
, etc.
-
- */
- ejs.DisMaxQuery = function () {
-
- var
- _common = ejs.QueryMixin('dis_max'),
- query = _common.toJSON();
-
- return extend(_common, {
-
- /**
- Updates the queries. If passed a single Query, it is added to the
- list of existing queries. If passed an array of Queries, it
- replaces all existing values.
-
- @member ejs.DisMaxQuery
- @param {(Query|Query[])} qs A single Query or an array of Queries
- @returns {Object} returns this
so that calls can be chained.
- */
- queries: function (qs) {
- var i, len;
-
- if (qs == null) {
- return query.dis_max.queries;
- }
-
- if (query.dis_max.queries == null) {
- query.dis_max.queries = [];
- }
-
- if (isQuery(qs)) {
- query.dis_max.queries.push(qs.toJSON());
- } else if (isArray(qs)) {
- query.dis_max.queries = [];
- for (i = 0, len = qs.length; i < len; i++) {
- if (!isQuery(qs[i])) {
- throw new TypeError('Argument must be array of Queries');
- }
-
- query.dis_max.queries.push(qs[i].toJSON());
- }
- } else {
- throw new TypeError('Argument must be a Query or array of Queries');
- }
-
- return this;
- },
-
- /**
- The tie breaker value.
- -The tie breaker capability allows results that include the same term in multiple - fields to be judged better than results that include this term in only the best of those - multiple fields, without confusing this with the better case of two different terms in - the multiple fields.
- -Default: 0.0.
- - @member ejs.DisMaxQuery - @param {Double} tieBreaker A positivedouble
value.
- @returns {Object} returns this
so that calls can be chained.
- */
- tieBreaker: function (tieBreaker) {
- if (tieBreaker == null) {
- return query.dis_max.tie_breaker;
- }
-
- query.dis_max.tie_breaker = tieBreaker;
- return this;
- }
-
- });
- };
-
-
- /**
- @class
- Wrapper to allow SpanQuery objects participate in composite single-field - SpanQueries by 'lying' about their search field. That is, the masked - SpanQuery will function as normal, but when asked for the field it - queries against, it will return the value specified as the masked field vs. - the real field used in the wrapped span query.
- - @name ejs.FieldMaskingSpanQuery - @ejs query - @borrows ejs.QueryMixin.boost as boost - @borrows ejs.QueryMixin._type as _type - @borrows ejs.QueryMixin.toJSON as toJSON - - @desc - Wraps a SpanQuery and hides the real field being searched across. - - @param {Query} spanQry A valid SpanQuery - @param {Integer} field the maximum field position in a match. - - */ - ejs.FieldMaskingSpanQuery = function (spanQry, field) { - - if (!isQuery(spanQry)) { - throw new TypeError('Argument must be a SpanQuery'); - } - - var - _common = ejs.QueryMixin('field_masking_span'), - query = _common.toJSON(); - - query.field_masking_span.query = spanQry.toJSON(); - query.field_masking_span.field = field; - - return extend(_common, { - - /** - Sets the span query to wrap. - - @member ejs.FieldMaskingSpanQuery - @param {Query} spanQuery Any valid span type query. - @returns {Object} returnsthis
so that calls can be chained.
- */
- query: function (spanQuery) {
- if (spanQuery == null) {
- return query.field_masking_span.query;
- }
-
- if (!isQuery(spanQuery)) {
- throw new TypeError('Argument must be a SpanQuery');
- }
-
- query.field_masking_span.query = spanQuery.toJSON();
- return this;
- },
-
- /**
- Sets the value of the "masked" field.
-
- @member ejs.FieldMaskingSpanQuery
- @param {String} f A field name the wrapped span query should use
- @returns {Object} returns this
so that calls can be chained.
- */
- field: function (f) {
- if (f == null) {
- return query.field_masking_span.field;
+ field: function (f) {
+ if (f == null) {
+ return query.field_masking_span.field;
}
query.field_masking_span.field = f;
@@ -9912,470 +9506,6 @@
});
};
- /**
- @class
- A query that executes against a given field or document property. It is a simplified version
- of the queryString
object.
-
- @name ejs.FieldQuery
- @ejs query
- @borrows ejs.QueryMixin._type as _type
- @borrows ejs.QueryMixin.toJSON as toJSON
-
- @desc
- A query that executes against a given field or document property.
-
- @param {String} field The field or document property to search against.
- @param {String} qstr The value to match.
- */
- ejs.FieldQuery = function (field, qstr) {
-
- var
- _common = ejs.QueryMixin('field'),
- query = _common.toJSON();
-
- query.field[field] = {
- query: qstr
- };
-
- return extend(_common, {
-
- /**
- The field to run the query against.
-
- @member ejs.FieldQuery
- @param {String} f A single field name.
- @returns {Object} returns this
so that calls can be chained.
- */
- field: function (f) {
- var oldValue = query.field[field];
-
- if (f == null) {
- return field;
- }
-
- delete query.field[field];
- field = f;
- query.field[f] = oldValue;
-
- return this;
- },
-
- /**
- Sets the query string.
- - @member ejs.FieldQuery - @param {String} q The lucene query string. - @returns {Object} returnsthis
so that calls can be chained.
- */
- query: function (q) {
- if (q == null) {
- return query.field[field].query;
- }
-
- query.field[field].query = q;
- return this;
- },
-
- /**
- Set the default Boolean
operator.
This operator is used to join individual query terms when no operator is
- explicity used in the query string (i.e., this AND that
).
- Defaults to OR
.
this
so that calls can be chained.
- */
- defaultOperator: function (op) {
- if (op == null) {
- return query.field[field].default_operator;
- }
-
- op = op.toUpperCase();
- if (op === 'AND' || op === 'OR') {
- query.field[field].default_operator = op;
- }
-
- return this;
- },
-
- /**
- Sets the analyzer name used to analyze the Query
object.
this
so that calls can be chained.
- */
- analyzer: function (analyzer) {
- if (analyzer == null) {
- return query.field[field].analyzer;
- }
-
- query.field[field].analyzer = analyzer;
- return this;
- },
-
- /**
- Sets the quote analyzer name used to analyze the query
- when in quoted text.
this
so that calls can be chained.
- */
- quoteAnalyzer: function (analyzer) {
- if (analyzer == null) {
- return query.field[field].quote_analyzer;
- }
-
- query.field[field].quote_analyzer = analyzer;
- return this;
- },
-
- /**
- Sets whether or not we should auto generate phrase queries *if* the - analyzer returns more than one term. Default: false.
- - @member ejs.FieldQuery - @param {Boolean} trueFalse Atrue/false
value.
- @returns {Object} returns this
so that calls can be chained.
- */
- autoGeneratePhraseQueries: function (trueFalse) {
- if (trueFalse == null) {
- return query.field[field].auto_generate_phrase_queries;
- }
-
- query.field[field].auto_generate_phrase_queries = trueFalse;
- return this;
- },
-
- /**
- Sets whether or not wildcard characters (* and ?) are allowed as the
- first character of the Query
.
Default: true
.
true/false
value.
- @returns {Object} returns this
so that calls can be chained.
- */
- allowLeadingWildcard: function (trueFalse) {
- if (trueFalse == null) {
- return query.field[field].allow_leading_wildcard;
- }
-
- query.field[field].allow_leading_wildcard = trueFalse;
- return this;
- },
-
- /**
- Sets whether or not terms from wildcard, prefix, fuzzy,
and
- range
queries should automatically be lowercased in the Query
- since they are not analyzed.
Default: true
.
true/false
value.
- @returns {Object} returns this
so that calls can be chained.
- */
- lowercaseExpandedTerms: function (trueFalse) {
- if (trueFalse == null) {
- return query.field[field].lowercase_expanded_terms;
- }
-
- query.field[field].lowercase_expanded_terms = trueFalse;
- return this;
- },
-
- /**
- Sets whether or not position increments will be used in the
- Query
.
Default: true
.
true/false
value.
- @returns {Object} returns this
so that calls can be chained.
- */
- enablePositionIncrements: function (trueFalse) {
- if (trueFalse == null) {
- return query.field[field].enable_position_increments;
- }
-
- query.field[field].enable_position_increments = trueFalse;
- return this;
- },
-
- /**
- Set the minimum similarity for fuzzy queries.
- -Default: 0.5
.
double
value between 0 and 1.
- @returns {Object} returns this
so that calls can be chained.
- */
- fuzzyMinSim: function (minSim) {
- if (minSim == null) {
- return query.field[field].fuzzy_min_sim;
- }
-
- query.field[field].fuzzy_min_sim = minSim;
- return this;
- },
-
- /**
- Sets the prefix length for fuzzy queries.
- -Default: 0
.
integer
value.
- @returns {Object} returns this
so that calls can be chained.
- */
- fuzzyPrefixLength: function (fuzzLen) {
- if (fuzzLen == null) {
- return query.field[field].fuzzy_prefix_length;
- }
-
- query.field[field].fuzzy_prefix_length = fuzzLen;
- return this;
- },
-
- /**
- Sets the max number of term expansions for fuzzy queries.
- - @member ejs.FieldQuery - @param {Integer} max A positiveinteger
value.
- @returns {Object} returns this
so that calls can be chained.
- */
- fuzzyMaxExpansions: function (max) {
- if (max == null) {
- return query.field[field].fuzzy_max_expansions;
- }
-
- query.field[field].fuzzy_max_expansions = max;
- return this;
- },
-
- /**
- Sets fuzzy rewrite method.
- -
Valid values are:
- -constant_score_auto
- tries to pick the best constant-score rewrite
- method based on term and document counts from the queryscoring_boolean
- translates each term into boolean should and
- keeps the scores as computed by the queryconstant_score_boolean
- same as scoring_boolean, expect no scores
- are computed.constant_score_filter
- first creates a private Filter, by visiting
- each term in sequence and marking all docs for that termtop_terms_boost_N
- first translates each term into boolean should
- and scores are only computed as the boost using the top N
- scoring terms. Replace N
with an integer value.top_terms_N
- first translates each term into boolean should
- and keeps the scores as computed by the query. Only the top N
- scoring terms are used. Replace N
with an integer value.Default is constant_score_auto
.
This is an advanced option, use with care.
- - @member ejs.FieldQuery - @param {String} m The rewrite method as a string. - @returns {Object} returnsthis
so that calls can be chained.
- */
- fuzzyRewrite: function (m) {
- if (m == null) {
- return query.field[field].fuzzy_rewrite;
- }
-
- m = m.toLowerCase();
- if (m === 'constant_score_auto' || m === 'scoring_boolean' ||
- m === 'constant_score_boolean' || m === 'constant_score_filter' ||
- m.indexOf('top_terms_boost_') === 0 ||
- m.indexOf('top_terms_') === 0) {
-
- query.field[field].fuzzy_rewrite = m;
- }
-
- return this;
- },
-
- /**
- Sets rewrite method.
- -Valid values are:
- -constant_score_auto
- tries to pick the best constant-score rewrite
- method based on term and document counts from the queryscoring_boolean
- translates each term into boolean should and
- keeps the scores as computed by the queryconstant_score_boolean
- same as scoring_boolean, expect no scores
- are computed.
-
- constant_score_filter
- first creates a private Filter, by visiting
- each term in sequence and marking all docs for that termtop_terms_boost_N
- first translates each term into boolean should
- and scores are only computed as the boost using the top N
- scoring terms. Replace N
with an integer value.top_terms_N
- first translates each term into boolean should
- and keeps the scores as computed by the query. Only the top N
- scoring terms are used. Replace N
with an integer value.Default is constant_score_auto
.
this
so that calls can be chained.
- */
- rewrite: function (m) {
- if (m == null) {
- return query.field[field].rewrite;
- }
-
- m = m.toLowerCase();
- if (m === 'constant_score_auto' || m === 'scoring_boolean' ||
- m === 'constant_score_boolean' || m === 'constant_score_filter' ||
- m.indexOf('top_terms_boost_') === 0 ||
- m.indexOf('top_terms_') === 0) {
-
- query.field[field].rewrite = m;
- }
-
- return this;
- },
-
- /**
- Sets the suffix to automatically add to the field name when - performing a quoted search.
- - @member ejs.FieldQuery - @param {String} s The suffix as a string. - @returns {Object} returnsthis
so that calls can be chained.
- */
- quoteFieldSuffix: function (s) {
- if (s == null) {
- return query.field[field].quote_field_suffix;
- }
-
- query.field[field].quote_field_suffix = s;
- return this;
- },
-
- /**
- Sets the default slop for phrases. If zero, then exact phrase matches - are required.
- -Default: 0
.
integer
value.
- @returns {Object} returns this
so that calls can be chained.
- */
- phraseSlop: function (slop) {
- if (slop == null) {
- return query.field[field].phrase_slop;
- }
-
- query.field[field].phrase_slop = slop;
- return this;
- },
-
- /**
- Sets whether or not we should attempt to analyzed wilcard terms in the
- Query
.
By default, wildcard terms are not analyzed. Analysis of wildcard characters is not perfect.
- -Default: false
.
true/false
value.
- @returns {Object} returns this
so that calls can be chained.
- */
- analyzeWildcard: function (trueFalse) {
- if (trueFalse == null) {
- return query.field[field].analyze_wildcard;
- }
-
- query.field[field].analyze_wildcard = trueFalse;
- return this;
- },
-
- /**
- If the query string should be escaped or not.
- - @member ejs.FieldQuery - @param {Boolean} trueFalse Atrue/false
value.
- @returns {Object} returns this
so that calls can be chained.
- */
- escape: function (trueFalse) {
- if (trueFalse == null) {
- return query.field[field].escape;
- }
-
- query.field[field].escape = trueFalse;
- return this;
- },
-
- /**
- Sets a percent value controlling how many should
clauses in the
- resulting Query
should match.
integer
between 0 and 100.
- @returns {Object} returns this
so that calls can be chained.
- */
- minimumShouldMatch: function (minMatch) {
- if (minMatch == null) {
- return query.field[field].minimum_should_match;
- }
-
- query.field[field].minimum_should_match = minMatch;
- return this;
- },
-
- /**
- Sets the boost value of the Query
.
Default: 1.0
.
double
value.
- @returns {Object} returns this
so that calls can be chained.
- */
- boost: function (boost) {
- if (boost == null) {
- return query.field[field].boost;
- }
-
- query.field[field].boost = boost;
- return this;
- },
-
- });
- };
-
/**
@class
Filter queries allow you to restrict the results returned by a query. There are diff --git a/dist/elastic.min.js b/dist/elastic.min.js index 74e46a7..29a249e 100644 --- a/dist/elastic.min.js +++ b/dist/elastic.min.js @@ -1,8 +1,7 @@ -/*! elastic.js - v1.1.1 - 2014-03-20 +/*! elastic.js - v1.1.1 - 2014-03-21 * https://github.com/fullscale/elastic.js * Copyright (c) 2014 FullScale Labs, LLC; Licensed MIT */ (function(){"use strict";var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z=this,A=z&&z.ejs,B=Array.prototype,C=Object.prototype,D=B.slice,E=C.toString,F=C.hasOwnProperty,G=B.forEach,H=Array.isArray,I=B.indexOf,J={};y="undefined"!=typeof exports?exports:z.ejs={},a=function(a,b){return F.call(a,b)},b=function(b,c,d){if(null!=b)if(G&&b.forEach===G)b.forEach(c,d);else if(b.length===+b.length){for(var e=0,f=b.length;f>e;e++)if(c.call(d,b[e],e,b)===J)return}else for(var g in b)if(a(b,g)&&c.call(d,b[g],g,b)===J)return},c=function(a){return b(D.call(arguments,1),function(b){for(var c in b)a[c]=b[c]}),a},d=function(a,b){if(null==a)return-1;var c=0,d=a.length;if(I&&a.indexOf===I)return a.indexOf(b);for(;d>c;c++)if(a[c]===b)return c;return-1},e=H||function(a){return"[object Array]"===E.call(a)},f=function(a){return a===Object(a)},g=function(a){return"[object String]"===E.call(a)},h=function(a){return"[object Number]"===E.call(a)},i=function(a){return a===!0||a===!1||"[object Boolean]"===E.call(a)},j="function"!=typeof/./?function(a){return"function"==typeof a}:function(a){return"[object Function]"===E.call(a)},k=function(b){return f(b)&&a(b,"_type")&&a(b,"toJSON")},l=function(a){return k(a)&&"query"===a._type()},m=function(a){return k(a)&&"rescore"===a._type()},n=function(a){return k(a)&&"filter"===a._type()},o=function(a){return k(a)&&"facet"===a._type()},p=function(a){return k(a)&&"aggregation"===a._type()},q=function(a){return k(a)&&"script field"===a._type()},r=function(a){return k(a)&&"geo point"===a._type()},s=function(a){return k(a)&&"indexed shape"===a._type()},t=function(a){return k(a)&&"shape"===a._type()},u=function(a){return k(a)&&"sort"===a._type()},v=function(a){return k(a)&&"highlight"===a._type()},w=function(a){return k(a)&&"suggest"===a._type()},x=function(a){return k(a)&&"generator"===a._type()},y.AggregationMixin=function(a){var b={};return b[a]={},{aggregation:function(d){if(null==d)return b[a].aggs;if(null==b[a].aggs&&(b[a].aggs={}),!p(d))throw new TypeError("Argument must be an Aggregation");return c(b[a].aggs,d.toJSON()),this},agg:function(a){return this.aggregation(a)},_type:function(){return"aggregation"},toJSON:function(){return b}}},y.DirectSettingsMixin=function(a){return{accuracy:function(b){return null==b?a.accuracy:(a.accuracy=b,this)},suggestMode:function(b){return null==b?a.suggest_mode:(b=b.toLowerCase(),("missing"===b||"popular"===b||"always"===b)&&(a.suggest_mode=b),this)},sort:function(b){return null==b?a.sort:(b=b.toLowerCase(),("score"===b||"frequency"===b)&&(a.sort=b),this)},stringDistance:function(b){return null==b?a.string_distance:(b=b.toLowerCase(),("internal"===b||"damerau_levenshtein"===b||"levenstein"===b||"jarowinkler"===b||"ngram"===b)&&(a.string_distance=b),this)},maxEdits:function(b){return null==b?a.max_edits:(a.max_edits=b,this)},maxInspections:function(b){return null==b?a.max_inspections:(a.max_inspections=b,this)},maxTermFreq:function(b){return null==b?a.max_term_freq:(a.max_term_freq=b,this)},prefixLen:function(b){return null==b?a.prefix_len:(a.prefix_len=b,this)},minWordLen:function(b){return null==b?a.min_word_len:(a.min_word_len=b,this)},minDocFreq:function(b){return null==b?a.min_doc_freq:(a.min_doc_freq=b,this)}}},y.FacetMixin=function(a){var b={};return b[a]={},{facetFilter:function(c){if(null==c)return b[a].facet_filter;if(!n(c))throw new TypeError("Argument must be a Filter");return b[a].facet_filter=c.toJSON(),this},global:function(c){return null==c?b[a].global:(b[a].global=c,this)},mode:function(c){return null==c?b[a].mode:(c=c.toLowerCase(),("collector"===c||"post"===c)&&(b[a].mode=c),this)},cacheFilter:function(c){return null==c?b[a].cache_filter:(b[a].cache_filter=c,this)},scope:function(){return this},nested:function(c){return null==c?b[a].nested:(b[a].nested=c,this)},_type:function(){return"facet"},toJSON:function(){return b}}},y.FilterMixin=function(a){var b={};return b[a]={},{name:function(c){return null==c?b[a]._name:(b[a]._name=c,this)},cache:function(c){return null==c?b[a]._cache:(b[a]._cache=c,this)},cacheKey:function(c){return null==c?b[a]._cache_key:(b[a]._cache_key=c,this)},_type:function(){return"filter"},toJSON:function(){return b}}},y.MetricsAggregationMixin=function(a,b){var d=y.AggregationMixin(a),e=d.toJSON();return delete d.aggregation,delete d.agg,e[a][b]={},c(d,{field:function(c){return null==c?e[a][b].field:(e[a][b].field=c,this)},script:function(c){return null==c?e[a][b].script:(e[a][b].script=c,this)},lang:function(c){return null==c?e[a][b].lang:(e[a][b].lang=c,this)},scriptValuesSorted:function(c){return null==c?e[a][b].script_values_sorted:(e[a][b].script_values_sorted=c,this)},params:function(c){return null==c?e[a][b].params:(e[a][b].params=c,this)}})},y.QueryMixin=function(a){var b={};return b[a]={},{boost:function(c){return null==c?b[a].boost:(b[a].boost=c,this)},_type:function(){return"query"},toJSON:function(){return b}}},y.SuggestContextMixin=function(a){return{analyzer:function(b){return null==b?a.analyzer:(a.analyzer=b,this)},field:function(b){return null==b?a.field:(a.field=b,this)},size:function(b){return null==b?a.size:(a.size=b,this)},shardSize:function(b){return null==b?a.shard_size:(a.shard_size=b,this)}}},y.SuggesterMixin=function(a){var b={};return b[a]={},{text:function(c){return null==c?b[a].text:(b[a].text=c,this)},_type:function(){return"suggest"},toJSON:function(){return b}}},y.DateHistogramFacet=function(a){var b=y.FacetMixin(a),d=b.toJSON();return d[a].date_histogram={},c(b,{field:function(b){return null==b?d[a].date_histogram.field:(d[a].date_histogram.field=b,this)},keyField:function(b){return null==b?d[a].date_histogram.key_field:(d[a].date_histogram.key_field=b,this)},valueField:function(b){return null==b?d[a].date_histogram.value_field:(d[a].date_histogram.value_field=b,this)},interval:function(b){return null==b?d[a].date_histogram.interval:(d[a].date_histogram.interval=b,this)},timeZone:function(b){return null==b?d[a].date_histogram.time_zone:(d[a].date_histogram.time_zone=b,this)},preZone:function(b){return null==b?d[a].date_histogram.pre_zone:(d[a].date_histogram.pre_zone=b,this)},preZoneAdjustLargeInterval:function(b){return null==b?d[a].date_histogram.pre_zone_adjust_large_interval:(d[a].date_histogram.pre_zone_adjust_large_interval=b,this)},postZone:function(b){return null==b?d[a].date_histogram.post_zone:(d[a].date_histogram.post_zone=b,this)},preOffset:function(b){return null==b?d[a].date_histogram.pre_offset:(d[a].date_histogram.pre_offset=b,this)},postOffset:function(b){return null==b?d[a].date_histogram.post_offset:(d[a].date_histogram.post_offset=b,this)},factor:function(b){return null==b?d[a].date_histogram.factor:(d[a].date_histogram.factor=b,this)},valueScript:function(b){return null==b?d[a].date_histogram.value_script:(d[a].date_histogram.value_script=b,this)},order:function(b){return null==b?d[a].date_histogram.order:(b=b.toLowerCase(),("time"===b||"count"===b||"total"===b)&&(d[a].date_histogram.order=b),this)},lang:function(b){return null==b?d[a].date_histogram.lang:(d[a].date_histogram.lang=b,this)},params:function(b){return null==b?d[a].date_histogram.params:(d[a].date_histogram.params=b,this)}})},y.FilterFacet=function(a){var b=y.FacetMixin(a),d=b.toJSON();return c(b,{filter:function(b){if(null==b)return d[a].filter;if(!n(b))throw new TypeError("Argument must be a Filter");return d[a].filter=b.toJSON(),this}})},y.GeoDistanceFacet=function(a){var b=y.FacetMixin(a),d=b.toJSON(),e=y.GeoPoint([0,0]),f="location";return d[a].geo_distance={location:e.toJSON(),ranges:[]},c(b,{field:function(b){var c=d[a].geo_distance[f];return null==b?f:(delete d[a].geo_distance[f],f=b,d[a].geo_distance[b]=c,this)},point:function(b){if(null==b)return e;if(!r(b))throw new TypeError("Argument must be a GeoPoint");return e=b,d[a].geo_distance[f]=b.toJSON(),this},addRange:function(b,c){return 0===arguments.length?d[a].geo_distance.ranges:(d[a].geo_distance.ranges.push({from:b,to:c}),this)},addUnboundedFrom:function(b){return null==b?d[a].geo_distance.ranges:(d[a].geo_distance.ranges.push({from:b}),this)},addUnboundedTo:function(b){return null==b?d[a].geo_distance.ranges:(d[a].geo_distance.ranges.push({to:b}),this)},unit:function(b){return null==b?d[a].geo_distance.unit:(b=b.toLowerCase(),("mi"===b||"km"===b)&&(d[a].geo_distance.unit=b),this)},distanceType:function(b){return null==b?d[a].geo_distance.distance_type:(b=b.toLowerCase(),("arc"===b||"plane"===b)&&(d[a].geo_distance.distance_type=b),this)},normalize:function(b){return null==b?d[a].geo_distance.normalize:(d[a].geo_distance.normalize=b,this)},valueField:function(b){return null==b?d[a].geo_distance.value_field:(d[a].geo_distance.value_field=b,this)},valueScript:function(b){return null==b?d[a].geo_distance.value_script:(d[a].geo_distance.value_script=b,this)},lang:function(b){return null==b?d[a].geo_distance.lang:(d[a].geo_distance.lang=b,this)},params:function(b){return null==b?d[a].geo_distance.params:(d[a].geo_distance.params=b,this)}})},y.HistogramFacet=function(a){var b=y.FacetMixin(a),d=b.toJSON();return d[a].histogram={},c(b,{field:function(b){return null==b?d[a].histogram.field:(d[a].histogram.field=b,this)},interval:function(b){return null==b?d[a].histogram.interval:(d[a].histogram.interval=b,this)},timeInterval:function(b){return null==b?d[a].histogram.time_interval:(d[a].histogram.time_interval=b,this)},from:function(b){return null==b?d[a].histogram.from:(d[a].histogram.from=b,this)},to:function(b){return null==b?d[a].histogram.to:(d[a].histogram.to=b,this)},valueField:function(b){return null==b?d[a].histogram.value_field:(d[a].histogram.value_field=b,this)},keyField:function(b){return null==b?d[a].histogram.key_field:(d[a].histogram.key_field=b,this)},valueScript:function(b){return null==b?d[a].histogram.value_script:(d[a].histogram.value_script=b,this)},keyScript:function(b){return null==b?d[a].histogram.key_script:(d[a].histogram.key_script=b,this)},lang:function(b){return null==b?d[a].histogram.lang:(d[a].histogram.lang=b,this)},params:function(b){return null==b?d[a].histogram.params:(d[a].histogram.params=b,this)},order:function(b){return null==b?d[a].histogram.order:(b=b.toLowerCase(),("key"===b||"count"===b||"total"===b)&&(d[a].histogram.order=b),this)}})},y.QueryFacet=function(a){var b=y.FacetMixin(a),d=b.toJSON();return c(b,{query:function(b){if(null==b)return d[a].query;if(!l(b))throw new TypeError("Argument must be a Query");return d[a].query=b.toJSON(),this}})},y.RangeFacet=function(a){var b=y.FacetMixin(a),d=b.toJSON();return d[a].range={ranges:[]},c(b,{field:function(b){return null==b?d[a].range.field:(d[a].range.field=b,this)},keyField:function(b){return null==b?d[a].range.key_field:(d[a].range.key_field=b,this)},valueField:function(b){return null==b?d[a].range.value_field:(d[a].range.value_field=b,this)},valueScript:function(b){return null==b?d[a].range.value_script:(d[a].range.value_script=b,this)},keyScript:function(b){return null==b?d[a].range.key_script:(d[a].range.key_script=b,this)},lang:function(b){return null==b?d[a].range.lang:(d[a].range.lang=b,this)},params:function(b){return null==b?d[a].range.params:(d[a].range.params=b,this)},addRange:function(b,c){return 0===arguments.length?d[a].range.ranges:(d[a].range.ranges.push({from:b,to:c}),this)},addUnboundedFrom:function(b){return null==b?d[a].range.ranges:(d[a].range.ranges.push({from:b}),this)},addUnboundedTo:function(b){return null==b?d[a].range.ranges:(d[a].range.ranges.push({to:b}),this)}})},y.StatisticalFacet=function(a){var b=y.FacetMixin(a),d=b.toJSON();return d[a].statistical={},c(b,{field:function(b){return null==b?d[a].statistical.field:(d[a].statistical.field=b,this)},fields:function(b){if(null==b)return d[a].statistical.fields;if(!e(b))throw new TypeError("Argument must be an array");return d[a].statistical.fields=b,this},script:function(b){return null==b?d[a].statistical.script:(d[a].statistical.script=b,this)},lang:function(b){return null==b?d[a].statistical.lang:(d[a].statistical.lang=b,this)},params:function(b){return null==b?d[a].statistical.params:(d[a].statistical.params=b,this)}})},y.TermStatsFacet=function(a){var b=y.FacetMixin(a),d=b.toJSON();return d[a].terms_stats={},c(b,{valueField:function(b){return null==b?d[a].terms_stats.value_field:(d[a].terms_stats.value_field=b,this)},keyField:function(b){return null==b?d[a].terms_stats.key_field:(d[a].terms_stats.key_field=b,this)},scriptField:function(b){return null==b?d[a].terms_stats.script_field:(d[a].terms_stats.script_field=b,this)},valueScript:function(b){return null==b?d[a].terms_stats.value_script:(d[a].terms_stats.value_script=b,this)},allTerms:function(b){return null==b?d[a].terms_stats.all_terms:(d[a].terms_stats.all_terms=b,this)},lang:function(b){return null==b?d[a].terms_stats.lang:(d[a].terms_stats.lang=b,this)},params:function(b){return null==b?d[a].terms_stats.params:(d[a].terms_stats.params=b,this)},size:function(b){return null==b?d[a].terms_stats.size:(d[a].terms_stats.size=b,this)},order:function(b){return null==b?d[a].terms_stats.order:(b=b.toLowerCase(),("count"===b||"term"===b||"reverse_count"===b||"reverse_term"===b||"total"===b||"reverse_total"===b||"min"===b||"reverse_min"===b||"max"===b||"reverse_max"===b||"mean"===b||"reverse_mean"===b)&&(d[a].terms_stats.order=b),this)}})},y.TermsFacet=function(a){var b=y.FacetMixin(a),d=b.toJSON();return d[a].terms={},c(b,{field:function(b){return null==b?d[a].terms.field:(d[a].terms.field=b,this)},fields:function(b){if(null==b)return d[a].terms.fields;if(!e(b))throw new TypeError("Argument must be an array");return d[a].terms.fields=b,this},scriptField:function(b){return null==b?d[a].terms.script_field:(d[a].terms.script_field=b,this)},size:function(b){return null==b?d[a].terms.size:(d[a].terms.size=b,this)},shardSize:function(b){return null==b?d[a].terms.shard_size:(d[a].terms.shard_size=b,this)},order:function(b){return null==b?d[a].terms.order:(b=b.toLowerCase(),("count"===b||"term"===b||"reverse_count"===b||"reverse_term"===b)&&(d[a].terms.order=b),this)},allTerms:function(b){return null==b?d[a].terms.all_terms:(d[a].terms.all_terms=b,this)},exclude:function(b){if(null==d[a].terms.exclude&&(d[a].terms.exclude=[]),null==b)return d[a].terms.exclude;if(g(b))d[a].terms.exclude.push(b);else{if(!e(b))throw new TypeError("Argument must be string or array");d[a].terms.exclude=b}return this},regex:function(b){return null==b?d[a].terms.regex:(d[a].terms.regex=b,this)},regexFlags:function(b){return null==b?d[a].terms.regex_flags:(d[a].terms.regex_flags=b,this)},script:function(b){return null==b?d[a].terms.script:(d[a].terms.script=b,this)},lang:function(b){return null==b?d[a].terms.lang:(d[a].terms.lang=b,this)},params:function(b){return null==b?d[a].terms.params:(d[a].terms.params=b,this)},executionHint:function(b){return null==b?d[a].terms.execution_hint:(d[a].terms.execution_hint=b,this)}})},y.AvgAggregation=function(a){{var b=y.MetricsAggregationMixin(a,"avg");b.toJSON()}return b},y.CardinalityAggregation=function(a){var b=y.MetricsAggregationMixin(a,"cardinality"),d=b.toJSON();return delete b.scriptValuesSorted,c(b,{rehash:function(b){return null==b?d[a].cardinality.rehash:(d[a].cardinality.rehash=b,this)},precisionThreshold:function(b){return null==b?d[a].cardinality.precision_threshold:(d[a].cardinality.precision_threshold=b,this)}})},y.DateHistogramAggregation=function(a){var b=y.AggregationMixin(a),d=b.toJSON();return d[a].date_histogram={},c(b,{field:function(b){return null==b?d[a].date_histogram.field:(d[a].date_histogram.field=b,this)},script:function(b){return null==b?d[a].date_histogram.script:(d[a].date_histogram.script=b,this)},lang:function(b){return null==b?d[a].date_histogram.lang:(d[a].date_histogram.lang=b,this)},timeZone:function(b){return null==b?d[a].date_histogram.time_zone:(d[a].date_histogram.time_zone=b,this)},preZone:function(b){return null==b?d[a].date_histogram.pre_zone:(d[a].date_histogram.pre_zone=b,this)},postZone:function(b){return null==b?d[a].date_histogram.post_zone:(d[a].date_histogram.post_zone=b,this)},preOffset:function(b){return null==b?d[a].date_histogram.pre_offset:(d[a].date_histogram.pre_offset=b,this)},postOffset:function(b){return null==b?d[a].date_histogram.post_offset:(d[a].date_histogram.post_offset=b,this)},extendedBounds:function(b,c){var e;return null==b&&null==c?d[a].date_histogram.extended_bounds:(e={},null!=b&&(e.min=b),null!=c&&(e.max=c),d[a].date_histogram.extended_bounds=e,this)},interval:function(b){return null==b?d[a].date_histogram.interval:(d[a].date_histogram.interval=b,this)},format:function(b){return null==b?d[a].date_histogram.format:(d[a].date_histogram.format=b,this)},keyed:function(b){return null==b?d[a].date_histogram.keyed:(d[a].date_histogram.keyed=b,this)},scriptValuesSorted:function(b){return null==b?d[a].date_histogram.script_values_sorted:(d[a].date_histogram.script_values_sorted=b,this)},preZoneAdjustLargeInterval:function(b){return null==b?d[a].date_histogram.pre_zone_adjust_large_interval:(d[a].date_histogram.pre_zone_adjust_large_interval=b,this)},minDocCount:function(b){return null==b?d[a].date_histogram.min_doc_count:(d[a].date_histogram.min_doc_count=b,this)},params:function(b){return null==b?d[a].date_histogram.params:(d[a].date_histogram.params=b,this)},order:function(b,c){return null==b?d[a].date_histogram.order:(null==c&&(c="desc"),c=c.toLowerCase(),"asc"!==c&&"desc"!==c&&(c="desc"),d[a].date_histogram.order={},d[a].date_histogram.order[b]=c,this)}})},y.DateRangeAggregation=function(a){var b=y.AggregationMixin(a),d=b.toJSON();return d[a].date_range={},c(b,{field:function(b){return null==b?d[a].date_range.field:(d[a].date_range.field=b,this)},script:function(b){return null==b?d[a].date_range.script:(d[a].date_range.script=b,this)},lang:function(b){return null==b?d[a].date_range.lang:(d[a].date_range.lang=b,this)},format:function(b){return null==b?d[a].date_range.format:(d[a].date_range.format=b,this)},range:function(b,c,e){var f={};return null==d[a].date_range.ranges&&(d[a].date_range.ranges=[]),null==b&&null==c?d[a].date_range.ranges:(null!=b&&(f.from=b),null!=c&&(f.to=c),null!=e&&(f.key=e),d[a].date_range.ranges.push(f),this)},keyed:function(b){return null==b?d[a].date_range.keyed:(d[a].date_range.keyed=b,this)},scriptValuesSorted:function(b){return null==b?d[a].date_range.script_values_sorted:(d[a].date_range.script_values_sorted=b,this)},params:function(b){return null==b?d[a].date_range.params:(d[a].date_range.params=b,this)}})},y.ExtendedStatsAggregation=function(a){{var b=y.MetricsAggregationMixin(a,"extended_stats");b.toJSON()}return b},y.FilterAggregation=function(a){var b=y.AggregationMixin(a),d=b.toJSON();return c(b,{filter:function(b){if(null==b)return d[a].filter;if(!n(b))throw new TypeError("Argument must be a Filter");return d[a].filter=b.toJSON(),this}})},y.GeoDistanceAggregation=function(a){var b=y.AggregationMixin(a),d=y.GeoPoint([0,0]),e=b.toJSON();return e[a].geo_distance={},c(b,{field:function(b){return null==b?e[a].geo_distance.field:(e[a].geo_distance.field=b,this)},unit:function(b){return null==b?e[a].geo_distance.unit:(("in"===b||"yd"===b||"ft"===b||"km"===b||"NM"===b||"mm"===b||"cm"===b||"mi"===b||"m"===b)&&(e[a].geo_distance.unit=b),this)},distanceType:function(b){return null==b?e[a].geo_distance.distance_type:(b=b.toLowerCase(),("plane"===b||"arc"===b||"sloppy_arc"===b||"factor"===b)&&(e[a].geo_distance.distance_type=b),this)},origin:function(b){if(null==b)return d;if(!r(b))throw new TypeError("Argument must be a GeoPoint");return d=b,e[a].geo_distance.origin=b.toJSON(),this},point:function(b){if(null==b)return d;if(!r(b))throw new TypeError("Argument must be a GeoPoint");return d=b,e[a].geo_distance.point=b.toJSON(),this},center:function(b){if(null==b)return d;if(!r(b))throw new TypeError("Argument must be a GeoPoint");return d=b,e[a].geo_distance.center=b.toJSON(),this},range:function(b,c,d){var f={};return null==e[a].geo_distance.ranges&&(e[a].geo_distance.ranges=[]),null==b&&null==c?e[a].geo_distance.ranges:(null!=b&&(f.from=b),null!=c&&(f.to=c),null!=d&&(f.key=d),e[a].geo_distance.ranges.push(f),this)},keyed:function(b){return null==b?e[a].geo_distance.keyed:(e[a].geo_distance.keyed=b,this)}})},y.GeoHashGridAggregation=function(a){var b=y.AggregationMixin(a),d=b.toJSON();return d[a].geohash_grid={},c(b,{field:function(b){return null==b?d[a].geohash_grid.field:(d[a].geohash_grid.field=b,this)},precision:function(b){return null==b?d[a].geohash_grid.precision:(d[a].geohash_grid.precision=b,this)},size:function(b){return null==b?d[a].geohash_grid.size:(d[a].geohash_grid.size=b,this)},shardSize:function(b){return null==b?d[a].geohash_grid.shard_size:(d[a].geohash_grid.shard_size=b,this)}})},y.GlobalAggregation=function(a){var b=y.AggregationMixin(a),c=b.toJSON();return c[a].global={},b},y.HistogramAggregation=function(a){var b=y.AggregationMixin(a),d=b.toJSON();return d[a].histogram={},c(b,{field:function(b){return null==b?d[a].histogram.field:(d[a].histogram.field=b,this)},script:function(b){return null==b?d[a].histogram.script:(d[a].histogram.script=b,this)},lang:function(b){return null==b?d[a].histogram.lang:(d[a].histogram.lang=b,this)},format:function(b){return null==b?d[a].histogram.format:(d[a].histogram.format=b,this)},extendedBounds:function(b,c){var e;return null==b&&null==c?d[a].histogram.extended_bounds:(e={},null!=b&&(e.min=b),null!=c&&(e.max=c),d[a].histogram.extended_bounds=e,this)},interval:function(b){return null==b?d[a].histogram.interval:(d[a].histogram.interval=b,this)},minDocCount:function(b){return null==b?d[a].histogram.min_doc_count:(d[a].histogram.min_doc_count=b,this)},keyed:function(b){return null==b?d[a].histogram.keyed:(d[a].histogram.keyed=b,this)},scriptValuesSorted:function(b){return null==b?d[a].histogram.script_values_sorted:(d[a].histogram.script_values_sorted=b,this)},params:function(b){return null==b?d[a].histogram.params:(d[a].histogram.params=b,this)},order:function(b,c){return null==b?d[a].histogram.order:(null==c&&(c="desc"),c=c.toLowerCase(),"asc"!==c&&"desc"!==c&&(c="desc"),d[a].histogram.order={},d[a].histogram.order[b]=c,this)}})},y.IPv4RangeAggregation=function(a){var b=y.AggregationMixin(a),d=b.toJSON();return d[a].ip_range={},c(b,{field:function(b){return null==b?d[a].ip_range.field:(d[a].ip_range.field=b,this)},script:function(b){return null==b?d[a].ip_range.script:(d[a].ip_range.script=b,this)},lang:function(b){return null==b?d[a].ip_range.lang:(d[a].ip_range.lang=b,this)},range:function(b,c,e,f){var g={};return null==d[a].ip_range.ranges&&(d[a].ip_range.ranges=[]),null==b&&null==c&&null==e?d[a].ip_range.ranges:(null!=b&&(g.from=b),null!=c&&(g.to=c),null!=e&&(g.mask=e),null!=f&&(g.key=f),d[a].ip_range.ranges.push(g),this)},keyed:function(b){return null==b?d[a].ip_range.keyed:(d[a].ip_range.keyed=b,this)},scriptValuesSorted:function(b){return null==b?d[a].ip_range.script_values_sorted:(d[a].ip_range.script_values_sorted=b,this)},params:function(b){return null==b?d[a].ip_range.params:(d[a].ip_range.params=b,this)}})},y.MaxAggregation=function(a){{var b=y.MetricsAggregationMixin(a,"max");b.toJSON()}return b},y.MinAggregation=function(a){{var b=y.MetricsAggregationMixin(a,"min");b.toJSON()}return b},y.MissingAggregation=function(a){var b=y.AggregationMixin(a),d=b.toJSON();return d[a].missing={},c(b,{field:function(b){return null==b?d[a].missing.field:(d[a].missing.field=b,this)}})},y.NestedAggregation=function(a){var b=y.AggregationMixin(a),d=b.toJSON();return d[a].nested={},c(b,{path:function(b){return null==b?d[a].nested.path:(d[a].nested.path=b,this)}})},y.PercentilesAggregation=function(a){var b=y.MetricsAggregationMixin(a,"percentiles"),d=b.toJSON();return c(b,{keyed:function(b){return null==b?d[a].percentiles.keyed:(d[a].percentiles.keyed=b,this)},percents:function(b){if(null==b)return d[a].percentiles.percents;if(!e(b))throw new TypeError("Percents must be an array of doubles");return d[a].percentiles.percents=b,this},percent:function(b){return null==d[a].percentiles.percents&&(d[a].percentiles.percents=[]),null==b?d[a].percentiles.percents:(d[a].percentiles.percents.push(b),this)},compression:function(b){return null==b?d[a].percentiles.compression:(d[a].percentiles.compression=b,this)}})},y.RangeAggregation=function(a){var b=y.AggregationMixin(a),d=b.toJSON();return d[a].range={},c(b,{field:function(b){return null==b?d[a].range.field:(d[a].range.field=b,this)},script:function(b){return null==b?d[a].range.script:(d[a].range.script=b,this)},lang:function(b){return null==b?d[a].range.lang:(d[a].range.lang=b,this)},range:function(b,c,e){var f={};return null==d[a].range.ranges&&(d[a].range.ranges=[]),null==b&&null==c?d[a].range.ranges:(null!=b&&(f.from=b),null!=c&&(f.to=c),null!=e&&(f.key=e),d[a].range.ranges.push(f),this)},keyed:function(b){return null==b?d[a].range.keyed:(d[a].range.keyed=b,this)},scriptValuesSorted:function(b){return null==b?d[a].range.script_values_sorted:(d[a].range.script_values_sorted=b,this)},params:function(b){return null==b?d[a].range.params:(d[a].range.params=b,this)}})},y.SignificantTermsAggregation=function(a){var b=y.AggregationMixin(a),d=b.toJSON();return d[a].significant_terms={},c(b,{field:function(b){return null==b?d[a].significant_terms.field:(d[a].significant_terms.field=b,this)},format:function(b){return null==b?d[a].significant_terms.format:(d[a].significant_terms.format=b,this)},include:function(b,c){return null==d[a].significant_terms.include&&(d[a].significant_terms.include={}),null==b?d[a].significant_terms.include:(d[a].significant_terms.include.pattern=b,null!=c&&(d[a].significant_terms.include.flags=c),this)},exclude:function(b,c){return null==d[a].significant_terms.exclude&&(d[a].significant_terms.exclude={}),null==b?d[a].significant_terms.exclude:(d[a].significant_terms.exclude.pattern=b,null!=c&&(d[a].significant_terms.exclude.flags=c),this)},executionHint:function(b){return null==b?d[a].significant_terms.execution_hint:(b=b.toLowerCase(),("map"===b||"ordinals"===b)&&(d[a].significant_terms.execution_hint=b),this)},size:function(b){return null==b?d[a].significant_terms.size:(d[a].significant_terms.size=b,this)},shardSize:function(b){return null==b?d[a].significant_terms.shard_size:(d[a].significant_terms.shard_size=b,this)},minDocCount:function(b){return null==b?d[a].significant_terms.min_doc_count:(d[a].significant_terms.min_doc_count=b,this)}})},y.StatsAggregation=function(a){{var b=y.MetricsAggregationMixin(a,"stats");b.toJSON()}return b},y.SumAggregation=function(a){{var b=y.MetricsAggregationMixin(a,"sum");b.toJSON()}return b},y.TermsAggregation=function(a){var b=y.AggregationMixin(a),d=b.toJSON();return d[a].terms={},c(b,{field:function(b){return null==b?d[a].terms.field:(d[a].terms.field=b,this)},script:function(b){return null==b?d[a].terms.script:(d[a].terms.script=b,this)},lang:function(b){return null==b?d[a].terms.lang:(d[a].terms.lang=b,this)},valueType:function(b){return null==b?d[a].terms.value_type:(b=b.toLowerCase(),("string"===b||"double"===b||"float"===b||"long"===b||"integer"===b||"short"===b||"byte"===b)&&(d[a].terms.value_type=b),this)},format:function(b){return null==b?d[a].terms.format:(d[a].terms.format=b,this)},include:function(b,c){return null==d[a].terms.include&&(d[a].terms.include={}),null==b?d[a].terms.include:(d[a].terms.include.pattern=b,null!=c&&(d[a].terms.include.flags=c),this)},exclude:function(b,c){return null==d[a].terms.exclude&&(d[a].terms.exclude={}),null==b?d[a].terms.exclude:(d[a].terms.exclude.pattern=b,null!=c&&(d[a].terms.exclude.flags=c),this)},executionHint:function(b){return null==b?d[a].terms.execution_hint:(b=b.toLowerCase(),("map"===b||"ordinals"===b)&&(d[a].terms.execution_hint=b),this)},scriptValuesUnique:function(b){return null==b?d[a].terms.script_values_unique:(d[a].terms.script_values_unique=b,this)},size:function(b){return null==b?d[a].terms.size:(d[a].terms.size=b,this)},shardSize:function(b){return null==b?d[a].terms.shard_size:(d[a].terms.shard_size=b,this)},minDocCount:function(b){return null==b?d[a].terms.min_doc_count:(d[a].terms.min_doc_count=b,this)},params:function(b){return null==b?d[a].terms.params:(d[a].terms.params=b,this)},order:function(b,c){return null==b?d[a].terms.order:(null==c&&(c="desc"),c=c.toLowerCase(),"asc"!==c&&"desc"!==c&&(c="desc"),d[a].terms.order={},d[a].terms.order[b]=c,this)}})},y.ValueCountAggregation=function(a){var b=y.MetricsAggregationMixin(a,"value_count"),d=b.toJSON();return delete b.scriptValuesSorted,c(b,{scriptValuesUnique:function(b){return null==b?d[a].value_count.script_values_unique:(d[a].value_count.script_values_unique=b,this)}})},y.AndFilter=function(a){var b,d,f=y.FilterMixin("and"),g=f.toJSON();if(g.and.filters=[],n(a))g.and.filters.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be a Filter or Array of Filters");for(b=0,d=a.length;d>b;b++){if(!n(a[b]))throw new TypeError("Array must contain only Filter objects");g.and.filters.push(a[b].toJSON())}}return c(f,{filters:function(a){var b,c;if(null==a)return g.and.filters;if(n(a))g.and.filters.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be a Filter or an Array of Filters");for(g.and.filters=[],b=0,c=a.length;c>b;b++){if(!n(a[b]))throw new TypeError("Array must contain only Filter objects");g.and.filters.push(a[b].toJSON())}}return this}})},y.BoolFilter=function(){var a=y.FilterMixin("bool"),b=a.toJSON();return c(a,{must:function(a){var c,d;if(null==b.bool.must&&(b.bool.must=[]),null==a)return b.bool.must;if(n(a))b.bool.must.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be a Filter or array of Filters");for(b.bool.must=[],c=0,d=a.length;d>c;c++){if(!n(a[c]))throw new TypeError("Argument must be an array of Filters");b.bool.must.push(a[c].toJSON())}}return this},mustNot:function(a){var c,d;if(null==b.bool.must_not&&(b.bool.must_not=[]),null==a)return b.bool.must_not;if(n(a))b.bool.must_not.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be a Filter or array of Filters");for(b.bool.must_not=[],c=0,d=a.length;d>c;c++){if(!n(a[c]))throw new TypeError("Argument must be an array of Filters");b.bool.must_not.push(a[c].toJSON())}}return this},should:function(a){var c,d;if(null==b.bool.should&&(b.bool.should=[]),null==a)return b.bool.should;if(n(a))b.bool.should.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be a Filter or array of Filters");for(b.bool.should=[],c=0,d=a.length;d>c;c++){if(!n(a[c]))throw new TypeError("Argument must be an array of Filters");b.bool.should.push(a[c].toJSON())}}return this}})},y.ExistsFilter=function(a){var b=y.FilterMixin("exists"),d=b.toJSON();return d.exists.field=a,c(b,{field:function(a){return null==a?d.exists.field:(d.exists.field=a,this)}})},y.GeoBboxFilter=function(a){var b=y.FilterMixin("geo_bounding_box"),d=b.toJSON();return d.geo_bounding_box[a]={},c(b,{field:function(b){var c=d.geo_bounding_box[a];return null==b?a:(delete d.geo_bounding_box[a],a=b,d.geo_bounding_box[b]=c,this)},topLeft:function(b){if(null==b)return d.geo_bounding_box[a].top_left;if(!r(b))throw new TypeError("Argument must be a GeoPoint");return d.geo_bounding_box[a].top_left=b.toJSON(),this},bottomRight:function(b){if(null==b)return d.geo_bounding_box[a].bottom_right;if(!r(b))throw new TypeError("Argument must be a GeoPoint");return d.geo_bounding_box[a].bottom_right=b.toJSON(),this},type:function(a){return null==a?d.geo_bounding_box.type:(a=a.toLowerCase(),("memory"===a||"indexed"===a)&&(d.geo_bounding_box.type=a),this)},normalize:function(a){return null==a?d.geo_bounding_box.normalize:(d.geo_bounding_box.normalize=a,this)}})},y.GeoDistanceFilter=function(a){var b=y.FilterMixin("geo_distance"),d=b.toJSON();return d.geo_distance[a]=[0,0],c(b,{field:function(b){var c=d.geo_distance[a];return null==b?a:(delete d.geo_distance[a],a=b,d.geo_distance[b]=c,this)},distance:function(a){if(null==a)return d.geo_distance.distance;if(!h(a))throw new TypeError("Argument must be a numeric value");return d.geo_distance.distance=a,this},unit:function(a){return null==a?d.geo_distance.unit:(a=a.toLowerCase(),("mi"===a||"km"===a)&&(d.geo_distance.unit=a),this) -},point:function(b){if(null==b)return d.geo_distance[a];if(!r(b))throw new TypeError("Argument must be a GeoPoint");return d.geo_distance[a]=b.toJSON(),this},distanceType:function(a){return null==a?d.geo_distance.distance_type:(a=a.toLowerCase(),("arc"===a||"plane"===a)&&(d.geo_distance.distance_type=a),this)},normalize:function(a){return null==a?d.geo_distance.normalize:(d.geo_distance.normalize=a,this)},optimizeBbox:function(a){return null==a?d.geo_distance.optimize_bbox:(a=a.toLowerCase(),("memory"===a||"indexed"===a||"none"===a)&&(d.geo_distance.optimize_bbox=a),this)}})},y.GeoDistanceRangeFilter=function(a){var b=y.FilterMixin("geo_distance_range"),d=b.toJSON();return d.geo_distance_range[a]=[0,0],c(b,{field:function(b){var c=d.geo_distance_range[a];return null==b?a:(delete d.geo_distance_range[a],a=b,d.geo_distance_range[b]=c,this)},from:function(a){if(null==a)return d.geo_distance_range.from;if(!h(a))throw new TypeError("Argument must be a numeric value");return d.geo_distance_range.from=a,this},to:function(a){if(null==a)return d.geo_distance_range.to;if(!h(a))throw new TypeError("Argument must be a numeric value");return d.geo_distance_range.to=a,this},includeLower:function(a){return null==a?d.geo_distance_range.include_lower:(d.geo_distance_range.include_lower=a,this)},includeUpper:function(a){return null==a?d.geo_distance_range.include_upper:(d.geo_distance_range.include_upper=a,this)},gt:function(a){if(null==a)return d.geo_distance_range.gt;if(!h(a))throw new TypeError("Argument must be a numeric value");return d.geo_distance_range.gt=a,this},gte:function(a){if(null==a)return d.geo_distance_range.gte;if(!h(a))throw new TypeError("Argument must be a numeric value");return d.geo_distance_range.gte=a,this},lt:function(a){if(null==a)return d.geo_distance_range.lt;if(!h(a))throw new TypeError("Argument must be a numeric value");return d.geo_distance_range.lt=a,this},lte:function(a){if(null==a)return d.geo_distance_range.lte;if(!h(a))throw new TypeError("Argument must be a numeric value");return d.geo_distance_range.lte=a,this},unit:function(a){return null==a?d.geo_distance_range.unit:(a=a.toLowerCase(),("mi"===a||"km"===a)&&(d.geo_distance_range.unit=a),this)},point:function(b){if(null==b)return d.geo_distance_range[a];if(!r(b))throw new TypeError("Argument must be a GeoPoint");return d.geo_distance_range[a]=b.toJSON(),this},distanceType:function(a){return null==a?d.geo_distance_range.distance_type:(a=a.toLowerCase(),("arc"===a||"plane"===a)&&(d.geo_distance_range.distance_type=a),this)},normalize:function(a){return null==a?d.geo_distance_range.normalize:(d.geo_distance_range.normalize=a,this)},optimizeBbox:function(a){return null==a?d.geo_distance_range.optimize_bbox:(a=a.toLowerCase(),("memory"===a||"indexed"===a||"none"===a)&&(d.geo_distance_range.optimize_bbox=a),this)}})},y.GeoPolygonFilter=function(a){var b=y.FilterMixin("geo_polygon"),d=b.toJSON();return d.geo_polygon[a]={points:[]},c(b,{field:function(b){var c=d.geo_polygon[a];return null==b?a:(delete d.geo_polygon[a],a=b,d.geo_polygon[b]=c,this)},points:function(b){var c,f;if(null==b)return d.geo_polygon[a].points;if(r(b))d.geo_polygon[a].points.push(b.toJSON());else{if(!e(b))throw new TypeError("Argument must be a GeoPoint or Array of GeoPoints");for(d.geo_polygon[a].points=[],c=0,f=b.length;f>c;c++){if(!r(b[c]))throw new TypeError("Argument must be Array of GeoPoints");d.geo_polygon[a].points.push(b[c].toJSON())}}return this},normalize:function(a){return null==a?d.geo_polygon.normalize:(d.geo_polygon.normalize=a,this)}})},y.GeoShapeFilter=function(a){var b=y.FilterMixin("geo_shape"),d=b.toJSON();return d.geo_shape[a]={},c(b,{field:function(b){var c=d.geo_shape[a];return null==b?a:(delete d.geo_shape[a],a=b,d.geo_shape[b]=c,this)},shape:function(b){return null==b?d.geo_shape[a].shape:(null!=d.geo_shape[a].indexed_shape&&delete d.geo_shape[a].indexed_shape,d.geo_shape[a].shape=b.toJSON(),this)},indexedShape:function(b){return null==b?d.geo_shape[a].indexed_shape:(null!=d.geo_shape[a].shape&&delete d.geo_shape[a].shape,d.geo_shape[a].indexed_shape=b.toJSON(),this)},relation:function(b){return null==b?d.geo_shape[a].relation:(b=b.toLowerCase(),("intersects"===b||"disjoint"===b||"within"===b)&&(d.geo_shape[a].relation=b),this)},strategy:function(b){return null==b?d.geo_shape[a].strategy:(b=b.toLowerCase(),("recursive"===b||"term"===b)&&(d.geo_shape[a].strategy=b),this)}})},y.HasChildFilter=function(a,b){if(!l(a))throw new TypeError("No Query object found");var d=y.FilterMixin("has_child"),e=d.toJSON();return e.has_child.query=a.toJSON(),e.has_child.type=b,c(d,{query:function(a){if(null==a)return e.has_child.query;if(!l(a))throw new TypeError("Argument must be a Query object");return e.has_child.query=a.toJSON(),this},filter:function(a){if(null==a)return e.has_child.filter;if(!n(a))throw new TypeError("Argument must be a Filter object");return e.has_child.filter=a.toJSON(),this},type:function(a){return null==a?e.has_child.type:(e.has_child.type=a,this)},shortCircuitCutoff:function(a){return null==a?e.has_child.short_circuit_cutoff:(e.has_child.short_circuit_cutoff=a,this)},scope:function(){return this}})},y.HasParentFilter=function(a,b){if(!l(a))throw new TypeError("No Query object found");var d=y.FilterMixin("has_parent"),e=d.toJSON();return e.has_parent.query=a.toJSON(),e.has_parent.parent_type=b,c(d,{query:function(a){if(null==a)return e.has_parent.query;if(!l(a))throw new TypeError("Argument must be a Query object");return e.has_parent.query=a.toJSON(),this},filter:function(a){if(null==a)return e.has_parent.filter;if(!n(a))throw new TypeError("Argument must be a Filter object");return e.has_parent.filter=a.toJSON(),this},parentType:function(a){return null==a?e.has_parent.parent_type:(e.has_parent.parent_type=a,this)},scope:function(){return this}})},y.IdsFilter=function(a){var b=y.FilterMixin("ids"),d=b.toJSON();if(g(a))d.ids.values=[a];else{if(!e(a))throw new TypeError("Argument must be a string or an array");d.ids.values=a}return c(b,{values:function(a){if(null==a)return d.ids.values;if(g(a))d.ids.values.push(a);else{if(!e(a))throw new TypeError("Argument must be a string or an array");d.ids.values=a}return this},type:function(a){if(null==d.ids.type&&(d.ids.type=[]),null==a)return d.ids.type;if(g(a))d.ids.type.push(a);else{if(!e(a))throw new TypeError("Argument must be a string or an array");d.ids.type=a}return this}})},y.IndicesFilter=function(a,b){if(!n(a))throw new TypeError("Argument must be a Filter");var d=y.FilterMixin("indices"),f=d.toJSON();if(f.indices.filter=a.toJSON(),g(b))f.indices.indices=[b];else{if(!e(b))throw new TypeError("Argument must be a string or array");f.indices.indices=b}return c(d,{indices:function(a){if(null==a)return f.indices.indices;if(g(a))f.indices.indices.push(a);else{if(!e(a))throw new TypeError("Argument must be a string or array");f.indices.indices=a}return this},filter:function(a){if(null==a)return f.indices.filter;if(!n(a))throw new TypeError("Argument must be a Filter");return f.indices.filter=a.toJSON(),this},noMatchFilter:function(a){if(null==a)return f.indices.no_match_filter;if(g(a))a=a.toLowerCase(),("none"===a||"all"===a)&&(f.indices.no_match_filter=a);else{if(!n(a))throw new TypeError("Argument must be string or Filter");f.indices.no_match_filter=a.toJSON()}return this}})},y.LimitFilter=function(a){var b=y.FilterMixin("limit"),d=b.toJSON();return d.limit.value=a,c(b,{value:function(a){if(null==a)return d.limit.value;if(!h(a))throw new TypeError("Argument must be a numeric value");return d.limit.value=a,this}})},y.MatchAllFilter=function(){return y.FilterMixin("match_all")},y.MissingFilter=function(a){var b=y.FilterMixin("missing"),d=b.toJSON();return d.missing.field=a,c(b,{field:function(a){return null==a?d.missing.field:(d.missing.field=a,this)},existence:function(a){return null==a?d.missing.existence:(d.missing.existence=a,this)},nullValue:function(a){return null==a?d.missing.null_value:(d.missing.null_value=a,this)}})},y.NestedFilter=function(a){var b=y.FilterMixin("nested"),d=b.toJSON();return d.nested.path=a,c(b,{path:function(a){return null==a?d.nested.path:(d.nested.path=a,this)},query:function(a){if(null==a)return d.nested.query;if(!l(a))throw new TypeError("Argument must be a Query object");return d.nested.query=a.toJSON(),this},filter:function(a){if(null==a)return d.nested.filter;if(!n(a))throw new TypeError("Argument must be a Filter object");return d.nested.filter=a.toJSON(),this},boost:function(a){return null==a?d.nested.boost:(d.nested.boost=a,this)},join:function(a){return null==a?d.nested.join:(d.nested.join=a,this)},scope:function(){return this}})},y.NotFilter=function(a){if(!n(a))throw new TypeError("Argument must be a Filter");var b=y.FilterMixin("not"),d=b.toJSON();return d.not=a.toJSON(),c(b,{filter:function(a){if(null==a)return d.not;if(!n(a))throw new TypeError("Argument must be a Filter");return d.not=a.toJSON(),this}})},y.NumericRangeFilter=function(a){var b=y.FilterMixin("numeric_range"),d=b.toJSON();return d.numeric_range[a]={},c(b,{field:function(b){var c=d.numeric_range[a];return null==b?a:(delete d.numeric_range[a],a=b,d.numeric_range[a]=c,this)},from:function(b){if(null==b)return d.numeric_range[a].from;if(!h(b))throw new TypeError("Argument must be a numeric value");return d.numeric_range[a].from=b,this},to:function(b){if(null==b)return d.numeric_range[a].to;if(!h(b))throw new TypeError("Argument must be a numeric value");return d.numeric_range[a].to=b,this},includeLower:function(b){return null==b?d.numeric_range[a].include_lower:(d.numeric_range[a].include_lower=b,this)},includeUpper:function(b){return null==b?d.numeric_range[a].include_upper:(d.numeric_range[a].include_upper=b,this)},gt:function(b){if(null==b)return d.numeric_range[a].gt;if(!h(b))throw new TypeError("Argument must be a numeric value");return d.numeric_range[a].gt=b,this},gte:function(b){if(null==b)return d.numeric_range[a].gte;if(!h(b))throw new TypeError("Argument must be a numeric value");return d.numeric_range[a].gte=b,this},lt:function(b){if(null==b)return d.numeric_range[a].lt;if(!h(b))throw new TypeError("Argument must be a numeric value");return d.numeric_range[a].lt=b,this},lte:function(b){if(null==b)return d.numeric_range[a].lte;if(!h(b))throw new TypeError("Argument must be a numeric value");return d.numeric_range[a].lte=b,this}})},y.OrFilter=function(a){var b,d,f=y.FilterMixin("or"),g=f.toJSON();if(g.or.filters=[],n(a))g.or.filters.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be a Filter or array of Filters");for(b=0,d=a.length;d>b;b++){if(!n(a[b]))throw new TypeError("Argument must be array of Filters");g.or.filters.push(a[b].toJSON())}}return c(f,{filters:function(a){var b,c;if(null==a)return g.or.filters;if(n(a))g.or.filters.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be a Filter or array of Filters");for(g.or.filters=[],b=0,c=a.length;c>b;b++){if(!n(a[b]))throw new TypeError("Argument must be an array of Filters");g.or.filters.push(a[b].toJSON())}}return this}})},y.PrefixFilter=function(a,b){var d=y.FilterMixin("prefix"),e=d.toJSON();return e.prefix[a]=b,c(d,{field:function(b){var c=e.prefix[a];return null==b?a:(delete e.prefix[a],a=b,e.prefix[a]=c,this)},prefix:function(b){return null==b?e.prefix[a]:(e.prefix[a]=b,this)}})},y.QueryFilter=function(a){if(!l(a))throw new TypeError("Argument must be a Query");var b=y.FilterMixin("fquery"),d=b.toJSON();return d.fquery.query=a.toJSON(),c(b,{query:function(a){if(null==a)return d.fquery.query;if(!l(a))throw new TypeError("Argument must be a Query");return d.fquery.query=a.toJSON(),this}})},y.RangeFilter=function(a){var b=y.FilterMixin("range"),d=b.toJSON();return d.range[a]={},c(b,{field:function(b){var c=d.range[a];return null==b?a:(delete d.range[a],a=b,d.range[b]=c,this)},from:function(b){return null==b?d.range[a].from:(d.range[a].from=b,this)},to:function(b){return null==b?d.range[a].to:(d.range[a].to=b,this)},includeLower:function(b){return null==b?d.range[a].include_lower:(d.range[a].include_lower=b,this)},includeUpper:function(b){return null==b?d.range[a].include_upper:(d.range[a].include_upper=b,this)},gt:function(b){return null==b?d.range[a].gt:(d.range[a].gt=b,this)},gte:function(b){return null==b?d.range[a].gte:(d.range[a].gte=b,this)},lt:function(b){return null==b?d.range[a].lt:(d.range[a].lt=b,this)},lte:function(b){return null==b?d.range[a].lte:(d.range[a].lte=b,this)}})},y.RegexpFilter=function(a,b){var d=y.FilterMixin("regexp"),e=d.toJSON();return e.regexp[a]={value:b},c(d,{field:function(b){var c=e.regexp[a];return null==b?a:(delete e.regexp[a],a=b,e.regexp[b]=c,this)},value:function(b){return null==b?e.regexp[a].value:(e.regexp[a].value=b,this)},flags:function(b){return null==b?e.regexp[a].flags:(e.regexp[a].flags=b,this)},flagsValue:function(b){return null==b?e.regexp[a].flags_value:(e.regexp[a].flags_value=b,this)}})},y.ScriptFilter=function(a){var b=y.FilterMixin("script"),d=b.toJSON();return d.script.script=a,c(b,{script:function(a){return null==a?d.script.script:(d.script.script=a,this)},params:function(a){return null==a?d.script.params:(d.script.params=a,this)},lang:function(a){return null==a?d.script.lang:(d.script.lang=a,this)}})},y.TermFilter=function(a,b){var d=y.FilterMixin("term"),e=d.toJSON();return e.term[a]=b,c(d,{field:function(b){var c=e.term[a];return null==b?a:(delete e.term[a],a=b,e.term[a]=c,this)},term:function(b){return null==b?e.term[a]:(e.term[a]=b,this)}})},y.TermsFilter=function(a,b){var d=y.FilterMixin("terms"),f=d.toJSON(),g=function(){e(f.terms[a])||(f.terms[a]=[])},h=function(){e(f.terms[a])&&(f.terms[a]={})};return f.terms[a]=e(b)?b:[b],c(d,{field:function(b){var c=f.terms[a];return null==b?a:(delete f.terms[a],a=b,f.terms[b]=c,this)},terms:function(b){return g(),null==b?f.terms[a]:(e(b)?f.terms[a]=b:f.terms[a].push(b),this)},index:function(b){return h(),null==b?f.terms[a].index:(f.terms[a].index=b,this)},type:function(b){return h(),null==b?f.terms[a].type:(f.terms[a].type=b,this)},id:function(b){return h(),null==b?f.terms[a].id:(f.terms[a].id=b,this)},path:function(b){return h(),null==b?f.terms[a].path:(f.terms[a].path=b,this)},routing:function(b){return h(),null==b?f.terms[a].routing:(f.terms[a].routing=b,this)},cacheLookup:function(b){return h(),null==b?f.terms[a].cache:(f.terms[a].cache=b,this)},execution:function(a){return null==a?f.terms.execution:(a=a.toLowerCase(),("plain"===a||"bool"===a||"bool_nocache"===a||"and"===a||"and_nocache"===a||"or"===a||"or_nocache"===a)&&(f.terms.execution=a),this)}})},y.TypeFilter=function(a){var b=y.FilterMixin("type"),d=b.toJSON();return d.type.value=a,c(b,{type:function(a){return null==a?d.type.value:(d.type.value=a,this)}})},y.BoolQuery=function(){var a=y.QueryMixin("bool"),b=a.toJSON();return c(a,{must:function(a){var c,d;if(null==b.bool.must&&(b.bool.must=[]),null==a)return b.bool.must;if(l(a))b.bool.must.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be a Query or array of Queries");for(b.bool.must=[],c=0,d=a.length;d>c;c++){if(!l(a[c]))throw new TypeError("Argument must be an array of Queries");b.bool.must.push(a[c].toJSON())}}return this},mustNot:function(a){var c,d;if(null==b.bool.must_not&&(b.bool.must_not=[]),null==a)return b.bool.must_not;if(l(a))b.bool.must_not.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be a Query or array of Queries");for(b.bool.must_not=[],c=0,d=a.length;d>c;c++){if(!l(a[c]))throw new TypeError("Argument must be an array of Queries");b.bool.must_not.push(a[c].toJSON())}}return this},should:function(a){var c,d;if(null==b.bool.should&&(b.bool.should=[]),null==a)return b.bool.should;if(l(a))b.bool.should.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be a Query or array of Queries");for(b.bool.should=[],c=0,d=a.length;d>c;c++){if(!l(a[c]))throw new TypeError("Argument must be an array of Queries");b.bool.should.push(a[c].toJSON())}}return this},adjustPureNegative:function(a){return null==a?b.bool.adjust_pure_negative:(b.bool.adjust_pure_negative=a,this)},disableCoord:function(a){return null==a?b.bool.disable_coord:(b.bool.disable_coord=a,this)},minimumNumberShouldMatch:function(a){return null==a?b.bool.minimum_number_should_match:(b.bool.minimum_number_should_match=a,this)}})},y.BoostingQuery=function(a,b,d){if(!l(a)||!l(b))throw new TypeError("Arguments must be Queries");var e=y.QueryMixin("boosting"),f=e.toJSON();return f.boosting.positive=a.toJSON(),f.boosting.negative=b.toJSON(),f.boosting.negative_boost=d,c(e,{positive:function(a){if(null==a)return f.boosting.positive;if(!l(a))throw new TypeError("Argument must be a Query");return f.boosting.positive=a.toJSON(),this},negative:function(a){if(null==a)return f.boosting.negative;if(!l(a))throw new TypeError("Argument must be a Query");return f.boosting.negative=a.toJSON(),this},negativeBoost:function(a){return null==a?f.boosting.negative_boost:(f.boosting.negative_boost=a,this)}})},y.CommonTermsQuery=function(a,b){var d=y.QueryMixin("common"),e=d.toJSON();return null==a&&(a="no_field_set"),e.common[a]={},null!=b&&(e.common[a].query=b),c(d,{field:function(b){var c=e.common[a];return null==b?a:(delete e.common[a],a=b,e.common[b]=c,this)},query:function(b){return null==b?e.common[a].query:(e.common[a].query=b,this)},analyzer:function(b){return null==b?e.common[a].analyzer:(e.common[a].analyzer=b,this)},disableCoord:function(b){return null==b?e.common[a].disable_coord:(e.common[a].disable_coord=b,this)},cutoffFrequency:function(b){return null==b?e.common[a].cutoff_frequency:(e.common[a].cutoff_frequency=b,this)},highFreqOperator:function(b){return null==b?e.common[a].high_freq_operator:(b=b.toLowerCase(),("and"===b||"or"===b)&&(e.common[a].high_freq_operator=b),this)},lowFreqOperator:function(b){return null==b?e.common[a].low_freq_operator:(b=b.toLowerCase(),("and"===b||"or"===b)&&(e.common[a].low_freq_operator=b),this)},minimumShouldMatch:function(b){return null==b?e.common[a].minimum_should_match.low_freq:(null==e.common[a].minimum_should_match&&(e.common[a].minimum_should_match={}),e.common[a].minimum_should_match.low_freq=b,this)},minimumShouldMatchLowFreq:function(a){return this.minimumShouldMatch(a)},minimumShouldMatchHighFreq:function(b){return null==b?e.common[a].minimum_should_match.high_freq:(null==e.common[a].minimum_should_match&&(e.common[a].minimum_should_match={}),e.common[a].minimum_should_match.high_freq=b,this)},boost:function(b){return null==b?e.common[a].boost:(e.common[a].boost=b,this)}})},y.ConstantScoreQuery=function(){var a=y.QueryMixin("constant_score"),b=a.toJSON();return c(a,{query:function(a){if(null==a)return b.constant_score.query;if(!l(a))throw new TypeError("Argument must be a Query");return b.constant_score.query=a.toJSON(),this},filter:function(a){if(null==a)return b.constant_score.filter;if(!n(a))throw new TypeError("Argument must be a Filter");return b.constant_score.filter=a.toJSON(),this},cache:function(a){return null==a?b.constant_score._cache:(b.constant_score._cache=a,this)},cacheKey:function(a){return null==a?b.constant_score._cache_key:(b.constant_score._cache_key=a,this)}})},y.CustomBoostFactorQuery=function(a){if(!l(a))throw new TypeError("Argument must be a Query");var b=y.QueryMixin("custom_boost_factor"),d=b.toJSON();return d.custom_boost_factor.query=a.toJSON(),c(b,{query:function(a){if(null==a)return d.custom_boost_factor.query;if(!l(a))throw new TypeError("Argument must be a Query");return d.custom_boost_factor.query=a.toJSON(),this},boostFactor:function(a){return null==a?d.custom_boost_factor.boost_factor:(d.custom_boost_factor.boost_factor=a,this)}})},y.CustomFiltersScoreQuery=function(a,d){if(!l(a))throw new TypeError("Argument must be a Query");var f=y.QueryMixin("custom_filters_score"),g=f.toJSON(),h=function(a){var b=null;return a.filter&&n(a.filter)&&(b={filter:a.filter.toJSON()},a.boost?b.boost=a.boost:a.script?b.script=a.script:b=null),b};return g.custom_filters_score.query=a.toJSON(),g.custom_filters_score.filters=[],b(e(d)?d:[d],function(a){var b=h(a);null!==b&&g.custom_filters_score.filters.push(b)}),c(f,{query:function(a){if(null==a)return g.custom_filters_score.query;if(!l(a))throw new TypeError("Argument must be a Query");return g.custom_filters_score.query=a.toJSON(),this},filters:function(a){return null==a?g.custom_filters_score.filters:(e(a)&&(g.custom_filters_score.filters=[]),b(e(a)?a:[a],function(a){var b=h(a);null!==b&&g.custom_filters_score.filters.push(b)}),this)},scoreMode:function(a){return null==a?g.custom_filters_score.score_mode:(a=a.toLowerCase(),("first"===a||"min"===a||"max"===a||"total"===a||"avg"===a||"multiply"===a)&&(g.custom_filters_score.score_mode=a),this)},params:function(a){return null==a?g.custom_filters_score.params:(g.custom_filters_score.params=a,this)},lang:function(a){return null==a?g.custom_filters_score.lang:(g.custom_filters_score.lang=a,this)},maxBoost:function(a){return null==a?g.custom_filters_score.max_boost:(g.custom_filters_score.max_boost=a,this)}})},y.CustomScoreQuery=function(a,b){if(!l(a)&&!n(a))throw new TypeError("Argument must be a Query or Filter");var d=y.QueryMixin("custom_score"),e=d.toJSON();return e.custom_score.script=b,l(a)?e.custom_score.query=a.toJSON():n(a)&&(e.custom_score.filter=a.toJSON()),c(d,{query:function(a){if(null==a)return e.custom_score.query;if(!l(a))throw new TypeError("Argument must be a Query");return e.custom_score.query=a.toJSON(),this},filter:function(a){if(null==a)return e.custom_score.filter;if(!n(a))throw new TypeError("Argument must be a Filter");return e.custom_score.filter=a.toJSON(),this},script:function(a){return null==a?e.custom_score.script:(e.custom_score.script=a,this)},params:function(a){return null==a?e.custom_score.params:(e.custom_score.params=a,this)},lang:function(a){return null==a?e.custom_score.lang:(e.custom_score.lang=a,this)}})},y.DisMaxQuery=function(){var a=y.QueryMixin("dis_max"),b=a.toJSON();return c(a,{queries:function(a){var c,d;if(null==a)return b.dis_max.queries;if(null==b.dis_max.queries&&(b.dis_max.queries=[]),l(a))b.dis_max.queries.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be a Query or array of Queries");for(b.dis_max.queries=[],c=0,d=a.length;d>c;c++){if(!l(a[c]))throw new TypeError("Argument must be array of Queries");b.dis_max.queries.push(a[c].toJSON())}}return this},tieBreaker:function(a){return null==a?b.dis_max.tie_breaker:(b.dis_max.tie_breaker=a,this)}})},y.FieldMaskingSpanQuery=function(a,b){if(!l(a))throw new TypeError("Argument must be a SpanQuery");var d=y.QueryMixin("field_masking_span"),e=d.toJSON();return e.field_masking_span.query=a.toJSON(),e.field_masking_span.field=b,c(d,{query:function(a){if(null==a)return e.field_masking_span.query;if(!l(a))throw new TypeError("Argument must be a SpanQuery");return e.field_masking_span.query=a.toJSON(),this},field:function(a){return null==a?e.field_masking_span.field:(e.field_masking_span.field=a,this)}})},y.FieldQuery=function(a,b){var d=y.QueryMixin("field"),e=d.toJSON();return e.field[a]={query:b},c(d,{field:function(b){var c=e.field[a];return null==b?a:(delete e.field[a],a=b,e.field[b]=c,this)},query:function(b){return null==b?e.field[a].query:(e.field[a].query=b,this)},defaultOperator:function(b){return null==b?e.field[a].default_operator:(b=b.toUpperCase(),("AND"===b||"OR"===b)&&(e.field[a].default_operator=b),this)},analyzer:function(b){return null==b?e.field[a].analyzer:(e.field[a].analyzer=b,this)},quoteAnalyzer:function(b){return null==b?e.field[a].quote_analyzer:(e.field[a].quote_analyzer=b,this)},autoGeneratePhraseQueries:function(b){return null==b?e.field[a].auto_generate_phrase_queries:(e.field[a].auto_generate_phrase_queries=b,this)},allowLeadingWildcard:function(b){return null==b?e.field[a].allow_leading_wildcard:(e.field[a].allow_leading_wildcard=b,this)},lowercaseExpandedTerms:function(b){return null==b?e.field[a].lowercase_expanded_terms:(e.field[a].lowercase_expanded_terms=b,this)},enablePositionIncrements:function(b){return null==b?e.field[a].enable_position_increments:(e.field[a].enable_position_increments=b,this)},fuzzyMinSim:function(b){return null==b?e.field[a].fuzzy_min_sim:(e.field[a].fuzzy_min_sim=b,this)},fuzzyPrefixLength:function(b){return null==b?e.field[a].fuzzy_prefix_length:(e.field[a].fuzzy_prefix_length=b,this)},fuzzyMaxExpansions:function(b){return null==b?e.field[a].fuzzy_max_expansions:(e.field[a].fuzzy_max_expansions=b,this)},fuzzyRewrite:function(b){return null==b?e.field[a].fuzzy_rewrite:(b=b.toLowerCase(),("constant_score_auto"===b||"scoring_boolean"===b||"constant_score_boolean"===b||"constant_score_filter"===b||0===b.indexOf("top_terms_boost_")||0===b.indexOf("top_terms_"))&&(e.field[a].fuzzy_rewrite=b),this)},rewrite:function(b){return null==b?e.field[a].rewrite:(b=b.toLowerCase(),("constant_score_auto"===b||"scoring_boolean"===b||"constant_score_boolean"===b||"constant_score_filter"===b||0===b.indexOf("top_terms_boost_")||0===b.indexOf("top_terms_"))&&(e.field[a].rewrite=b),this)},quoteFieldSuffix:function(b){return null==b?e.field[a].quote_field_suffix:(e.field[a].quote_field_suffix=b,this)},phraseSlop:function(b){return null==b?e.field[a].phrase_slop:(e.field[a].phrase_slop=b,this)},analyzeWildcard:function(b){return null==b?e.field[a].analyze_wildcard:(e.field[a].analyze_wildcard=b,this)},escape:function(b){return null==b?e.field[a].escape:(e.field[a].escape=b,this)},minimumShouldMatch:function(b){return null==b?e.field[a].minimum_should_match:(e.field[a].minimum_should_match=b,this)},boost:function(b){return null==b?e.field[a].boost:(e.field[a].boost=b,this)}})},y.FilteredQuery=function(a,b){if(!l(a))throw new TypeError("Argument must be a Query");if(null!=b&&!n(b))throw new TypeError("Argument must be a Filter");var d=y.QueryMixin("filtered"),e=d.toJSON();return e.filtered.query=a.toJSON(),null!=b&&(e.filtered.filter=b.toJSON()),c(d,{query:function(a){if(null==a)return e.filtered.query;if(!l(a))throw new TypeError("Argument must be a Query");return e.filtered.query=a.toJSON(),this},filter:function(a){if(null==a)return e.filtered.filter;if(!n(a))throw new TypeError("Argument must be a Filter");return e.filtered.filter=a.toJSON(),this},strategy:function(a){return null==a?e.filtered.strategy:(a=a.toLowerCase(),("query_first"===a||"random_access_always"===a||"leap_frog"===a||"leap_frog_filter_first"===a||0===a.indexOf("random_access_"))&&(e.filtered.strategy=a),this)},cache:function(a){return null==a?e.filtered._cache:(e.filtered._cache=a,this)},cacheKey:function(a){return null==a?e.filtered._cache_key:(e.filtered._cache_key=a,this)}})},y.FuzzyLikeThisFieldQuery=function(a,b){var d=y.QueryMixin("flt_field"),e=d.toJSON();return e.flt_field[a]={like_text:b},c(d,{field:function(b){var c=e.flt_field[a];return null==b?a:(delete e.flt_field[a],a=b,e.flt_field[b]=c,this)},likeText:function(b){return null==b?e.flt_field[a].like_text:(e.flt_field[a].like_text=b,this)},ignoreTf:function(b){return null==b?e.flt_field[a].ignore_tf:(e.flt_field[a].ignore_tf=b,this)},maxQueryTerms:function(b){return null==b?e.flt_field[a].max_query_terms:(e.flt_field[a].max_query_terms=b,this)},minSimilarity:function(b){return null==b?e.flt_field[a].min_similarity:(e.flt_field[a].min_similarity=b,this)},prefixLength:function(b){return null==b?e.flt_field[a].prefix_length:(e.flt_field[a].prefix_length=b,this)},analyzer:function(b){return null==b?e.flt_field[a].analyzer:(e.flt_field[a].analyzer=b,this)},failOnUnsupportedField:function(b){return null==b?e.flt_field[a].fail_on_unsupported_field:(e.flt_field[a].fail_on_unsupported_field=b,this)},boost:function(b){return null==b?e.flt_field[a].boost:(e.flt_field[a].boost=b,this)}})},y.FuzzyLikeThisQuery=function(a){var b=y.QueryMixin("flt"),d=b.toJSON();return d.flt.like_text=a,c(b,{fields:function(a){if(null==d.flt.fields&&(d.flt.fields=[]),null==a)return d.flt.fields;if(g(a))d.flt.fields.push(a);else{if(!e(a))throw new TypeError("Argument must be a string or array");d.flt.fields=a}return this},likeText:function(a){return null==a?d.flt.like_text:(d.flt.like_text=a,this)},ignoreTf:function(a){return null==a?d.flt.ignore_tf:(d.flt.ignore_tf=a,this)},maxQueryTerms:function(a){return null==a?d.flt.max_query_terms:(d.flt.max_query_terms=a,this)},minSimilarity:function(a){return null==a?d.flt.min_similarity:(d.flt.min_similarity=a,this)},prefixLength:function(a){return null==a?d.flt.prefix_length:(d.flt.prefix_length=a,this)},analyzer:function(a){return null==a?d.flt.analyzer:(d.flt.analyzer=a,this)},failOnUnsupportedField:function(a){return null==a?d.flt.fail_on_unsupported_field:(d.flt.fail_on_unsupported_field=a,this)}})},y.FuzzyQuery=function(a,b){var d=y.QueryMixin("fuzzy"),e=d.toJSON();return e.fuzzy[a]={value:b},c(d,{field:function(b){var c=e.fuzzy[a];return null==b?a:(delete e.fuzzy[a],a=b,e.fuzzy[b]=c,this)},value:function(b){return null==b?e.fuzzy[a].value:(e.fuzzy[a].value=b,this)},transpositions:function(b){return null==b?e.fuzzy[a].transpositions:(e.fuzzy[a].transpositions=b,this)},maxExpansions:function(b){return null==b?e.fuzzy[a].max_expansions:(e.fuzzy[a].max_expansions=b,this)},minSimilarity:function(b){return null==b?e.fuzzy[a].min_similarity:(e.fuzzy[a].min_similarity=b,this)},prefixLength:function(b){return null==b?e.fuzzy[a].prefix_length:(e.fuzzy[a].prefix_length=b,this)},rewrite:function(b){return null==b?e.fuzzy[a].rewrite:(b=b.toLowerCase(),("constant_score_auto"===b||"scoring_boolean"===b||"constant_score_boolean"===b||"constant_score_filter"===b||0===b.indexOf("top_terms_boost_")||0===b.indexOf("top_terms_"))&&(e.fuzzy[a].rewrite=b),this)},boost:function(b){return null==b?e.fuzzy[a].boost:(e.fuzzy[a].boost=b,this)}})},y.GeoShapeQuery=function(a){var b=y.QueryMixin("geo_shape"),d=b.toJSON();return d.geo_shape[a]={},c(b,{field:function(b){var c=d.geo_shape[a];return null==b?a:(delete d.geo_shape[a],a=b,d.geo_shape[b]=c,this)},shape:function(b){return null==b?d.geo_shape[a].shape:(null!=d.geo_shape[a].indexed_shape&&delete d.geo_shape[a].indexed_shape,d.geo_shape[a].shape=b.toJSON(),this)},indexedShape:function(b){return null==b?d.geo_shape[a].indexed_shape:(null!=d.geo_shape[a].shape&&delete d.geo_shape[a].shape,d.geo_shape[a].indexed_shape=b.toJSON(),this)},relation:function(b){return null==b?d.geo_shape[a].relation:(b=b.toLowerCase(),("intersects"===b||"disjoint"===b||"within"===b)&&(d.geo_shape[a].relation=b),this)},strategy:function(b){return null==b?d.geo_shape[a].strategy:(b=b.toLowerCase(),("recursive"===b||"term"===b)&&(d.geo_shape[a].strategy=b),this)},boost:function(b){return null==b?d.geo_shape[a].boost:(d.geo_shape[a].boost=b,this)}})},y.HasChildQuery=function(a,b){if(!l(a))throw new TypeError("Argument must be a valid Query");var d=y.QueryMixin("has_child"),e=d.toJSON();return e.has_child.query=a.toJSON(),e.has_child.type=b,c(d,{query:function(a){if(null==a)return e.has_child.query;if(!l(a))throw new TypeError("Argument must be a valid Query");return e.has_child.query=a.toJSON(),this},type:function(a){return null==a?e.has_child.type:(e.has_child.type=a,this)},scope:function(){return this},scoreType:function(a){return null==a?e.has_child.score_type:(a=a.toLowerCase(),("none"===a||"max"===a||"sum"===a||"avg"===a)&&(e.has_child.score_type=a),this)},scoreMode:function(a){return null==a?e.has_child.score_mode:(a=a.toLowerCase(),("none"===a||"max"===a||"sum"===a||"avg"===a)&&(e.has_child.score_mode=a),this)},shortCircuitCutoff:function(a){return null==a?e.has_child.short_circuit_cutoff:(e.has_child.short_circuit_cutoff=a,this)}})},y.HasParentQuery=function(a,b){if(!l(a))throw new TypeError("Argument must be a Query");var d=y.QueryMixin("has_parent"),e=d.toJSON();return e.has_parent.query=a.toJSON(),e.has_parent.parent_type=b,c(d,{query:function(a){if(null==a)return e.has_parent.query;if(!l(a))throw new TypeError("Argument must be a Query");return e.has_parent.query=a.toJSON(),this},parentType:function(a){return null==a?e.has_parent.parent_type:(e.has_parent.parent_type=a,this)},scope:function(){return this -},scoreType:function(a){return null==a?e.has_parent.score_type:(a=a.toLowerCase(),("none"===a||"score"===a)&&(e.has_parent.score_type=a),this)},scoreMode:function(a){return null==a?e.has_parent.score_mode:(a=a.toLowerCase(),("none"===a||"score"===a)&&(e.has_parent.score_mode=a),this)}})},y.IdsQuery=function(a){var b=y.QueryMixin("ids"),d=b.toJSON();if(g(a))d.ids.values=[a];else{if(!e(a))throw new TypeError("Argument must be string or array");d.ids.values=a}return c(b,{values:function(a){if(null==a)return d.ids.values;if(g(a))d.ids.values.push(a);else{if(!e(a))throw new TypeError("Argument must be string or array");d.ids.values=a}return this},type:function(a){if(null==d.ids.type&&(d.ids.type=[]),null==a)return d.ids.type;if(g(a))d.ids.type.push(a);else{if(!e(a))throw new TypeError("Argument must be string or array");d.ids.type=a}return this}})},y.IndicesQuery=function(a,b){if(!l(a))throw new TypeError("Argument must be a Query");var d=y.QueryMixin("indices"),f=d.toJSON();if(f.indices.query=a.toJSON(),g(b))f.indices.indices=[b];else{if(!e(b))throw new TypeError("Argument must be a string or array");f.indices.indices=b}return c(d,{indices:function(a){if(null==a)return f.indices.indices;if(g(a))f.indices.indices.push(a);else{if(!e(a))throw new TypeError("Argument must be a string or array");f.indices.indices=a}return this},query:function(a){if(null==a)return f.indices.query;if(!l(a))throw new TypeError("Argument must be a Query");return f.indices.query=a.toJSON(),this},noMatchQuery:function(a){if(null==a)return f.indices.no_match_query;if(g(a))a=a.toLowerCase(),("none"===a||"all"===a)&&(f.indices.no_match_query=a);else{if(!l(a))throw new TypeError("Argument must be string or Query");f.indices.no_match_query=a.toJSON()}return this}})},y.MatchAllQuery=function(){return y.QueryMixin("match_all")},y.MatchQuery=function(a,b){var d=y.QueryMixin("match"),e=d.toJSON();return e.match[a]={query:b},c(d,{query:function(b){return null==b?e.match[a].query:(e.match[a].query=b,this)},type:function(b){return null==b?e.match[a].type:(b=b.toLowerCase(),("boolean"===b||"phrase"===b||"phrase_prefix"===b)&&(e.match[a].type=b),this)},fuzziness:function(b){return null==b?e.match[a].fuzziness:(e.match[a].fuzziness=b,this)},cutoffFrequency:function(b){return null==b?e.match[a].cutoff_frequency:(e.match[a].cutoff_frequency=b,this)},prefixLength:function(b){return null==b?e.match[a].prefix_length:(e.match[a].prefix_length=b,this)},maxExpansions:function(b){return null==b?e.match[a].max_expansions:(e.match[a].max_expansions=b,this)},operator:function(b){return null==b?e.match[a].operator:(b=b.toLowerCase(),("and"===b||"or"===b)&&(e.match[a].operator=b),this)},slop:function(b){return null==b?e.match[a].slop:(e.match[a].slop=b,this)},analyzer:function(b){return null==b?e.match[a].analyzer:(e.match[a].analyzer=b,this)},minimumShouldMatch:function(b){return null==b?e.match[a].minimum_should_match:(e.match[a].minimum_should_match=b,this)},rewrite:function(b){return null==b?e.match[a].rewrite:(b=b.toLowerCase(),("constant_score_auto"===b||"scoring_boolean"===b||"constant_score_boolean"===b||"constant_score_filter"===b||0===b.indexOf("top_terms_boost_")||0===b.indexOf("top_terms_"))&&(e.match[a].rewrite=b),this)},fuzzyRewrite:function(b){return null==b?e.match[a].fuzzy_rewrite:(b=b.toLowerCase(),("constant_score_auto"===b||"scoring_boolean"===b||"constant_score_boolean"===b||"constant_score_filter"===b||0===b.indexOf("top_terms_boost_")||0===b.indexOf("top_terms_"))&&(e.match[a].fuzzy_rewrite=b),this)},fuzzyTranspositions:function(b){return null==b?e.match[a].fuzzy_transpositions:(e.match[a].fuzzy_transpositions=b,this)},lenient:function(b){return null==b?e.match[a].lenient:(e.match[a].lenient=b,this)},zeroTermsQuery:function(b){return null==b?e.match[a].zero_terms_query:(b=b.toLowerCase(),("all"===b||"none"===b)&&(e.match[a].zero_terms_query=b),this)},boost:function(b){return null==b?e.match[a].boost:(e.match[a].boost=b,this)}})},y.MoreLikeThisFieldQuery=function(a,b){var d=y.QueryMixin("mlt_field"),e=d.toJSON();return e.mlt_field[a]={like_text:b},c(d,{field:function(b){var c=e.mlt_field[a];return null==b?a:(delete e.mlt_field[a],a=b,e.mlt_field[b]=c,this)},likeText:function(b){return null==b?e.mlt_field[a].like_text:(e.mlt_field[a].like_text=b,this)},percentTermsToMatch:function(b){return null==b?e.mlt_field[a].percent_terms_to_match:(e.mlt_field[a].percent_terms_to_match=b,this)},minTermFreq:function(b){return null==b?e.mlt_field[a].min_term_freq:(e.mlt_field[a].min_term_freq=b,this)},maxQueryTerms:function(b){return null==b?e.mlt_field[a].max_query_terms:(e.mlt_field[a].max_query_terms=b,this)},stopWords:function(b){return null==b?e.mlt_field[a].stop_words:(e.mlt_field[a].stop_words=b,this)},minDocFreq:function(b){return null==b?e.mlt_field[a].min_doc_freq:(e.mlt_field[a].min_doc_freq=b,this)},maxDocFreq:function(b){return null==b?e.mlt_field[a].max_doc_freq:(e.mlt_field[a].max_doc_freq=b,this)},minWordLen:function(b){return null==b?e.mlt_field[a].min_word_len:(e.mlt_field[a].min_word_len=b,this)},maxWordLen:function(b){return null==b?e.mlt_field[a].max_word_len:(e.mlt_field[a].max_word_len=b,this)},analyzer:function(b){return null==b?e.mlt_field[a].analyzer:(e.mlt_field[a].analyzer=b,this)},boostTerms:function(b){return null==b?e.mlt_field[a].boost_terms:(e.mlt_field[a].boost_terms=b,this)},failOnUnsupportedField:function(b){return null==b?e.mlt_field[a].fail_on_unsupported_field:(e.mlt_field[a].fail_on_unsupported_field=b,this)},boost:function(b){return null==b?e.mlt_field[a].boost:(e.mlt_field[a].boost=b,this)}})},y.MoreLikeThisQuery=function(a,b){var d=y.QueryMixin("mlt"),f=d.toJSON();if(f.mlt.like_text=b,f.mlt.fields=[],g(a))f.mlt.fields.push(a);else{if(!e(a))throw new TypeError("Argument must be string or array");f.mlt.fields=a}return c(d,{fields:function(a){if(null==a)return f.mlt.fields;if(g(a))f.mlt.fields.push(a);else{if(!e(a))throw new TypeError("Argument must be a string or array");f.mlt.fields=a}return this},likeText:function(a){return null==a?f.mlt.like_text:(f.mlt.like_text=a,this)},percentTermsToMatch:function(a){return null==a?f.mlt.percent_terms_to_match:(f.mlt.percent_terms_to_match=a,this)},minTermFreq:function(a){return null==a?f.mlt.min_term_freq:(f.mlt.min_term_freq=a,this)},maxQueryTerms:function(a){return null==a?f.mlt.max_query_terms:(f.mlt.max_query_terms=a,this)},stopWords:function(a){return null==a?f.mlt.stop_words:(f.mlt.stop_words=a,this)},minDocFreq:function(a){return null==a?f.mlt.min_doc_freq:(f.mlt.min_doc_freq=a,this)},maxDocFreq:function(a){return null==a?f.mlt.max_doc_freq:(f.mlt.max_doc_freq=a,this)},minWordLen:function(a){return null==a?f.mlt.min_word_len:(f.mlt.min_word_len=a,this)},maxWordLen:function(a){return null==a?f.mlt.max_word_len:(f.mlt.max_word_len=a,this)},analyzer:function(a){return null==a?f.mlt.analyzer:(f.mlt.analyzer=a,this)},boostTerms:function(a){return null==a?f.mlt.boost_terms:(f.mlt.boost_terms=a,this)},failOnUnsupportedField:function(a){return null==a?f.mlt.fail_on_unsupported_field:(f.mlt.fail_on_unsupported_field=a,this)}})},y.MultiMatchQuery=function(a,b){var d=y.QueryMixin("multi_match"),f=d.toJSON();if(f.multi_match.query=b,f.multi_match.fields=[],g(a))f.multi_match.fields.push(a);else{if(!e(a))throw new TypeError("Argument must be string or array");f.multi_match.fields=a}return c(d,{fields:function(a){if(null==a)return f.multi_match.fields;if(g(a))f.multi_match.fields.push(a);else{if(!e(a))throw new TypeError("Argument must be string or array");f.multi_match.fields=a}return this},useDisMax:function(a){return null==a?f.multi_match.use_dis_max:(f.multi_match.use_dis_max=a,this)},tieBreaker:function(a){return null==a?f.multi_match.tie_breaker:(f.multi_match.tie_breaker=a,this)},cutoffFrequency:function(a){return null==a?f.multi_match.cutoff_frequency:(f.multi_match.cutoff_frequency=a,this)},minimumShouldMatch:function(a){return null==a?f.multi_match.minimum_should_match:(f.multi_match.minimum_should_match=a,this)},rewrite:function(a){return null==a?f.multi_match.rewrite:(a=a.toLowerCase(),("constant_score_auto"===a||"scoring_boolean"===a||"constant_score_boolean"===a||"constant_score_filter"===a||0===a.indexOf("top_terms_boost_")||0===a.indexOf("top_terms_"))&&(f.multi_match.rewrite=a),this)},fuzzyRewrite:function(a){return null==a?f.multi_match.fuzzy_rewrite:(a=a.toLowerCase(),("constant_score_auto"===a||"scoring_boolean"===a||"constant_score_boolean"===a||"constant_score_filter"===a||0===a.indexOf("top_terms_boost_")||0===a.indexOf("top_terms_"))&&(f.multi_match.fuzzy_rewrite=a),this)},lenient:function(a){return null==a?f.multi_match.lenient:(f.multi_match.lenient=a,this)},query:function(a){return null==a?f.multi_match.query:(f.multi_match.query=a,this)},type:function(a){return null==a?f.multi_match.type:(a=a.toLowerCase(),("boolean"===a||"phrase"===a||"phrase_prefix"===a)&&(f.multi_match.type=a),this)},fuzziness:function(a){return null==a?f.multi_match.fuzziness:(f.multi_match.fuzziness=a,this)},prefixLength:function(a){return null==a?f.multi_match.prefix_length:(f.multi_match.prefix_length=a,this)},maxExpansions:function(a){return null==a?f.multi_match.max_expansions:(f.multi_match.max_expansions=a,this)},operator:function(a){return null==a?f.multi_match.operator:(a=a.toLowerCase(),("and"===a||"or"===a)&&(f.multi_match.operator=a),this)},slop:function(a){return null==a?f.multi_match.slop:(f.multi_match.slop=a,this)},analyzer:function(a){return null==a?f.multi_match.analyzer:(f.multi_match.analyzer=a,this)},zeroTermsQuery:function(a){return null==a?f.multi_match.zero_terms_query:(a=a.toLowerCase(),("all"===a||"none"===a)&&(f.multi_match.zero_terms_query=a),this)}})},y.NestedQuery=function(a){var b=y.QueryMixin("nested"),d=b.toJSON();return d.nested.path=a,c(b,{path:function(a){return null==a?d.nested.path:(d.nested.path=a,this)},query:function(a){if(null==a)return d.nested.query;if(!l(a))throw new TypeError("Argument must be a Query");return d.nested.query=a.toJSON(),this},filter:function(a){if(null==a)return d.nested.filter;if(!n(a))throw new TypeError("Argument must be a Filter");return d.nested.filter=a.toJSON(),this},scoreMode:function(a){return null==a?d.nested.score_mode:(a=a.toLowerCase(),("avg"===a||"total"===a||"max"===a||"none"===a||"sum"===a)&&(d.nested.score_mode=a),this)},scope:function(){return this}})},y.PrefixQuery=function(a,b){var d=y.QueryMixin("prefix"),e=d.toJSON();return e.prefix[a]={value:b},c(d,{field:function(b){var c=e.prefix[a];return null==b?a:(delete e.prefix[a],a=b,e.prefix[b]=c,this)},value:function(b){return null==b?e.prefix[a].value:(e.prefix[a].value=b,this)},rewrite:function(b){return null==b?e.prefix[a].rewrite:(b=b.toLowerCase(),("constant_score_auto"===b||"scoring_boolean"===b||"constant_score_boolean"===b||"constant_score_filter"===b||0===b.indexOf("top_terms_boost_")||0===b.indexOf("top_terms_"))&&(e.prefix[a].rewrite=b),this)},boost:function(b){return null==b?e.prefix[a].boost:(e.prefix[a].boost=b,this)}})},y.QueryStringQuery=function(a){var b=y.QueryMixin("query_string"),d=b.toJSON();return d.query_string.query=a,c(b,{query:function(a){return null==a?d.query_string.query:(d.query_string.query=a,this)},defaultField:function(a){return null==a?d.query_string.default_field:(d.query_string.default_field=a,this)},fields:function(a){if(null==d.query_string.fields&&(d.query_string.fields=[]),null==a)return d.query_string.fields;if(g(a))d.query_string.fields.push(a);else{if(!e(a))throw new TypeError("Argument must be a string or array");d.query_string.fields=a}return this},useDisMax:function(a){return null==a?d.query_string.use_dis_max:(d.query_string.use_dis_max=a,this)},defaultOperator:function(a){return null==a?d.query_string.default_operator:(a=a.toUpperCase(),("AND"===a||"OR"===a)&&(d.query_string.default_operator=a),this)},analyzer:function(a){return null==a?d.query_string.analyzer:(d.query_string.analyzer=a,this)},quoteAnalyzer:function(a){return null==a?d.query_string.quote_analyzer:(d.query_string.quote_analyzer=a,this)},allowLeadingWildcard:function(a){return null==a?d.query_string.allow_leading_wildcard:(d.query_string.allow_leading_wildcard=a,this)},lowercaseExpandedTerms:function(a){return null==a?d.query_string.lowercase_expanded_terms:(d.query_string.lowercase_expanded_terms=a,this)},enablePositionIncrements:function(a){return null==a?d.query_string.enable_position_increments:(d.query_string.enable_position_increments=a,this)},fuzzyPrefixLength:function(a){return null==a?d.query_string.fuzzy_prefix_length:(d.query_string.fuzzy_prefix_length=a,this)},fuzzyMinSim:function(a){return null==a?d.query_string.fuzzy_min_sim:(d.query_string.fuzzy_min_sim=a,this)},phraseSlop:function(a){return null==a?d.query_string.phrase_slop:(d.query_string.phrase_slop=a,this)},analyzeWildcard:function(a){return null==a?d.query_string.analyze_wildcard:(d.query_string.analyze_wildcard=a,this)},autoGeneratePhraseQueries:function(a){return null==a?d.query_string.auto_generate_phrase_queries:(d.query_string.auto_generate_phrase_queries=a,this)},minimumShouldMatch:function(a){return null==a?d.query_string.minimum_should_match:(d.query_string.minimum_should_match=a,this)},tieBreaker:function(a){return null==a?d.query_string.tie_breaker:(d.query_string.tie_breaker=a,this)},escape:function(a){return null==a?d.query_string.escape:(d.query_string.escape=a,this)},fuzzyMaxExpansions:function(a){return null==a?d.query_string.fuzzy_max_expansions:(d.query_string.fuzzy_max_expansions=a,this)},fuzzyRewrite:function(a){return null==a?d.query_string.fuzzy_rewrite:(a=a.toLowerCase(),("constant_score_auto"===a||"scoring_boolean"===a||"constant_score_boolean"===a||"constant_score_filter"===a||0===a.indexOf("top_terms_boost_")||0===a.indexOf("top_terms_"))&&(d.query_string.fuzzy_rewrite=a),this)},rewrite:function(a){return null==a?d.query_string.rewrite:(a=a.toLowerCase(),("constant_score_auto"===a||"scoring_boolean"===a||"constant_score_boolean"===a||"constant_score_filter"===a||0===a.indexOf("top_terms_boost_")||0===a.indexOf("top_terms_"))&&(d.query_string.rewrite=a),this)},quoteFieldSuffix:function(a){return null==a?d.query_string.quote_field_suffix:(d.query_string.quote_field_suffix=a,this)},lenient:function(a){return null==a?d.query_string.lenient:(d.query_string.lenient=a,this)}})},y.RangeQuery=function(a){var b=y.QueryMixin("range"),d=b.toJSON();return d.range[a]={},c(b,{field:function(b){var c=d.range[a];return null==b?a:(delete d.range[a],a=b,d.range[b]=c,this)},from:function(b){return null==b?d.range[a].from:(d.range[a].from=b,this)},to:function(b){return null==b?d.range[a].to:(d.range[a].to=b,this)},includeLower:function(b){return null==b?d.range[a].include_lower:(d.range[a].include_lower=b,this)},includeUpper:function(b){return null==b?d.range[a].include_upper:(d.range[a].include_upper=b,this)},gt:function(b){return null==b?d.range[a].gt:(d.range[a].gt=b,this)},gte:function(b){return null==b?d.range[a].gte:(d.range[a].gte=b,this)},lt:function(b){return null==b?d.range[a].lt:(d.range[a].lt=b,this)},lte:function(b){return null==b?d.range[a].lte:(d.range[a].lte=b,this)},boost:function(b){return null==b?d.range[a].boost:(d.range[a].boost=b,this)}})},y.RegexpQuery=function(a,b){var d=y.QueryMixin("regexp"),e=d.toJSON();return e.regexp[a]={value:b},c(d,{field:function(b){var c=e.regexp[a];return null==b?a:(delete e.regexp[a],a=b,e.regexp[b]=c,this)},value:function(b){return null==b?e.regexp[a].value:(e.regexp[a].value=b,this)},flags:function(b){return null==b?e.regexp[a].flags:(e.regexp[a].flags=b,this)},flagsValue:function(b){return null==b?e.regexp[a].flags_value:(e.regexp[a].flags_value=b,this)},rewrite:function(b){return null==b?e.regexp[a].rewrite:(b=b.toLowerCase(),("constant_score_auto"===b||"scoring_boolean"===b||"constant_score_boolean"===b||"constant_score_filter"===b||0===b.indexOf("top_terms_boost_")||0===b.indexOf("top_terms_"))&&(e.regexp[a].rewrite=b),this)},boost:function(b){return null==b?e.regexp[a].boost:(e.regexp[a].boost=b,this)}})},y.SpanFirstQuery=function(a,b){if(!l(a))throw new TypeError("Argument must be a SpanQuery");var d=y.QueryMixin("span_first"),e=d.toJSON();return e.span_first.match=a.toJSON(),e.span_first.end=b,c(d,{match:function(a){if(null==a)return e.span_first.match;if(!l(a))throw new TypeError("Argument must be a SpanQuery");return e.span_first.match=a.toJSON(),this},end:function(a){return null==a?e.span_first.end:(e.span_first.end=a,this)}})},y.SpanMultiTermQuery=function(a){if(null!=a&&!l(a))throw new TypeError("Argument must be a MultiTermQuery");var b=y.QueryMixin("span_multi"),d=b.toJSON();return d.span_multi.match={},null!=a&&(d.span_multi.match=a.toJSON()),c(b,{match:function(a){if(null==a)return d.span_multi.match;if(!l(a))throw new TypeError("Argument must be a MultiTermQuery");return d.span_multi.match=a.toJSON(),this}})},y.SpanNearQuery=function(a,b){var d,f,g=y.QueryMixin("span_near"),h=g.toJSON();if(h.span_near.clauses=[],h.span_near.slop=b,l(a))h.span_near.clauses.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be SpanQuery or array of SpanQueries");for(d=0,f=a.length;f>d;d++){if(!l(a[d]))throw new TypeError("Argument must be array of SpanQueries");h.span_near.clauses.push(a[d].toJSON())}}return c(g,{clauses:function(a){var b,c;if(null==a)return h.span_near.clauses;if(l(a))h.span_near.clauses.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be SpanQuery or array of SpanQueries");for(h.span_near.clauses=[],b=0,c=a.length;c>b;b++){if(!l(a[b]))throw new TypeError("Argument must be array of SpanQueries");h.span_near.clauses.push(a[b].toJSON())}}return this},slop:function(a){return null==a?h.span_near.slop:(h.span_near.slop=a,this)},inOrder:function(a){return null==a?h.span_near.in_order:(h.span_near.in_order=a,this)},collectPayloads:function(a){return null==a?h.span_near.collect_payloads:(h.span_near.collect_payloads=a,this)}})},y.SpanNotQuery=function(a,b){if(!l(a)||!l(b))throw new TypeError("Argument must be a SpanQuery");var d=y.QueryMixin("span_not"),e=d.toJSON();return e.span_not.include=a.toJSON(),e.span_not.exclude=b.toJSON(),c(d,{include:function(a){if(null==a)return e.span_not.include;if(!l(a))throw new TypeError("Argument must be a SpanQuery");return e.span_not.include=a.toJSON(),this},exclude:function(a){if(null==a)return e.span_not.exclude;if(!l(a))throw new TypeError("Argument must be a SpanQuery");return e.span_not.exclude=a.toJSON(),this}})},y.SpanOrQuery=function(a){var b,d,f=y.QueryMixin("span_or"),g=f.toJSON();if(g.span_or.clauses=[],l(a))g.span_or.clauses.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be SpanQuery or array of SpanQueries");for(b=0,d=a.length;d>b;b++){if(!l(a[b]))throw new TypeError("Argument must be array of SpanQueries");g.span_or.clauses.push(a[b].toJSON())}}return c(f,{clauses:function(a){var b,c;if(null==a)return g.span_or.clauses;if(l(a))g.span_or.clauses.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be SpanQuery or array of SpanQueries");for(g.span_or.clauses=[],b=0,c=a.length;c>b;b++){if(!l(a[b]))throw new TypeError("Argument must be array of SpanQueries");g.span_or.clauses.push(a[b].toJSON())}}return this}})},y.SpanTermQuery=function(a,b){var d=y.QueryMixin("span_term"),e=d.toJSON();return e.span_term[a]={term:b},c(d,{field:function(b){var c=e.span_term[a];return null==b?a:(delete e.span_term[a],a=b,e.span_term[b]=c,this)},term:function(b){return null==b?e.span_term[a].term:(e.span_term[a].term=b,this)},boost:function(b){return null==b?e.span_term[a].boost:(e.span_term[a].boost=b,this)}})},y.TermQuery=function(a,b){var d=y.QueryMixin("term"),e=d.toJSON();return e.term[a]={term:b},c(d,{field:function(b){var c=e.term[a];return null==b?a:(delete e.term[a],a=b,e.term[b]=c,this)},term:function(b){return null==b?e.term[a].term:(e.term[a].term=b,this)},boost:function(b){return null==b?e.term[a].boost:(e.term[a].boost=b,this)}})},y.TermsQuery=function(a,b){var d=y.QueryMixin("terms"),f=d.toJSON();if(g(b))f.terms[a]=[b];else{if(!e(b))throw new TypeError("Argument must be string or array");f.terms[a]=b}return c(d,{field:function(b){var c=f.terms[a];return null==b?a:(delete f.terms[a],a=b,f.terms[b]=c,this)},terms:function(b){if(null==b)return f.terms[a];if(g(b))f.terms[a].push(b);else{if(!e(b))throw new TypeError("Argument must be string or array");f.terms[a]=b}return this},minimumShouldMatch:function(a){return null==a?f.terms.minimum_should_match:(f.terms.minimum_should_match=a,this)},disableCoord:function(a){return null==a?f.terms.disable_coord:(f.terms.disable_coord=a,this)}})},y.TopChildrenQuery=function(a,b){if(!l(a))throw new TypeError("Argument must be a Query");var d=y.QueryMixin("top_children"),e=d.toJSON();return e.top_children.query=a.toJSON(),e.top_children.type=b,c(d,{query:function(a){if(null==a)return e.top_children.query;if(!l(a))throw new TypeError("Argument must be a Query");return e.top_children.query=a.toJSON(),this},type:function(a){return null==a?e.top_children.type:(e.top_children.type=a,this)},scope:function(){return this},score:function(a){return null==a?e.top_children.score:(a=a.toLowerCase(),("max"===a||"sum"===a||"avg"===a||"total"===a)&&(e.top_children.score=a),this)},scoreMode:function(a){return null==a?e.top_children.score_mode:(a=a.toLowerCase(),("max"===a||"sum"===a||"avg"===a||"total"===a)&&(e.top_children.score_mode=a),this)},factor:function(a){return null==a?e.top_children.factor:(e.top_children.factor=a,this)},incrementalFactor:function(a){return null==a?e.top_children.incremental_factor:(e.top_children.incremental_factor=a,this)}})},y.WildcardQuery=function(a,b){var d=y.QueryMixin("wildcard"),e=d.toJSON();return e.wildcard[a]={value:b},c(d,{field:function(b){var c=e.wildcard[a];return null==b?a:(delete e.wildcard[a],a=b,e.wildcard[b]=c,this)},value:function(b){return null==b?e.wildcard[a].value:(e.wildcard[a].value=b,this)},rewrite:function(b){return null==b?e.wildcard[a].rewrite:(b=b.toLowerCase(),("constant_score_auto"===b||"scoring_boolean"===b||"constant_score_boolean"===b||"constant_score_filter"===b||0===b.indexOf("top_terms_boost_")||0===b.indexOf("top_terms_"))&&(e.wildcard[a].rewrite=b),this)},boost:function(b){return null==b?e.wildcard[a].boost:(e.wildcard[a].boost=b,this)}})},y.GeoPoint=function(b){var c=[0,0];return null!=b&&e(b)&&2===b.length&&(c=[b[1],b[0]]),{properties:function(b){return null==b?c:(f(b)&&a(b,"lat")&&a(b,"lon")?c={lat:b.lat,lon:b.lon}:f(b)&&a(b,"geohash")&&(c={geohash:b.geohash}),this)},string:function(a){return null==a?c:(g(a)&&-1!==a.indexOf(",")&&(c=a),this)},geohash:function(a,b){return b=null!=b&&h(b)?b:12,null==a?c:(g(a)&&a.length===b&&(c=a),this)},array:function(a){return null==a?c:(e(a)&&2===a.length&&(c=[a[1],a[0]]),this)},_type:function(){return"geo point"},toJSON:function(){return c}}},y.Highlight=function(c){var d={fields:{}},h=function(b,c,e){null==b?d[c]=e:(a(d.fields,b)||(d.fields[b]={}),d.fields[b][c]=e)};return null!=c&&(g(c)?d.fields[c]={}:e(c)&&b(c,function(a){d.fields[a]={}})),{fields:function(c){return null==c?d.fields:(g(c)?a(d.fields,c)||(d.fields[c]={}):e(c)&&b(c,function(b){a(d.fields,b)||(d.fields[b]={})}),void 0)},preTags:function(a,b){return null===a&&null!=b?d.fields[b].pre_tags:null==a?d.pre_tags:(g(a)?h(b,"pre_tags",[a]):e(a)&&h(b,"pre_tags",a),this)},postTags:function(a,b){return null===a&&null!=b?d.fields[b].post_tags:null==a?d.post_tags:(g(a)?h(b,"post_tags",[a]):e(a)&&h(b,"post_tags",a),this)},order:function(a,b){return null===a&&null!=b?d.fields[b].order:null==a?d.order:(a=a.toLowerCase(),"score"===a&&h(b,"order",a),this)},tagsSchema:function(a){return null==a?d.tags_schema:(a=a.toLowerCase(),"styled"===a&&(d.tags_schema=a),this)},highlightFilter:function(a,b){return null===a&&null!=b?d.fields[b].highlight_filter:null==a?d.highlight_filter:(h(b,"highlight_filter",a),this)},fragmentSize:function(a,b){return null===a&&null!=b?d.fields[b].fragment_size:null==a?d.fragment_size:(h(b,"fragment_size",a),this)},numberOfFragments:function(a,b){return null===a&&null!=b?d.fields[b].number_of_fragments:null==a?d.number_of_fragments:(h(b,"number_of_fragments",a),this)},encoder:function(a){return null==a?d.encoder:(a=a.toLowerCase(),("default"===a||"html"===a)&&(d.encoder=a),this)},requireFieldMatch:function(a,b){return null===a&&null!=b?d.fields[b].require_field_match:null==a?d.require_field_match:(h(b,"require_field_match",a),this)},boundaryMaxScan:function(a,b){return null===a&&null!=b?d.fields[b].boundary_max_scan:null==a?d.boundary_max_scan:(h(b,"boundary_max_scan",a),this)},boundaryChars:function(a,b){return null===a&&null!=b?d.fields[b].boundary_chars:null==a?d.boundary_chars:(h(b,"boundary_chars",a),this)},type:function(a,b){return null===a&&null!=b?d.fields[b].type:null==a?d.type:(a=a.toLowerCase(),("fast-vector-highlighter"===a||"highlighter"===a)&&h(b,"type",a),this)},fragmenter:function(a,b){return null===a&&null!=b?d.fields[b].fragmenter:null==a?d.fragmenter:(a=a.toLowerCase(),("simple"===a||"span"===a)&&h(b,"fragmenter",a),this)},options:function(a,b){if(null===a&&null!=b)return d.fields[b].options;if(null==a)return d.options;if(!f(a)||e(a)||k(a))throw new TypeError("Parameter must be an object");return h(b,"options",a),this},_type:function(){return"highlight"},toJSON:function(){return d}}},y.IndexedShape=function(a,b){var c={type:a,id:b};return{type:function(a){return null==a?c.type:(c.type=a,this)},id:function(a){return null==a?c.id:(c.id=a,this)},index:function(a){return null==a?c.index:(c.index=a,this)},shapeFieldName:function(a){return null==a?c.shape_field_name:(c.shape_field_name=a,this)},_type:function(){return"indexed shape"},toJSON:function(){return c}}},y.Request=function(){var b={};return{sort:function(){var c,d;if(a(b,"sort")||(b.sort=[]),0===arguments.length)return b.sort;if(1===arguments.length){var f=arguments[0];if(g(f))b.sort.push(f);else if(u(f))b.sort.push(f.toJSON());else{if(!e(f))throw new TypeError("Argument must be string, Sort, or array");for(b.sort=[],c=0,d=f.length;d>c;c++)if(g(f[c]))b.sort.push(f[c]);else{if(!u(f[c]))throw new TypeError("Invalid object in array");b.sort.push(f[c].toJSON())}}}else if(2===arguments.length){var h=arguments[0],i=arguments[1];if(g(h)&&g(i)&&(i=i.toLowerCase(),"asc"===i||"desc"===i)){var j={};j[h]={order:i},b.sort.push(j)}}return this},trackScores:function(a){return null==a?b.track_scores:(b.track_scores=a,this)},from:function(a){return null==a?b.from:(b.from=a,this)},size:function(a){return null==a?b.size:(b.size=a,this)},timeout:function(a){return null==a?b.timeout:(b.timeout=a,this)},fields:function(a){if(null==a)return b.fields;if(null==b.fields&&(b.fields=[]),g(a))b.fields.push(a);else{if(!e(a))throw new TypeError("Argument must be a string or an array");b.fields=a}return this},source:function(a,c){if(null==a&&null==c)return b._source;if(!e(a)&&!g(a)&&!i(a))throw new TypeError("Argument includes must be a string, an array, or a boolean");if(null!=c&&!e(c)&&!g(c))throw new TypeError("Argument excludes must be a string or an array");return i(a)?b._source=a:(b._source={includes:a},null!=c&&(b._source.excludes=c)),this},rescore:function(a){if(null==a)return b.rescore;if(!m(a))throw new TypeError("Argument must be a Rescore");return b.rescore=a.toJSON(),this},query:function(a){if(null==a)return b.query;if(!l(a))throw new TypeError("Argument must be a Query");return b.query=a.toJSON(),this},facet:function(a){if(null==a)return b.facets;if(null==b.facets&&(b.facets={}),!o(a))throw new TypeError("Argument must be a Facet");return c(b.facets,a.toJSON()),this},aggregation:function(a){if(null==a)return b.aggs;if(null==b.aggs&&(b.aggs={}),!p(a))throw new TypeError("Argument must be an Aggregation");return c(b.aggs,a.toJSON()),this},agg:function(a){return this.aggregation(a)},filter:function(a){if(null==a)return b.filter;if(!n(a))throw new TypeError("Argument must be a Filter");return b.filter=a.toJSON(),this},highlight:function(a){if(null==a)return b.highlight;if(!v(a))throw new TypeError("Argument must be a Highlight object");return b.highlight=a.toJSON(),this},suggest:function(a){if(null==a)return b.suggest;if(null==b.suggest&&(b.suggest={}),g(a))b.suggest.text=a;else{if(!w(a))throw new TypeError("Argument must be a string or Suggest object");c(b.suggest,a.toJSON())}return this},scriptField:function(a){if(null==a)return b.script_fields;if(null==b.script_fields&&(b.script_fields={}),!q(a))throw new TypeError("Argument must be a ScriptField");return c(b.script_fields,a.toJSON()),this},indexBoost:function(a,c){return null==b.indices_boost&&(b.indices_boost={}),0===arguments.length?b.indices_boost:(b.indices_boost[a]=c,this)},explain:function(a){return null==a?b.explain:(b.explain=a,this)},version:function(a){return null==a?b.version:(b.version=a,this)},minScore:function(a){return null==a?b.min_score:(b.min_score=a,this)},_type:function(){return"request"},toJSON:function(){return b}}},y.Rescore=function(a,b){if(null!=a&&!h(a))throw new TypeError("Argument must be a Number");if(null!=b&&!l(b))throw new TypeError("Argument must be a Query");var c={query:{}};return null!=a&&(c.window_size=a),null!=b&&(c.query.rescore_query=b.toJSON()),{rescoreQuery:function(a){if(null==a)return c.query.rescore_query;if(!l(a))throw new TypeError("Argument must be a Query");return c.query.rescore_query=a.toJSON(),this},queryWeight:function(a){if(null==a)return c.query.query_weight;if(!h(a))throw new TypeError("Argument must be a Number");return c.query.query_weight=a,this},rescoreQueryWeight:function(a){if(null==a)return c.query.rescore_query_weight;if(!h(a))throw new TypeError("Argument must be a Number");return c.query.rescore_query_weight=a,this},windowSize:function(a){if(null==a)return c.window_size;if(!h(a))throw new TypeError("Argument must be a Number");return c.window_size=a,this},scoreMode:function(a){return null==a?c.query.score_mode:(a=a.toLowerCase(),("total"===a||"min"===a||"max"===a||"multiply"===a||"avg"===a)&&(c.query.score_mode=a),this)},_type:function(){return"rescore"},toJSON:function(){return c}}},y.ScriptField=function(a){var b={};return b[a]={},{lang:function(c){return null==c?b[a].lang:(b[a].lang=c,this)},script:function(c){return null==c?b[a].script:(b[a].script=c,this)},params:function(c){return null==c?b[a].params:(b[a].params=c,this)},ignoreFailure:function(c){return null==c?b[a].ignore_failure:(b[a].ignore_failure=c,this)},_type:function(){return"script field"},toJSON:function(){return b}}},y.Shape=function(a,b){var c={},d=function(a){var b=!1;return("point"===a||"linestring"===a||"polygon"===a||"multipoint"===a||"envelope"===a||"multipolygon"===a||"circle"===a||"multilinestring"===a)&&(b=!0),b};return a=a.toLowerCase(),d(a)&&(c.type=a,c.coordinates=b),{type:function(a){return null==a?c.type:(a=a.toLowerCase(),d(a)&&(c.type=a),this)},coordinates:function(a){return null==a?c.coordinates:(c.coordinates=a,this)},radius:function(a){return null==a?c.radius:(c.radius=a,this)},_type:function(){return"shape"},toJSON:function(){return c}}},y.Sort=function(a){null==a&&(a="_score");var b={},c=a,d="_geo_distance",e="_script";return b[c]={},{field:function(d){var e=b[c];return null==d?a:(delete b[c],a=d,c=d,b[c]=e,this)},geoDistance:function(e){var f=b[c];if(null==e)return b[c][a];if(!r(e))throw new TypeError("Argument must be a GeoPoint");return delete b[c],c=d,b[c]=f,b[c][a]=e.toJSON(),this},script:function(a){var d=b[c];return null==a?b[c].script:(delete b[c],c=e,b[c]=d,b[c].script=a,this)},order:function(a){return null==a?b[c].order:(a=a.toLowerCase(),("asc"===a||"desc"===a)&&(b[c].order=a),this)},asc:function(){return b[c].order="asc",this},desc:function(){return b[c].order="desc",this},reverse:function(a){return null==a?b[c].reverse:(b[c].reverse=a,this)},missing:function(a){return null==a?b[c].missing:(b[c].missing=a,this)},ignoreUnmapped:function(a){return null==a?b[c].ignore_unmapped:(b[c].ignore_unmapped=a,this)},unit:function(a){return null==a?b[c].unit:(a=a.toLowerCase(),("mi"===a||"km"===a)&&(b[c].unit=a),this)},normalize:function(a){return null==a?b[c].normalize:(b[c].normalize=a,this) -},distanceType:function(a){return null==a?b[c].distance_type:(a=a.toLowerCase(),("arc"===a||"plane"===a)&&(b[c].distance_type=a),this)},params:function(a){return null==a?b[c].params:(b[c].params=a,this)},lang:function(a){return null==a?b[c].lang:(b[c].lang=a,this)},type:function(a){return null==a?b[c].type:(a=a.toLowerCase(),("string"===a||"number"===a)&&(b[c].type=a),this)},mode:function(a){return null==a?b[c].mode:(a=a.toLowerCase(),("min"===a||"max"===a||"sum"===a||"avg"===a)&&(b[c].mode=a),this)},nestedPath:function(a){return null==a?b[c].nested_path:(b[c].nested_path=a,this)},nestedFilter:function(a){if(null==a)return b[c].nested_filter;if(!n(a))throw new TypeError("Argument must be a Filter");return b[c].nested_filter=a.toJSON(),this},_type:function(){return"sort"},toJSON:function(){return b}}},y.CompletionSuggester=function(a){var b,d=y.SuggesterMixin(a),e=d.toJSON();return e[a].completion={},b=y.SuggestContextMixin(e[a].completion),c(d,b,{fuzzy:function(b){return null==b?e[a].completion.fuzzy:(b&&null==e[a].completion.fuzzy?e[a].completion.fuzzy={}:b||null==e[a].completion.fuzzy||delete e[a].completion.fuzzy,this)},transpositions:function(b){return null==e[a].completion.fuzzy&&(e[a].completion.fuzzy={}),null==b?e[a].completion.fuzzy.transpositions:(e[a].completion.fuzzy.transpositions=b,this)},unicodeAware:function(b){return null==e[a].completion.fuzzy&&(e[a].completion.fuzzy={}),null==b?e[a].completion.fuzzy.unicode_aware:(e[a].completion.fuzzy.unicode_aware=b,this)},editDistance:function(b){return null==e[a].completion.fuzzy&&(e[a].completion.fuzzy={}),null==b?e[a].completion.fuzzy.edit_distance:(e[a].completion.fuzzy.edit_distance=b,this)},minLength:function(b){return null==e[a].completion.fuzzy&&(e[a].completion.fuzzy={}),null==b?e[a].completion.fuzzy.min_length:(e[a].completion.fuzzy.min_length=b,this)},prefixLength:function(b){return null==e[a].completion.fuzzy&&(e[a].completion.fuzzy={}),null==b?e[a].completion.fuzzy.prefix_length:(e[a].completion.fuzzy.prefix_length=b,this)}})},y.DirectGenerator=function(){var a={},b=y.DirectSettingsMixin(a);return c(b,{preFilter:function(b){return null==b?a.pre_filter:(a.pre_filter=b,this)},postFilter:function(b){return null==b?a.post_filter:(a.post_filter=b,this)},field:function(b){return null==b?a.field:(a.field=b,this)},size:function(b){return null==b?a.size:(a.size=b,this)},_type:function(){return"generator"},toJSON:function(){return a}})},y.PhraseSuggester=function(a){var b,d=y.SuggesterMixin(a),f=d.toJSON();return f[a].phrase={},b=y.SuggestContextMixin(f[a].phrase),c(d,b,{realWorldErrorLikelihood:function(b){return null==b?f[a].phrase.real_world_error_likelihood:(f[a].phrase.real_world_error_likelihood=b,this)},confidence:function(b){return null==b?f[a].phrase.confidence:(f[a].phrase.confidence=b,this)},separator:function(b){return null==b?f[a].phrase.separator:(f[a].phrase.separator=b,this)},maxErrors:function(b){return null==b?f[a].phrase.max_errors:(f[a].phrase.max_errors=b,this)},gramSize:function(b){return null==b?f[a].phrase.gram_size:(f[a].phrase.gram_size=b,this)},forceUnigrams:function(b){return null==b?f[a].phrase.force_unigrams:(f[a].phrase.force_unigrams=b,this)},tokenLimit:function(b){return null==b?f[a].phrase.token_limit:(f[a].phrase.token_limit=b,this)},linearSmoothing:function(b,c,d){return 0===arguments.length?f[a].phrase.smoothing:(f[a].phrase.smoothing={linear:{trigram_lambda:b,bigram_lambda:c,unigram_lambda:d}},this)},laplaceSmoothing:function(b){return null==b?f[a].phrase.smoothing:(f[a].phrase.smoothing={laplace:{alpha:b}},this)},stupidBackoffSmoothing:function(b){return null==b?f[a].phrase.smoothing:(f[a].phrase.smoothing={stupid_backoff:{discount:b}},this)},highlight:function(b,c){return 0===arguments.length?f[a].phrase.highlight:(f[a].phrase.highlight={pre_tag:b,post_tag:c},this)},directGenerator:function(b){var c,d;if(null==f[a].phrase.direct_generator&&(f[a].phrase.direct_generator=[]),null==b)return f[a].phrase.direct_generator;if(x(b))f[a].phrase.direct_generator.push(b.toJSON());else{if(!e(b))throw new TypeError("Argument must be a Generator or array of Generators");for(f[a].phrase.direct_generator=[],c=0,d=b.length;d>c;c++){if(!x(b[c]))throw new TypeError("Argument must be an array of Generators");f[a].phrase.direct_generator.push(b[c].toJSON())}}return this}})},y.TermSuggester=function(a){var b,d,e=y.SuggesterMixin(a),f=e.toJSON();return f[a].term={},b=y.DirectSettingsMixin(f[a].term),d=y.SuggestContextMixin(f[a].term),c(e,b,d)},y.noConflict=function(){return z.ejs=A,this}}).call(this); \ No newline at end of file +},point:function(b){if(null==b)return d.geo_distance[a];if(!r(b))throw new TypeError("Argument must be a GeoPoint");return d.geo_distance[a]=b.toJSON(),this},distanceType:function(a){return null==a?d.geo_distance.distance_type:(a=a.toLowerCase(),("arc"===a||"plane"===a)&&(d.geo_distance.distance_type=a),this)},normalize:function(a){return null==a?d.geo_distance.normalize:(d.geo_distance.normalize=a,this)},optimizeBbox:function(a){return null==a?d.geo_distance.optimize_bbox:(a=a.toLowerCase(),("memory"===a||"indexed"===a||"none"===a)&&(d.geo_distance.optimize_bbox=a),this)}})},y.GeoDistanceRangeFilter=function(a){var b=y.FilterMixin("geo_distance_range"),d=b.toJSON();return d.geo_distance_range[a]=[0,0],c(b,{field:function(b){var c=d.geo_distance_range[a];return null==b?a:(delete d.geo_distance_range[a],a=b,d.geo_distance_range[b]=c,this)},from:function(a){if(null==a)return d.geo_distance_range.from;if(!h(a))throw new TypeError("Argument must be a numeric value");return d.geo_distance_range.from=a,this},to:function(a){if(null==a)return d.geo_distance_range.to;if(!h(a))throw new TypeError("Argument must be a numeric value");return d.geo_distance_range.to=a,this},includeLower:function(a){return null==a?d.geo_distance_range.include_lower:(d.geo_distance_range.include_lower=a,this)},includeUpper:function(a){return null==a?d.geo_distance_range.include_upper:(d.geo_distance_range.include_upper=a,this)},gt:function(a){if(null==a)return d.geo_distance_range.gt;if(!h(a))throw new TypeError("Argument must be a numeric value");return d.geo_distance_range.gt=a,this},gte:function(a){if(null==a)return d.geo_distance_range.gte;if(!h(a))throw new TypeError("Argument must be a numeric value");return d.geo_distance_range.gte=a,this},lt:function(a){if(null==a)return d.geo_distance_range.lt;if(!h(a))throw new TypeError("Argument must be a numeric value");return d.geo_distance_range.lt=a,this},lte:function(a){if(null==a)return d.geo_distance_range.lte;if(!h(a))throw new TypeError("Argument must be a numeric value");return d.geo_distance_range.lte=a,this},unit:function(a){return null==a?d.geo_distance_range.unit:(a=a.toLowerCase(),("mi"===a||"km"===a)&&(d.geo_distance_range.unit=a),this)},point:function(b){if(null==b)return d.geo_distance_range[a];if(!r(b))throw new TypeError("Argument must be a GeoPoint");return d.geo_distance_range[a]=b.toJSON(),this},distanceType:function(a){return null==a?d.geo_distance_range.distance_type:(a=a.toLowerCase(),("arc"===a||"plane"===a)&&(d.geo_distance_range.distance_type=a),this)},normalize:function(a){return null==a?d.geo_distance_range.normalize:(d.geo_distance_range.normalize=a,this)},optimizeBbox:function(a){return null==a?d.geo_distance_range.optimize_bbox:(a=a.toLowerCase(),("memory"===a||"indexed"===a||"none"===a)&&(d.geo_distance_range.optimize_bbox=a),this)}})},y.GeoPolygonFilter=function(a){var b=y.FilterMixin("geo_polygon"),d=b.toJSON();return d.geo_polygon[a]={points:[]},c(b,{field:function(b){var c=d.geo_polygon[a];return null==b?a:(delete d.geo_polygon[a],a=b,d.geo_polygon[b]=c,this)},points:function(b){var c,f;if(null==b)return d.geo_polygon[a].points;if(r(b))d.geo_polygon[a].points.push(b.toJSON());else{if(!e(b))throw new TypeError("Argument must be a GeoPoint or Array of GeoPoints");for(d.geo_polygon[a].points=[],c=0,f=b.length;f>c;c++){if(!r(b[c]))throw new TypeError("Argument must be Array of GeoPoints");d.geo_polygon[a].points.push(b[c].toJSON())}}return this},normalize:function(a){return null==a?d.geo_polygon.normalize:(d.geo_polygon.normalize=a,this)}})},y.GeoShapeFilter=function(a){var b=y.FilterMixin("geo_shape"),d=b.toJSON();return d.geo_shape[a]={},c(b,{field:function(b){var c=d.geo_shape[a];return null==b?a:(delete d.geo_shape[a],a=b,d.geo_shape[b]=c,this)},shape:function(b){return null==b?d.geo_shape[a].shape:(null!=d.geo_shape[a].indexed_shape&&delete d.geo_shape[a].indexed_shape,d.geo_shape[a].shape=b.toJSON(),this)},indexedShape:function(b){return null==b?d.geo_shape[a].indexed_shape:(null!=d.geo_shape[a].shape&&delete d.geo_shape[a].shape,d.geo_shape[a].indexed_shape=b.toJSON(),this)},relation:function(b){return null==b?d.geo_shape[a].relation:(b=b.toLowerCase(),("intersects"===b||"disjoint"===b||"within"===b)&&(d.geo_shape[a].relation=b),this)},strategy:function(b){return null==b?d.geo_shape[a].strategy:(b=b.toLowerCase(),("recursive"===b||"term"===b)&&(d.geo_shape[a].strategy=b),this)}})},y.HasChildFilter=function(a,b){if(!l(a))throw new TypeError("No Query object found");var d=y.FilterMixin("has_child"),e=d.toJSON();return e.has_child.query=a.toJSON(),e.has_child.type=b,c(d,{query:function(a){if(null==a)return e.has_child.query;if(!l(a))throw new TypeError("Argument must be a Query object");return e.has_child.query=a.toJSON(),this},filter:function(a){if(null==a)return e.has_child.filter;if(!n(a))throw new TypeError("Argument must be a Filter object");return e.has_child.filter=a.toJSON(),this},type:function(a){return null==a?e.has_child.type:(e.has_child.type=a,this)},shortCircuitCutoff:function(a){return null==a?e.has_child.short_circuit_cutoff:(e.has_child.short_circuit_cutoff=a,this)},scope:function(){return this}})},y.HasParentFilter=function(a,b){if(!l(a))throw new TypeError("No Query object found");var d=y.FilterMixin("has_parent"),e=d.toJSON();return e.has_parent.query=a.toJSON(),e.has_parent.parent_type=b,c(d,{query:function(a){if(null==a)return e.has_parent.query;if(!l(a))throw new TypeError("Argument must be a Query object");return e.has_parent.query=a.toJSON(),this},filter:function(a){if(null==a)return e.has_parent.filter;if(!n(a))throw new TypeError("Argument must be a Filter object");return e.has_parent.filter=a.toJSON(),this},parentType:function(a){return null==a?e.has_parent.parent_type:(e.has_parent.parent_type=a,this)},scope:function(){return this}})},y.IdsFilter=function(a){var b=y.FilterMixin("ids"),d=b.toJSON();if(g(a))d.ids.values=[a];else{if(!e(a))throw new TypeError("Argument must be a string or an array");d.ids.values=a}return c(b,{values:function(a){if(null==a)return d.ids.values;if(g(a))d.ids.values.push(a);else{if(!e(a))throw new TypeError("Argument must be a string or an array");d.ids.values=a}return this},type:function(a){if(null==d.ids.type&&(d.ids.type=[]),null==a)return d.ids.type;if(g(a))d.ids.type.push(a);else{if(!e(a))throw new TypeError("Argument must be a string or an array");d.ids.type=a}return this}})},y.IndicesFilter=function(a,b){if(!n(a))throw new TypeError("Argument must be a Filter");var d=y.FilterMixin("indices"),f=d.toJSON();if(f.indices.filter=a.toJSON(),g(b))f.indices.indices=[b];else{if(!e(b))throw new TypeError("Argument must be a string or array");f.indices.indices=b}return c(d,{indices:function(a){if(null==a)return f.indices.indices;if(g(a))f.indices.indices.push(a);else{if(!e(a))throw new TypeError("Argument must be a string or array");f.indices.indices=a}return this},filter:function(a){if(null==a)return f.indices.filter;if(!n(a))throw new TypeError("Argument must be a Filter");return f.indices.filter=a.toJSON(),this},noMatchFilter:function(a){if(null==a)return f.indices.no_match_filter;if(g(a))a=a.toLowerCase(),("none"===a||"all"===a)&&(f.indices.no_match_filter=a);else{if(!n(a))throw new TypeError("Argument must be string or Filter");f.indices.no_match_filter=a.toJSON()}return this}})},y.LimitFilter=function(a){var b=y.FilterMixin("limit"),d=b.toJSON();return d.limit.value=a,c(b,{value:function(a){if(null==a)return d.limit.value;if(!h(a))throw new TypeError("Argument must be a numeric value");return d.limit.value=a,this}})},y.MatchAllFilter=function(){return y.FilterMixin("match_all")},y.MissingFilter=function(a){var b=y.FilterMixin("missing"),d=b.toJSON();return d.missing.field=a,c(b,{field:function(a){return null==a?d.missing.field:(d.missing.field=a,this)},existence:function(a){return null==a?d.missing.existence:(d.missing.existence=a,this)},nullValue:function(a){return null==a?d.missing.null_value:(d.missing.null_value=a,this)}})},y.NestedFilter=function(a){var b=y.FilterMixin("nested"),d=b.toJSON();return d.nested.path=a,c(b,{path:function(a){return null==a?d.nested.path:(d.nested.path=a,this)},query:function(a){if(null==a)return d.nested.query;if(!l(a))throw new TypeError("Argument must be a Query object");return d.nested.query=a.toJSON(),this},filter:function(a){if(null==a)return d.nested.filter;if(!n(a))throw new TypeError("Argument must be a Filter object");return d.nested.filter=a.toJSON(),this},boost:function(a){return null==a?d.nested.boost:(d.nested.boost=a,this)},join:function(a){return null==a?d.nested.join:(d.nested.join=a,this)},scope:function(){return this}})},y.NotFilter=function(a){if(!n(a))throw new TypeError("Argument must be a Filter");var b=y.FilterMixin("not"),d=b.toJSON();return d.not=a.toJSON(),c(b,{filter:function(a){if(null==a)return d.not;if(!n(a))throw new TypeError("Argument must be a Filter");return d.not=a.toJSON(),this}})},y.NumericRangeFilter=function(a){var b=y.FilterMixin("numeric_range"),d=b.toJSON();return d.numeric_range[a]={},c(b,{field:function(b){var c=d.numeric_range[a];return null==b?a:(delete d.numeric_range[a],a=b,d.numeric_range[a]=c,this)},from:function(b){if(null==b)return d.numeric_range[a].from;if(!h(b))throw new TypeError("Argument must be a numeric value");return d.numeric_range[a].from=b,this},to:function(b){if(null==b)return d.numeric_range[a].to;if(!h(b))throw new TypeError("Argument must be a numeric value");return d.numeric_range[a].to=b,this},includeLower:function(b){return null==b?d.numeric_range[a].include_lower:(d.numeric_range[a].include_lower=b,this)},includeUpper:function(b){return null==b?d.numeric_range[a].include_upper:(d.numeric_range[a].include_upper=b,this)},gt:function(b){if(null==b)return d.numeric_range[a].gt;if(!h(b))throw new TypeError("Argument must be a numeric value");return d.numeric_range[a].gt=b,this},gte:function(b){if(null==b)return d.numeric_range[a].gte;if(!h(b))throw new TypeError("Argument must be a numeric value");return d.numeric_range[a].gte=b,this},lt:function(b){if(null==b)return d.numeric_range[a].lt;if(!h(b))throw new TypeError("Argument must be a numeric value");return d.numeric_range[a].lt=b,this},lte:function(b){if(null==b)return d.numeric_range[a].lte;if(!h(b))throw new TypeError("Argument must be a numeric value");return d.numeric_range[a].lte=b,this}})},y.OrFilter=function(a){var b,d,f=y.FilterMixin("or"),g=f.toJSON();if(g.or.filters=[],n(a))g.or.filters.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be a Filter or array of Filters");for(b=0,d=a.length;d>b;b++){if(!n(a[b]))throw new TypeError("Argument must be array of Filters");g.or.filters.push(a[b].toJSON())}}return c(f,{filters:function(a){var b,c;if(null==a)return g.or.filters;if(n(a))g.or.filters.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be a Filter or array of Filters");for(g.or.filters=[],b=0,c=a.length;c>b;b++){if(!n(a[b]))throw new TypeError("Argument must be an array of Filters");g.or.filters.push(a[b].toJSON())}}return this}})},y.PrefixFilter=function(a,b){var d=y.FilterMixin("prefix"),e=d.toJSON();return e.prefix[a]=b,c(d,{field:function(b){var c=e.prefix[a];return null==b?a:(delete e.prefix[a],a=b,e.prefix[a]=c,this)},prefix:function(b){return null==b?e.prefix[a]:(e.prefix[a]=b,this)}})},y.QueryFilter=function(a){if(!l(a))throw new TypeError("Argument must be a Query");var b=y.FilterMixin("fquery"),d=b.toJSON();return d.fquery.query=a.toJSON(),c(b,{query:function(a){if(null==a)return d.fquery.query;if(!l(a))throw new TypeError("Argument must be a Query");return d.fquery.query=a.toJSON(),this}})},y.RangeFilter=function(a){var b=y.FilterMixin("range"),d=b.toJSON();return d.range[a]={},c(b,{field:function(b){var c=d.range[a];return null==b?a:(delete d.range[a],a=b,d.range[b]=c,this)},from:function(b){return null==b?d.range[a].from:(d.range[a].from=b,this)},to:function(b){return null==b?d.range[a].to:(d.range[a].to=b,this)},includeLower:function(b){return null==b?d.range[a].include_lower:(d.range[a].include_lower=b,this)},includeUpper:function(b){return null==b?d.range[a].include_upper:(d.range[a].include_upper=b,this)},gt:function(b){return null==b?d.range[a].gt:(d.range[a].gt=b,this)},gte:function(b){return null==b?d.range[a].gte:(d.range[a].gte=b,this)},lt:function(b){return null==b?d.range[a].lt:(d.range[a].lt=b,this)},lte:function(b){return null==b?d.range[a].lte:(d.range[a].lte=b,this)}})},y.RegexpFilter=function(a,b){var d=y.FilterMixin("regexp"),e=d.toJSON();return e.regexp[a]={value:b},c(d,{field:function(b){var c=e.regexp[a];return null==b?a:(delete e.regexp[a],a=b,e.regexp[b]=c,this)},value:function(b){return null==b?e.regexp[a].value:(e.regexp[a].value=b,this)},flags:function(b){return null==b?e.regexp[a].flags:(e.regexp[a].flags=b,this)},flagsValue:function(b){return null==b?e.regexp[a].flags_value:(e.regexp[a].flags_value=b,this)}})},y.ScriptFilter=function(a){var b=y.FilterMixin("script"),d=b.toJSON();return d.script.script=a,c(b,{script:function(a){return null==a?d.script.script:(d.script.script=a,this)},params:function(a){return null==a?d.script.params:(d.script.params=a,this)},lang:function(a){return null==a?d.script.lang:(d.script.lang=a,this)}})},y.TermFilter=function(a,b){var d=y.FilterMixin("term"),e=d.toJSON();return e.term[a]=b,c(d,{field:function(b){var c=e.term[a];return null==b?a:(delete e.term[a],a=b,e.term[a]=c,this)},term:function(b){return null==b?e.term[a]:(e.term[a]=b,this)}})},y.TermsFilter=function(a,b){var d=y.FilterMixin("terms"),f=d.toJSON(),g=function(){e(f.terms[a])||(f.terms[a]=[])},h=function(){e(f.terms[a])&&(f.terms[a]={})};return f.terms[a]=e(b)?b:[b],c(d,{field:function(b){var c=f.terms[a];return null==b?a:(delete f.terms[a],a=b,f.terms[b]=c,this)},terms:function(b){return g(),null==b?f.terms[a]:(e(b)?f.terms[a]=b:f.terms[a].push(b),this)},index:function(b){return h(),null==b?f.terms[a].index:(f.terms[a].index=b,this)},type:function(b){return h(),null==b?f.terms[a].type:(f.terms[a].type=b,this)},id:function(b){return h(),null==b?f.terms[a].id:(f.terms[a].id=b,this)},path:function(b){return h(),null==b?f.terms[a].path:(f.terms[a].path=b,this)},routing:function(b){return h(),null==b?f.terms[a].routing:(f.terms[a].routing=b,this)},cacheLookup:function(b){return h(),null==b?f.terms[a].cache:(f.terms[a].cache=b,this)},execution:function(a){return null==a?f.terms.execution:(a=a.toLowerCase(),("plain"===a||"bool"===a||"bool_nocache"===a||"and"===a||"and_nocache"===a||"or"===a||"or_nocache"===a)&&(f.terms.execution=a),this)}})},y.TypeFilter=function(a){var b=y.FilterMixin("type"),d=b.toJSON();return d.type.value=a,c(b,{type:function(a){return null==a?d.type.value:(d.type.value=a,this)}})},y.BoolQuery=function(){var a=y.QueryMixin("bool"),b=a.toJSON();return c(a,{must:function(a){var c,d;if(null==b.bool.must&&(b.bool.must=[]),null==a)return b.bool.must;if(l(a))b.bool.must.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be a Query or array of Queries");for(b.bool.must=[],c=0,d=a.length;d>c;c++){if(!l(a[c]))throw new TypeError("Argument must be an array of Queries");b.bool.must.push(a[c].toJSON())}}return this},mustNot:function(a){var c,d;if(null==b.bool.must_not&&(b.bool.must_not=[]),null==a)return b.bool.must_not;if(l(a))b.bool.must_not.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be a Query or array of Queries");for(b.bool.must_not=[],c=0,d=a.length;d>c;c++){if(!l(a[c]))throw new TypeError("Argument must be an array of Queries");b.bool.must_not.push(a[c].toJSON())}}return this},should:function(a){var c,d;if(null==b.bool.should&&(b.bool.should=[]),null==a)return b.bool.should;if(l(a))b.bool.should.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be a Query or array of Queries");for(b.bool.should=[],c=0,d=a.length;d>c;c++){if(!l(a[c]))throw new TypeError("Argument must be an array of Queries");b.bool.should.push(a[c].toJSON())}}return this},adjustPureNegative:function(a){return null==a?b.bool.adjust_pure_negative:(b.bool.adjust_pure_negative=a,this)},disableCoord:function(a){return null==a?b.bool.disable_coord:(b.bool.disable_coord=a,this)},minimumNumberShouldMatch:function(a){return null==a?b.bool.minimum_number_should_match:(b.bool.minimum_number_should_match=a,this)}})},y.BoostingQuery=function(a,b,d){if(!l(a)||!l(b))throw new TypeError("Arguments must be Queries");var e=y.QueryMixin("boosting"),f=e.toJSON();return f.boosting.positive=a.toJSON(),f.boosting.negative=b.toJSON(),f.boosting.negative_boost=d,c(e,{positive:function(a){if(null==a)return f.boosting.positive;if(!l(a))throw new TypeError("Argument must be a Query");return f.boosting.positive=a.toJSON(),this},negative:function(a){if(null==a)return f.boosting.negative;if(!l(a))throw new TypeError("Argument must be a Query");return f.boosting.negative=a.toJSON(),this},negativeBoost:function(a){return null==a?f.boosting.negative_boost:(f.boosting.negative_boost=a,this)}})},y.CommonTermsQuery=function(a,b){var d=y.QueryMixin("common"),e=d.toJSON();return null==a&&(a="no_field_set"),e.common[a]={},null!=b&&(e.common[a].query=b),c(d,{field:function(b){var c=e.common[a];return null==b?a:(delete e.common[a],a=b,e.common[b]=c,this)},query:function(b){return null==b?e.common[a].query:(e.common[a].query=b,this)},analyzer:function(b){return null==b?e.common[a].analyzer:(e.common[a].analyzer=b,this)},disableCoord:function(b){return null==b?e.common[a].disable_coord:(e.common[a].disable_coord=b,this)},cutoffFrequency:function(b){return null==b?e.common[a].cutoff_frequency:(e.common[a].cutoff_frequency=b,this)},highFreqOperator:function(b){return null==b?e.common[a].high_freq_operator:(b=b.toLowerCase(),("and"===b||"or"===b)&&(e.common[a].high_freq_operator=b),this)},lowFreqOperator:function(b){return null==b?e.common[a].low_freq_operator:(b=b.toLowerCase(),("and"===b||"or"===b)&&(e.common[a].low_freq_operator=b),this)},minimumShouldMatch:function(b){return null==b?e.common[a].minimum_should_match.low_freq:(null==e.common[a].minimum_should_match&&(e.common[a].minimum_should_match={}),e.common[a].minimum_should_match.low_freq=b,this)},minimumShouldMatchLowFreq:function(a){return this.minimumShouldMatch(a)},minimumShouldMatchHighFreq:function(b){return null==b?e.common[a].minimum_should_match.high_freq:(null==e.common[a].minimum_should_match&&(e.common[a].minimum_should_match={}),e.common[a].minimum_should_match.high_freq=b,this)},boost:function(b){return null==b?e.common[a].boost:(e.common[a].boost=b,this)}})},y.ConstantScoreQuery=function(){var a=y.QueryMixin("constant_score"),b=a.toJSON();return c(a,{query:function(a){if(null==a)return b.constant_score.query;if(!l(a))throw new TypeError("Argument must be a Query");return b.constant_score.query=a.toJSON(),this},filter:function(a){if(null==a)return b.constant_score.filter;if(!n(a))throw new TypeError("Argument must be a Filter");return b.constant_score.filter=a.toJSON(),this},cache:function(a){return null==a?b.constant_score._cache:(b.constant_score._cache=a,this)},cacheKey:function(a){return null==a?b.constant_score._cache_key:(b.constant_score._cache_key=a,this)}})},y.DisMaxQuery=function(){var a=y.QueryMixin("dis_max"),b=a.toJSON();return c(a,{queries:function(a){var c,d;if(null==a)return b.dis_max.queries;if(null==b.dis_max.queries&&(b.dis_max.queries=[]),l(a))b.dis_max.queries.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be a Query or array of Queries");for(b.dis_max.queries=[],c=0,d=a.length;d>c;c++){if(!l(a[c]))throw new TypeError("Argument must be array of Queries");b.dis_max.queries.push(a[c].toJSON())}}return this},tieBreaker:function(a){return null==a?b.dis_max.tie_breaker:(b.dis_max.tie_breaker=a,this)}})},y.FieldMaskingSpanQuery=function(a,b){if(!l(a))throw new TypeError("Argument must be a SpanQuery");var d=y.QueryMixin("field_masking_span"),e=d.toJSON();return e.field_masking_span.query=a.toJSON(),e.field_masking_span.field=b,c(d,{query:function(a){if(null==a)return e.field_masking_span.query;if(!l(a))throw new TypeError("Argument must be a SpanQuery");return e.field_masking_span.query=a.toJSON(),this},field:function(a){return null==a?e.field_masking_span.field:(e.field_masking_span.field=a,this)}})},y.FilteredQuery=function(a,b){if(!l(a))throw new TypeError("Argument must be a Query");if(null!=b&&!n(b))throw new TypeError("Argument must be a Filter");var d=y.QueryMixin("filtered"),e=d.toJSON();return e.filtered.query=a.toJSON(),null!=b&&(e.filtered.filter=b.toJSON()),c(d,{query:function(a){if(null==a)return e.filtered.query;if(!l(a))throw new TypeError("Argument must be a Query");return e.filtered.query=a.toJSON(),this},filter:function(a){if(null==a)return e.filtered.filter;if(!n(a))throw new TypeError("Argument must be a Filter");return e.filtered.filter=a.toJSON(),this},strategy:function(a){return null==a?e.filtered.strategy:(a=a.toLowerCase(),("query_first"===a||"random_access_always"===a||"leap_frog"===a||"leap_frog_filter_first"===a||0===a.indexOf("random_access_"))&&(e.filtered.strategy=a),this)},cache:function(a){return null==a?e.filtered._cache:(e.filtered._cache=a,this)},cacheKey:function(a){return null==a?e.filtered._cache_key:(e.filtered._cache_key=a,this)}})},y.FuzzyLikeThisFieldQuery=function(a,b){var d=y.QueryMixin("flt_field"),e=d.toJSON();return e.flt_field[a]={like_text:b},c(d,{field:function(b){var c=e.flt_field[a];return null==b?a:(delete e.flt_field[a],a=b,e.flt_field[b]=c,this)},likeText:function(b){return null==b?e.flt_field[a].like_text:(e.flt_field[a].like_text=b,this)},ignoreTf:function(b){return null==b?e.flt_field[a].ignore_tf:(e.flt_field[a].ignore_tf=b,this)},maxQueryTerms:function(b){return null==b?e.flt_field[a].max_query_terms:(e.flt_field[a].max_query_terms=b,this)},minSimilarity:function(b){return null==b?e.flt_field[a].min_similarity:(e.flt_field[a].min_similarity=b,this)},prefixLength:function(b){return null==b?e.flt_field[a].prefix_length:(e.flt_field[a].prefix_length=b,this)},analyzer:function(b){return null==b?e.flt_field[a].analyzer:(e.flt_field[a].analyzer=b,this)},failOnUnsupportedField:function(b){return null==b?e.flt_field[a].fail_on_unsupported_field:(e.flt_field[a].fail_on_unsupported_field=b,this)},boost:function(b){return null==b?e.flt_field[a].boost:(e.flt_field[a].boost=b,this)}})},y.FuzzyLikeThisQuery=function(a){var b=y.QueryMixin("flt"),d=b.toJSON();return d.flt.like_text=a,c(b,{fields:function(a){if(null==d.flt.fields&&(d.flt.fields=[]),null==a)return d.flt.fields;if(g(a))d.flt.fields.push(a);else{if(!e(a))throw new TypeError("Argument must be a string or array");d.flt.fields=a}return this},likeText:function(a){return null==a?d.flt.like_text:(d.flt.like_text=a,this)},ignoreTf:function(a){return null==a?d.flt.ignore_tf:(d.flt.ignore_tf=a,this)},maxQueryTerms:function(a){return null==a?d.flt.max_query_terms:(d.flt.max_query_terms=a,this)},minSimilarity:function(a){return null==a?d.flt.min_similarity:(d.flt.min_similarity=a,this)},prefixLength:function(a){return null==a?d.flt.prefix_length:(d.flt.prefix_length=a,this)},analyzer:function(a){return null==a?d.flt.analyzer:(d.flt.analyzer=a,this)},failOnUnsupportedField:function(a){return null==a?d.flt.fail_on_unsupported_field:(d.flt.fail_on_unsupported_field=a,this)}})},y.FuzzyQuery=function(a,b){var d=y.QueryMixin("fuzzy"),e=d.toJSON();return e.fuzzy[a]={value:b},c(d,{field:function(b){var c=e.fuzzy[a];return null==b?a:(delete e.fuzzy[a],a=b,e.fuzzy[b]=c,this)},value:function(b){return null==b?e.fuzzy[a].value:(e.fuzzy[a].value=b,this)},transpositions:function(b){return null==b?e.fuzzy[a].transpositions:(e.fuzzy[a].transpositions=b,this)},maxExpansions:function(b){return null==b?e.fuzzy[a].max_expansions:(e.fuzzy[a].max_expansions=b,this)},minSimilarity:function(b){return null==b?e.fuzzy[a].min_similarity:(e.fuzzy[a].min_similarity=b,this)},prefixLength:function(b){return null==b?e.fuzzy[a].prefix_length:(e.fuzzy[a].prefix_length=b,this)},rewrite:function(b){return null==b?e.fuzzy[a].rewrite:(b=b.toLowerCase(),("constant_score_auto"===b||"scoring_boolean"===b||"constant_score_boolean"===b||"constant_score_filter"===b||0===b.indexOf("top_terms_boost_")||0===b.indexOf("top_terms_"))&&(e.fuzzy[a].rewrite=b),this)},boost:function(b){return null==b?e.fuzzy[a].boost:(e.fuzzy[a].boost=b,this)}})},y.GeoShapeQuery=function(a){var b=y.QueryMixin("geo_shape"),d=b.toJSON();return d.geo_shape[a]={},c(b,{field:function(b){var c=d.geo_shape[a];return null==b?a:(delete d.geo_shape[a],a=b,d.geo_shape[b]=c,this)},shape:function(b){return null==b?d.geo_shape[a].shape:(null!=d.geo_shape[a].indexed_shape&&delete d.geo_shape[a].indexed_shape,d.geo_shape[a].shape=b.toJSON(),this)},indexedShape:function(b){return null==b?d.geo_shape[a].indexed_shape:(null!=d.geo_shape[a].shape&&delete d.geo_shape[a].shape,d.geo_shape[a].indexed_shape=b.toJSON(),this)},relation:function(b){return null==b?d.geo_shape[a].relation:(b=b.toLowerCase(),("intersects"===b||"disjoint"===b||"within"===b)&&(d.geo_shape[a].relation=b),this)},strategy:function(b){return null==b?d.geo_shape[a].strategy:(b=b.toLowerCase(),("recursive"===b||"term"===b)&&(d.geo_shape[a].strategy=b),this)},boost:function(b){return null==b?d.geo_shape[a].boost:(d.geo_shape[a].boost=b,this)}})},y.HasChildQuery=function(a,b){if(!l(a))throw new TypeError("Argument must be a valid Query");var d=y.QueryMixin("has_child"),e=d.toJSON();return e.has_child.query=a.toJSON(),e.has_child.type=b,c(d,{query:function(a){if(null==a)return e.has_child.query;if(!l(a))throw new TypeError("Argument must be a valid Query");return e.has_child.query=a.toJSON(),this},type:function(a){return null==a?e.has_child.type:(e.has_child.type=a,this)},scope:function(){return this},scoreType:function(a){return null==a?e.has_child.score_type:(a=a.toLowerCase(),("none"===a||"max"===a||"sum"===a||"avg"===a)&&(e.has_child.score_type=a),this)},scoreMode:function(a){return null==a?e.has_child.score_mode:(a=a.toLowerCase(),("none"===a||"max"===a||"sum"===a||"avg"===a)&&(e.has_child.score_mode=a),this)},shortCircuitCutoff:function(a){return null==a?e.has_child.short_circuit_cutoff:(e.has_child.short_circuit_cutoff=a,this)}})},y.HasParentQuery=function(a,b){if(!l(a))throw new TypeError("Argument must be a Query");var d=y.QueryMixin("has_parent"),e=d.toJSON();return e.has_parent.query=a.toJSON(),e.has_parent.parent_type=b,c(d,{query:function(a){if(null==a)return e.has_parent.query;if(!l(a))throw new TypeError("Argument must be a Query");return e.has_parent.query=a.toJSON(),this},parentType:function(a){return null==a?e.has_parent.parent_type:(e.has_parent.parent_type=a,this)},scope:function(){return this},scoreType:function(a){return null==a?e.has_parent.score_type:(a=a.toLowerCase(),("none"===a||"score"===a)&&(e.has_parent.score_type=a),this)},scoreMode:function(a){return null==a?e.has_parent.score_mode:(a=a.toLowerCase(),("none"===a||"score"===a)&&(e.has_parent.score_mode=a),this)}})},y.IdsQuery=function(a){var b=y.QueryMixin("ids"),d=b.toJSON();if(g(a))d.ids.values=[a];else{if(!e(a))throw new TypeError("Argument must be string or array");d.ids.values=a}return c(b,{values:function(a){if(null==a)return d.ids.values;if(g(a))d.ids.values.push(a);else{if(!e(a))throw new TypeError("Argument must be string or array");d.ids.values=a}return this},type:function(a){if(null==d.ids.type&&(d.ids.type=[]),null==a)return d.ids.type;if(g(a))d.ids.type.push(a);else{if(!e(a))throw new TypeError("Argument must be string or array");d.ids.type=a}return this}})},y.IndicesQuery=function(a,b){if(!l(a))throw new TypeError("Argument must be a Query");var d=y.QueryMixin("indices"),f=d.toJSON();if(f.indices.query=a.toJSON(),g(b))f.indices.indices=[b];else{if(!e(b))throw new TypeError("Argument must be a string or array");f.indices.indices=b}return c(d,{indices:function(a){if(null==a)return f.indices.indices;if(g(a))f.indices.indices.push(a);else{if(!e(a))throw new TypeError("Argument must be a string or array");f.indices.indices=a}return this},query:function(a){if(null==a)return f.indices.query;if(!l(a))throw new TypeError("Argument must be a Query");return f.indices.query=a.toJSON(),this},noMatchQuery:function(a){if(null==a)return f.indices.no_match_query;if(g(a))a=a.toLowerCase(),("none"===a||"all"===a)&&(f.indices.no_match_query=a);else{if(!l(a))throw new TypeError("Argument must be string or Query");f.indices.no_match_query=a.toJSON()}return this}})},y.MatchAllQuery=function(){return y.QueryMixin("match_all")},y.MatchQuery=function(a,b){var d=y.QueryMixin("match"),e=d.toJSON();return e.match[a]={query:b},c(d,{query:function(b){return null==b?e.match[a].query:(e.match[a].query=b,this)},type:function(b){return null==b?e.match[a].type:(b=b.toLowerCase(),("boolean"===b||"phrase"===b||"phrase_prefix"===b)&&(e.match[a].type=b),this)},fuzziness:function(b){return null==b?e.match[a].fuzziness:(e.match[a].fuzziness=b,this)},cutoffFrequency:function(b){return null==b?e.match[a].cutoff_frequency:(e.match[a].cutoff_frequency=b,this)},prefixLength:function(b){return null==b?e.match[a].prefix_length:(e.match[a].prefix_length=b,this)},maxExpansions:function(b){return null==b?e.match[a].max_expansions:(e.match[a].max_expansions=b,this)},operator:function(b){return null==b?e.match[a].operator:(b=b.toLowerCase(),("and"===b||"or"===b)&&(e.match[a].operator=b),this)},slop:function(b){return null==b?e.match[a].slop:(e.match[a].slop=b,this)},analyzer:function(b){return null==b?e.match[a].analyzer:(e.match[a].analyzer=b,this)},minimumShouldMatch:function(b){return null==b?e.match[a].minimum_should_match:(e.match[a].minimum_should_match=b,this)},rewrite:function(b){return null==b?e.match[a].rewrite:(b=b.toLowerCase(),("constant_score_auto"===b||"scoring_boolean"===b||"constant_score_boolean"===b||"constant_score_filter"===b||0===b.indexOf("top_terms_boost_")||0===b.indexOf("top_terms_"))&&(e.match[a].rewrite=b),this)},fuzzyRewrite:function(b){return null==b?e.match[a].fuzzy_rewrite:(b=b.toLowerCase(),("constant_score_auto"===b||"scoring_boolean"===b||"constant_score_boolean"===b||"constant_score_filter"===b||0===b.indexOf("top_terms_boost_")||0===b.indexOf("top_terms_"))&&(e.match[a].fuzzy_rewrite=b),this)},fuzzyTranspositions:function(b){return null==b?e.match[a].fuzzy_transpositions:(e.match[a].fuzzy_transpositions=b,this)},lenient:function(b){return null==b?e.match[a].lenient:(e.match[a].lenient=b,this)},zeroTermsQuery:function(b){return null==b?e.match[a].zero_terms_query:(b=b.toLowerCase(),("all"===b||"none"===b)&&(e.match[a].zero_terms_query=b),this)},boost:function(b){return null==b?e.match[a].boost:(e.match[a].boost=b,this)}})},y.MoreLikeThisFieldQuery=function(a,b){var d=y.QueryMixin("mlt_field"),e=d.toJSON();return e.mlt_field[a]={like_text:b},c(d,{field:function(b){var c=e.mlt_field[a];return null==b?a:(delete e.mlt_field[a],a=b,e.mlt_field[b]=c,this)},likeText:function(b){return null==b?e.mlt_field[a].like_text:(e.mlt_field[a].like_text=b,this)},percentTermsToMatch:function(b){return null==b?e.mlt_field[a].percent_terms_to_match:(e.mlt_field[a].percent_terms_to_match=b,this)},minTermFreq:function(b){return null==b?e.mlt_field[a].min_term_freq:(e.mlt_field[a].min_term_freq=b,this)},maxQueryTerms:function(b){return null==b?e.mlt_field[a].max_query_terms:(e.mlt_field[a].max_query_terms=b,this)},stopWords:function(b){return null==b?e.mlt_field[a].stop_words:(e.mlt_field[a].stop_words=b,this)},minDocFreq:function(b){return null==b?e.mlt_field[a].min_doc_freq:(e.mlt_field[a].min_doc_freq=b,this)},maxDocFreq:function(b){return null==b?e.mlt_field[a].max_doc_freq:(e.mlt_field[a].max_doc_freq=b,this)},minWordLen:function(b){return null==b?e.mlt_field[a].min_word_len:(e.mlt_field[a].min_word_len=b,this)},maxWordLen:function(b){return null==b?e.mlt_field[a].max_word_len:(e.mlt_field[a].max_word_len=b,this)},analyzer:function(b){return null==b?e.mlt_field[a].analyzer:(e.mlt_field[a].analyzer=b,this)},boostTerms:function(b){return null==b?e.mlt_field[a].boost_terms:(e.mlt_field[a].boost_terms=b,this)},failOnUnsupportedField:function(b){return null==b?e.mlt_field[a].fail_on_unsupported_field:(e.mlt_field[a].fail_on_unsupported_field=b,this) +},boost:function(b){return null==b?e.mlt_field[a].boost:(e.mlt_field[a].boost=b,this)}})},y.MoreLikeThisQuery=function(a,b){var d=y.QueryMixin("mlt"),f=d.toJSON();if(f.mlt.like_text=b,f.mlt.fields=[],g(a))f.mlt.fields.push(a);else{if(!e(a))throw new TypeError("Argument must be string or array");f.mlt.fields=a}return c(d,{fields:function(a){if(null==a)return f.mlt.fields;if(g(a))f.mlt.fields.push(a);else{if(!e(a))throw new TypeError("Argument must be a string or array");f.mlt.fields=a}return this},likeText:function(a){return null==a?f.mlt.like_text:(f.mlt.like_text=a,this)},percentTermsToMatch:function(a){return null==a?f.mlt.percent_terms_to_match:(f.mlt.percent_terms_to_match=a,this)},minTermFreq:function(a){return null==a?f.mlt.min_term_freq:(f.mlt.min_term_freq=a,this)},maxQueryTerms:function(a){return null==a?f.mlt.max_query_terms:(f.mlt.max_query_terms=a,this)},stopWords:function(a){return null==a?f.mlt.stop_words:(f.mlt.stop_words=a,this)},minDocFreq:function(a){return null==a?f.mlt.min_doc_freq:(f.mlt.min_doc_freq=a,this)},maxDocFreq:function(a){return null==a?f.mlt.max_doc_freq:(f.mlt.max_doc_freq=a,this)},minWordLen:function(a){return null==a?f.mlt.min_word_len:(f.mlt.min_word_len=a,this)},maxWordLen:function(a){return null==a?f.mlt.max_word_len:(f.mlt.max_word_len=a,this)},analyzer:function(a){return null==a?f.mlt.analyzer:(f.mlt.analyzer=a,this)},boostTerms:function(a){return null==a?f.mlt.boost_terms:(f.mlt.boost_terms=a,this)},failOnUnsupportedField:function(a){return null==a?f.mlt.fail_on_unsupported_field:(f.mlt.fail_on_unsupported_field=a,this)}})},y.MultiMatchQuery=function(a,b){var d=y.QueryMixin("multi_match"),f=d.toJSON();if(f.multi_match.query=b,f.multi_match.fields=[],g(a))f.multi_match.fields.push(a);else{if(!e(a))throw new TypeError("Argument must be string or array");f.multi_match.fields=a}return c(d,{fields:function(a){if(null==a)return f.multi_match.fields;if(g(a))f.multi_match.fields.push(a);else{if(!e(a))throw new TypeError("Argument must be string or array");f.multi_match.fields=a}return this},useDisMax:function(a){return null==a?f.multi_match.use_dis_max:(f.multi_match.use_dis_max=a,this)},tieBreaker:function(a){return null==a?f.multi_match.tie_breaker:(f.multi_match.tie_breaker=a,this)},cutoffFrequency:function(a){return null==a?f.multi_match.cutoff_frequency:(f.multi_match.cutoff_frequency=a,this)},minimumShouldMatch:function(a){return null==a?f.multi_match.minimum_should_match:(f.multi_match.minimum_should_match=a,this)},rewrite:function(a){return null==a?f.multi_match.rewrite:(a=a.toLowerCase(),("constant_score_auto"===a||"scoring_boolean"===a||"constant_score_boolean"===a||"constant_score_filter"===a||0===a.indexOf("top_terms_boost_")||0===a.indexOf("top_terms_"))&&(f.multi_match.rewrite=a),this)},fuzzyRewrite:function(a){return null==a?f.multi_match.fuzzy_rewrite:(a=a.toLowerCase(),("constant_score_auto"===a||"scoring_boolean"===a||"constant_score_boolean"===a||"constant_score_filter"===a||0===a.indexOf("top_terms_boost_")||0===a.indexOf("top_terms_"))&&(f.multi_match.fuzzy_rewrite=a),this)},lenient:function(a){return null==a?f.multi_match.lenient:(f.multi_match.lenient=a,this)},query:function(a){return null==a?f.multi_match.query:(f.multi_match.query=a,this)},type:function(a){return null==a?f.multi_match.type:(a=a.toLowerCase(),("boolean"===a||"phrase"===a||"phrase_prefix"===a)&&(f.multi_match.type=a),this)},fuzziness:function(a){return null==a?f.multi_match.fuzziness:(f.multi_match.fuzziness=a,this)},prefixLength:function(a){return null==a?f.multi_match.prefix_length:(f.multi_match.prefix_length=a,this)},maxExpansions:function(a){return null==a?f.multi_match.max_expansions:(f.multi_match.max_expansions=a,this)},operator:function(a){return null==a?f.multi_match.operator:(a=a.toLowerCase(),("and"===a||"or"===a)&&(f.multi_match.operator=a),this)},slop:function(a){return null==a?f.multi_match.slop:(f.multi_match.slop=a,this)},analyzer:function(a){return null==a?f.multi_match.analyzer:(f.multi_match.analyzer=a,this)},zeroTermsQuery:function(a){return null==a?f.multi_match.zero_terms_query:(a=a.toLowerCase(),("all"===a||"none"===a)&&(f.multi_match.zero_terms_query=a),this)}})},y.NestedQuery=function(a){var b=y.QueryMixin("nested"),d=b.toJSON();return d.nested.path=a,c(b,{path:function(a){return null==a?d.nested.path:(d.nested.path=a,this)},query:function(a){if(null==a)return d.nested.query;if(!l(a))throw new TypeError("Argument must be a Query");return d.nested.query=a.toJSON(),this},filter:function(a){if(null==a)return d.nested.filter;if(!n(a))throw new TypeError("Argument must be a Filter");return d.nested.filter=a.toJSON(),this},scoreMode:function(a){return null==a?d.nested.score_mode:(a=a.toLowerCase(),("avg"===a||"total"===a||"max"===a||"none"===a||"sum"===a)&&(d.nested.score_mode=a),this)},scope:function(){return this}})},y.PrefixQuery=function(a,b){var d=y.QueryMixin("prefix"),e=d.toJSON();return e.prefix[a]={value:b},c(d,{field:function(b){var c=e.prefix[a];return null==b?a:(delete e.prefix[a],a=b,e.prefix[b]=c,this)},value:function(b){return null==b?e.prefix[a].value:(e.prefix[a].value=b,this)},rewrite:function(b){return null==b?e.prefix[a].rewrite:(b=b.toLowerCase(),("constant_score_auto"===b||"scoring_boolean"===b||"constant_score_boolean"===b||"constant_score_filter"===b||0===b.indexOf("top_terms_boost_")||0===b.indexOf("top_terms_"))&&(e.prefix[a].rewrite=b),this)},boost:function(b){return null==b?e.prefix[a].boost:(e.prefix[a].boost=b,this)}})},y.QueryStringQuery=function(a){var b=y.QueryMixin("query_string"),d=b.toJSON();return d.query_string.query=a,c(b,{query:function(a){return null==a?d.query_string.query:(d.query_string.query=a,this)},defaultField:function(a){return null==a?d.query_string.default_field:(d.query_string.default_field=a,this)},fields:function(a){if(null==d.query_string.fields&&(d.query_string.fields=[]),null==a)return d.query_string.fields;if(g(a))d.query_string.fields.push(a);else{if(!e(a))throw new TypeError("Argument must be a string or array");d.query_string.fields=a}return this},useDisMax:function(a){return null==a?d.query_string.use_dis_max:(d.query_string.use_dis_max=a,this)},defaultOperator:function(a){return null==a?d.query_string.default_operator:(a=a.toUpperCase(),("AND"===a||"OR"===a)&&(d.query_string.default_operator=a),this)},analyzer:function(a){return null==a?d.query_string.analyzer:(d.query_string.analyzer=a,this)},quoteAnalyzer:function(a){return null==a?d.query_string.quote_analyzer:(d.query_string.quote_analyzer=a,this)},allowLeadingWildcard:function(a){return null==a?d.query_string.allow_leading_wildcard:(d.query_string.allow_leading_wildcard=a,this)},lowercaseExpandedTerms:function(a){return null==a?d.query_string.lowercase_expanded_terms:(d.query_string.lowercase_expanded_terms=a,this)},enablePositionIncrements:function(a){return null==a?d.query_string.enable_position_increments:(d.query_string.enable_position_increments=a,this)},fuzzyPrefixLength:function(a){return null==a?d.query_string.fuzzy_prefix_length:(d.query_string.fuzzy_prefix_length=a,this)},fuzzyMinSim:function(a){return null==a?d.query_string.fuzzy_min_sim:(d.query_string.fuzzy_min_sim=a,this)},phraseSlop:function(a){return null==a?d.query_string.phrase_slop:(d.query_string.phrase_slop=a,this)},analyzeWildcard:function(a){return null==a?d.query_string.analyze_wildcard:(d.query_string.analyze_wildcard=a,this)},autoGeneratePhraseQueries:function(a){return null==a?d.query_string.auto_generate_phrase_queries:(d.query_string.auto_generate_phrase_queries=a,this)},minimumShouldMatch:function(a){return null==a?d.query_string.minimum_should_match:(d.query_string.minimum_should_match=a,this)},tieBreaker:function(a){return null==a?d.query_string.tie_breaker:(d.query_string.tie_breaker=a,this)},escape:function(a){return null==a?d.query_string.escape:(d.query_string.escape=a,this)},fuzzyMaxExpansions:function(a){return null==a?d.query_string.fuzzy_max_expansions:(d.query_string.fuzzy_max_expansions=a,this)},fuzzyRewrite:function(a){return null==a?d.query_string.fuzzy_rewrite:(a=a.toLowerCase(),("constant_score_auto"===a||"scoring_boolean"===a||"constant_score_boolean"===a||"constant_score_filter"===a||0===a.indexOf("top_terms_boost_")||0===a.indexOf("top_terms_"))&&(d.query_string.fuzzy_rewrite=a),this)},rewrite:function(a){return null==a?d.query_string.rewrite:(a=a.toLowerCase(),("constant_score_auto"===a||"scoring_boolean"===a||"constant_score_boolean"===a||"constant_score_filter"===a||0===a.indexOf("top_terms_boost_")||0===a.indexOf("top_terms_"))&&(d.query_string.rewrite=a),this)},quoteFieldSuffix:function(a){return null==a?d.query_string.quote_field_suffix:(d.query_string.quote_field_suffix=a,this)},lenient:function(a){return null==a?d.query_string.lenient:(d.query_string.lenient=a,this)}})},y.RangeQuery=function(a){var b=y.QueryMixin("range"),d=b.toJSON();return d.range[a]={},c(b,{field:function(b){var c=d.range[a];return null==b?a:(delete d.range[a],a=b,d.range[b]=c,this)},from:function(b){return null==b?d.range[a].from:(d.range[a].from=b,this)},to:function(b){return null==b?d.range[a].to:(d.range[a].to=b,this)},includeLower:function(b){return null==b?d.range[a].include_lower:(d.range[a].include_lower=b,this)},includeUpper:function(b){return null==b?d.range[a].include_upper:(d.range[a].include_upper=b,this)},gt:function(b){return null==b?d.range[a].gt:(d.range[a].gt=b,this)},gte:function(b){return null==b?d.range[a].gte:(d.range[a].gte=b,this)},lt:function(b){return null==b?d.range[a].lt:(d.range[a].lt=b,this)},lte:function(b){return null==b?d.range[a].lte:(d.range[a].lte=b,this)},boost:function(b){return null==b?d.range[a].boost:(d.range[a].boost=b,this)}})},y.RegexpQuery=function(a,b){var d=y.QueryMixin("regexp"),e=d.toJSON();return e.regexp[a]={value:b},c(d,{field:function(b){var c=e.regexp[a];return null==b?a:(delete e.regexp[a],a=b,e.regexp[b]=c,this)},value:function(b){return null==b?e.regexp[a].value:(e.regexp[a].value=b,this)},flags:function(b){return null==b?e.regexp[a].flags:(e.regexp[a].flags=b,this)},flagsValue:function(b){return null==b?e.regexp[a].flags_value:(e.regexp[a].flags_value=b,this)},rewrite:function(b){return null==b?e.regexp[a].rewrite:(b=b.toLowerCase(),("constant_score_auto"===b||"scoring_boolean"===b||"constant_score_boolean"===b||"constant_score_filter"===b||0===b.indexOf("top_terms_boost_")||0===b.indexOf("top_terms_"))&&(e.regexp[a].rewrite=b),this)},boost:function(b){return null==b?e.regexp[a].boost:(e.regexp[a].boost=b,this)}})},y.SpanFirstQuery=function(a,b){if(!l(a))throw new TypeError("Argument must be a SpanQuery");var d=y.QueryMixin("span_first"),e=d.toJSON();return e.span_first.match=a.toJSON(),e.span_first.end=b,c(d,{match:function(a){if(null==a)return e.span_first.match;if(!l(a))throw new TypeError("Argument must be a SpanQuery");return e.span_first.match=a.toJSON(),this},end:function(a){return null==a?e.span_first.end:(e.span_first.end=a,this)}})},y.SpanMultiTermQuery=function(a){if(null!=a&&!l(a))throw new TypeError("Argument must be a MultiTermQuery");var b=y.QueryMixin("span_multi"),d=b.toJSON();return d.span_multi.match={},null!=a&&(d.span_multi.match=a.toJSON()),c(b,{match:function(a){if(null==a)return d.span_multi.match;if(!l(a))throw new TypeError("Argument must be a MultiTermQuery");return d.span_multi.match=a.toJSON(),this}})},y.SpanNearQuery=function(a,b){var d,f,g=y.QueryMixin("span_near"),h=g.toJSON();if(h.span_near.clauses=[],h.span_near.slop=b,l(a))h.span_near.clauses.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be SpanQuery or array of SpanQueries");for(d=0,f=a.length;f>d;d++){if(!l(a[d]))throw new TypeError("Argument must be array of SpanQueries");h.span_near.clauses.push(a[d].toJSON())}}return c(g,{clauses:function(a){var b,c;if(null==a)return h.span_near.clauses;if(l(a))h.span_near.clauses.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be SpanQuery or array of SpanQueries");for(h.span_near.clauses=[],b=0,c=a.length;c>b;b++){if(!l(a[b]))throw new TypeError("Argument must be array of SpanQueries");h.span_near.clauses.push(a[b].toJSON())}}return this},slop:function(a){return null==a?h.span_near.slop:(h.span_near.slop=a,this)},inOrder:function(a){return null==a?h.span_near.in_order:(h.span_near.in_order=a,this)},collectPayloads:function(a){return null==a?h.span_near.collect_payloads:(h.span_near.collect_payloads=a,this)}})},y.SpanNotQuery=function(a,b){if(!l(a)||!l(b))throw new TypeError("Argument must be a SpanQuery");var d=y.QueryMixin("span_not"),e=d.toJSON();return e.span_not.include=a.toJSON(),e.span_not.exclude=b.toJSON(),c(d,{include:function(a){if(null==a)return e.span_not.include;if(!l(a))throw new TypeError("Argument must be a SpanQuery");return e.span_not.include=a.toJSON(),this},exclude:function(a){if(null==a)return e.span_not.exclude;if(!l(a))throw new TypeError("Argument must be a SpanQuery");return e.span_not.exclude=a.toJSON(),this}})},y.SpanOrQuery=function(a){var b,d,f=y.QueryMixin("span_or"),g=f.toJSON();if(g.span_or.clauses=[],l(a))g.span_or.clauses.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be SpanQuery or array of SpanQueries");for(b=0,d=a.length;d>b;b++){if(!l(a[b]))throw new TypeError("Argument must be array of SpanQueries");g.span_or.clauses.push(a[b].toJSON())}}return c(f,{clauses:function(a){var b,c;if(null==a)return g.span_or.clauses;if(l(a))g.span_or.clauses.push(a.toJSON());else{if(!e(a))throw new TypeError("Argument must be SpanQuery or array of SpanQueries");for(g.span_or.clauses=[],b=0,c=a.length;c>b;b++){if(!l(a[b]))throw new TypeError("Argument must be array of SpanQueries");g.span_or.clauses.push(a[b].toJSON())}}return this}})},y.SpanTermQuery=function(a,b){var d=y.QueryMixin("span_term"),e=d.toJSON();return e.span_term[a]={term:b},c(d,{field:function(b){var c=e.span_term[a];return null==b?a:(delete e.span_term[a],a=b,e.span_term[b]=c,this)},term:function(b){return null==b?e.span_term[a].term:(e.span_term[a].term=b,this)},boost:function(b){return null==b?e.span_term[a].boost:(e.span_term[a].boost=b,this)}})},y.TermQuery=function(a,b){var d=y.QueryMixin("term"),e=d.toJSON();return e.term[a]={term:b},c(d,{field:function(b){var c=e.term[a];return null==b?a:(delete e.term[a],a=b,e.term[b]=c,this)},term:function(b){return null==b?e.term[a].term:(e.term[a].term=b,this)},boost:function(b){return null==b?e.term[a].boost:(e.term[a].boost=b,this)}})},y.TermsQuery=function(a,b){var d=y.QueryMixin("terms"),f=d.toJSON();if(g(b))f.terms[a]=[b];else{if(!e(b))throw new TypeError("Argument must be string or array");f.terms[a]=b}return c(d,{field:function(b){var c=f.terms[a];return null==b?a:(delete f.terms[a],a=b,f.terms[b]=c,this)},terms:function(b){if(null==b)return f.terms[a];if(g(b))f.terms[a].push(b);else{if(!e(b))throw new TypeError("Argument must be string or array");f.terms[a]=b}return this},minimumShouldMatch:function(a){return null==a?f.terms.minimum_should_match:(f.terms.minimum_should_match=a,this)},disableCoord:function(a){return null==a?f.terms.disable_coord:(f.terms.disable_coord=a,this)}})},y.TopChildrenQuery=function(a,b){if(!l(a))throw new TypeError("Argument must be a Query");var d=y.QueryMixin("top_children"),e=d.toJSON();return e.top_children.query=a.toJSON(),e.top_children.type=b,c(d,{query:function(a){if(null==a)return e.top_children.query;if(!l(a))throw new TypeError("Argument must be a Query");return e.top_children.query=a.toJSON(),this},type:function(a){return null==a?e.top_children.type:(e.top_children.type=a,this)},scope:function(){return this},score:function(a){return null==a?e.top_children.score:(a=a.toLowerCase(),("max"===a||"sum"===a||"avg"===a||"total"===a)&&(e.top_children.score=a),this)},scoreMode:function(a){return null==a?e.top_children.score_mode:(a=a.toLowerCase(),("max"===a||"sum"===a||"avg"===a||"total"===a)&&(e.top_children.score_mode=a),this)},factor:function(a){return null==a?e.top_children.factor:(e.top_children.factor=a,this)},incrementalFactor:function(a){return null==a?e.top_children.incremental_factor:(e.top_children.incremental_factor=a,this)}})},y.WildcardQuery=function(a,b){var d=y.QueryMixin("wildcard"),e=d.toJSON();return e.wildcard[a]={value:b},c(d,{field:function(b){var c=e.wildcard[a];return null==b?a:(delete e.wildcard[a],a=b,e.wildcard[b]=c,this)},value:function(b){return null==b?e.wildcard[a].value:(e.wildcard[a].value=b,this)},rewrite:function(b){return null==b?e.wildcard[a].rewrite:(b=b.toLowerCase(),("constant_score_auto"===b||"scoring_boolean"===b||"constant_score_boolean"===b||"constant_score_filter"===b||0===b.indexOf("top_terms_boost_")||0===b.indexOf("top_terms_"))&&(e.wildcard[a].rewrite=b),this)},boost:function(b){return null==b?e.wildcard[a].boost:(e.wildcard[a].boost=b,this)}})},y.GeoPoint=function(b){var c=[0,0];return null!=b&&e(b)&&2===b.length&&(c=[b[1],b[0]]),{properties:function(b){return null==b?c:(f(b)&&a(b,"lat")&&a(b,"lon")?c={lat:b.lat,lon:b.lon}:f(b)&&a(b,"geohash")&&(c={geohash:b.geohash}),this)},string:function(a){return null==a?c:(g(a)&&-1!==a.indexOf(",")&&(c=a),this)},geohash:function(a,b){return b=null!=b&&h(b)?b:12,null==a?c:(g(a)&&a.length===b&&(c=a),this)},array:function(a){return null==a?c:(e(a)&&2===a.length&&(c=[a[1],a[0]]),this)},_type:function(){return"geo point"},toJSON:function(){return c}}},y.Highlight=function(c){var d={fields:{}},h=function(b,c,e){null==b?d[c]=e:(a(d.fields,b)||(d.fields[b]={}),d.fields[b][c]=e)};return null!=c&&(g(c)?d.fields[c]={}:e(c)&&b(c,function(a){d.fields[a]={}})),{fields:function(c){return null==c?d.fields:(g(c)?a(d.fields,c)||(d.fields[c]={}):e(c)&&b(c,function(b){a(d.fields,b)||(d.fields[b]={})}),void 0)},preTags:function(a,b){return null===a&&null!=b?d.fields[b].pre_tags:null==a?d.pre_tags:(g(a)?h(b,"pre_tags",[a]):e(a)&&h(b,"pre_tags",a),this)},postTags:function(a,b){return null===a&&null!=b?d.fields[b].post_tags:null==a?d.post_tags:(g(a)?h(b,"post_tags",[a]):e(a)&&h(b,"post_tags",a),this)},order:function(a,b){return null===a&&null!=b?d.fields[b].order:null==a?d.order:(a=a.toLowerCase(),"score"===a&&h(b,"order",a),this)},tagsSchema:function(a){return null==a?d.tags_schema:(a=a.toLowerCase(),"styled"===a&&(d.tags_schema=a),this)},highlightFilter:function(a,b){return null===a&&null!=b?d.fields[b].highlight_filter:null==a?d.highlight_filter:(h(b,"highlight_filter",a),this)},fragmentSize:function(a,b){return null===a&&null!=b?d.fields[b].fragment_size:null==a?d.fragment_size:(h(b,"fragment_size",a),this)},numberOfFragments:function(a,b){return null===a&&null!=b?d.fields[b].number_of_fragments:null==a?d.number_of_fragments:(h(b,"number_of_fragments",a),this)},encoder:function(a){return null==a?d.encoder:(a=a.toLowerCase(),("default"===a||"html"===a)&&(d.encoder=a),this)},requireFieldMatch:function(a,b){return null===a&&null!=b?d.fields[b].require_field_match:null==a?d.require_field_match:(h(b,"require_field_match",a),this)},boundaryMaxScan:function(a,b){return null===a&&null!=b?d.fields[b].boundary_max_scan:null==a?d.boundary_max_scan:(h(b,"boundary_max_scan",a),this)},boundaryChars:function(a,b){return null===a&&null!=b?d.fields[b].boundary_chars:null==a?d.boundary_chars:(h(b,"boundary_chars",a),this)},type:function(a,b){return null===a&&null!=b?d.fields[b].type:null==a?d.type:(a=a.toLowerCase(),("fast-vector-highlighter"===a||"highlighter"===a)&&h(b,"type",a),this)},fragmenter:function(a,b){return null===a&&null!=b?d.fields[b].fragmenter:null==a?d.fragmenter:(a=a.toLowerCase(),("simple"===a||"span"===a)&&h(b,"fragmenter",a),this)},options:function(a,b){if(null===a&&null!=b)return d.fields[b].options;if(null==a)return d.options;if(!f(a)||e(a)||k(a))throw new TypeError("Parameter must be an object");return h(b,"options",a),this},_type:function(){return"highlight"},toJSON:function(){return d}}},y.IndexedShape=function(a,b){var c={type:a,id:b};return{type:function(a){return null==a?c.type:(c.type=a,this)},id:function(a){return null==a?c.id:(c.id=a,this)},index:function(a){return null==a?c.index:(c.index=a,this)},shapeFieldName:function(a){return null==a?c.shape_field_name:(c.shape_field_name=a,this)},_type:function(){return"indexed shape"},toJSON:function(){return c}}},y.Request=function(){var b={};return{sort:function(){var c,d;if(a(b,"sort")||(b.sort=[]),0===arguments.length)return b.sort;if(1===arguments.length){var f=arguments[0];if(g(f))b.sort.push(f);else if(u(f))b.sort.push(f.toJSON());else{if(!e(f))throw new TypeError("Argument must be string, Sort, or array");for(b.sort=[],c=0,d=f.length;d>c;c++)if(g(f[c]))b.sort.push(f[c]);else{if(!u(f[c]))throw new TypeError("Invalid object in array");b.sort.push(f[c].toJSON())}}}else if(2===arguments.length){var h=arguments[0],i=arguments[1];if(g(h)&&g(i)&&(i=i.toLowerCase(),"asc"===i||"desc"===i)){var j={};j[h]={order:i},b.sort.push(j)}}return this},trackScores:function(a){return null==a?b.track_scores:(b.track_scores=a,this)},from:function(a){return null==a?b.from:(b.from=a,this)},size:function(a){return null==a?b.size:(b.size=a,this)},timeout:function(a){return null==a?b.timeout:(b.timeout=a,this)},fields:function(a){if(null==a)return b.fields;if(null==b.fields&&(b.fields=[]),g(a))b.fields.push(a);else{if(!e(a))throw new TypeError("Argument must be a string or an array");b.fields=a}return this},source:function(a,c){if(null==a&&null==c)return b._source;if(!e(a)&&!g(a)&&!i(a))throw new TypeError("Argument includes must be a string, an array, or a boolean");if(null!=c&&!e(c)&&!g(c))throw new TypeError("Argument excludes must be a string or an array");return i(a)?b._source=a:(b._source={includes:a},null!=c&&(b._source.excludes=c)),this},rescore:function(a){if(null==a)return b.rescore;if(!m(a))throw new TypeError("Argument must be a Rescore");return b.rescore=a.toJSON(),this},query:function(a){if(null==a)return b.query;if(!l(a))throw new TypeError("Argument must be a Query");return b.query=a.toJSON(),this},facet:function(a){if(null==a)return b.facets;if(null==b.facets&&(b.facets={}),!o(a))throw new TypeError("Argument must be a Facet");return c(b.facets,a.toJSON()),this},aggregation:function(a){if(null==a)return b.aggs;if(null==b.aggs&&(b.aggs={}),!p(a))throw new TypeError("Argument must be an Aggregation");return c(b.aggs,a.toJSON()),this},agg:function(a){return this.aggregation(a)},filter:function(a){if(null==a)return b.filter;if(!n(a))throw new TypeError("Argument must be a Filter");return b.filter=a.toJSON(),this},highlight:function(a){if(null==a)return b.highlight;if(!v(a))throw new TypeError("Argument must be a Highlight object");return b.highlight=a.toJSON(),this},suggest:function(a){if(null==a)return b.suggest;if(null==b.suggest&&(b.suggest={}),g(a))b.suggest.text=a;else{if(!w(a))throw new TypeError("Argument must be a string or Suggest object");c(b.suggest,a.toJSON())}return this},scriptField:function(a){if(null==a)return b.script_fields;if(null==b.script_fields&&(b.script_fields={}),!q(a))throw new TypeError("Argument must be a ScriptField");return c(b.script_fields,a.toJSON()),this},indexBoost:function(a,c){return null==b.indices_boost&&(b.indices_boost={}),0===arguments.length?b.indices_boost:(b.indices_boost[a]=c,this)},explain:function(a){return null==a?b.explain:(b.explain=a,this)},version:function(a){return null==a?b.version:(b.version=a,this)},minScore:function(a){return null==a?b.min_score:(b.min_score=a,this)},_type:function(){return"request"},toJSON:function(){return b}}},y.Rescore=function(a,b){if(null!=a&&!h(a))throw new TypeError("Argument must be a Number");if(null!=b&&!l(b))throw new TypeError("Argument must be a Query");var c={query:{}};return null!=a&&(c.window_size=a),null!=b&&(c.query.rescore_query=b.toJSON()),{rescoreQuery:function(a){if(null==a)return c.query.rescore_query;if(!l(a))throw new TypeError("Argument must be a Query");return c.query.rescore_query=a.toJSON(),this},queryWeight:function(a){if(null==a)return c.query.query_weight;if(!h(a))throw new TypeError("Argument must be a Number");return c.query.query_weight=a,this},rescoreQueryWeight:function(a){if(null==a)return c.query.rescore_query_weight;if(!h(a))throw new TypeError("Argument must be a Number");return c.query.rescore_query_weight=a,this},windowSize:function(a){if(null==a)return c.window_size;if(!h(a))throw new TypeError("Argument must be a Number");return c.window_size=a,this},scoreMode:function(a){return null==a?c.query.score_mode:(a=a.toLowerCase(),("total"===a||"min"===a||"max"===a||"multiply"===a||"avg"===a)&&(c.query.score_mode=a),this)},_type:function(){return"rescore"},toJSON:function(){return c}}},y.ScriptField=function(a){var b={};return b[a]={},{lang:function(c){return null==c?b[a].lang:(b[a].lang=c,this)},script:function(c){return null==c?b[a].script:(b[a].script=c,this)},params:function(c){return null==c?b[a].params:(b[a].params=c,this)},ignoreFailure:function(c){return null==c?b[a].ignore_failure:(b[a].ignore_failure=c,this)},_type:function(){return"script field"},toJSON:function(){return b}}},y.Shape=function(a,b){var c={},d=function(a){var b=!1;return("point"===a||"linestring"===a||"polygon"===a||"multipoint"===a||"envelope"===a||"multipolygon"===a||"circle"===a||"multilinestring"===a)&&(b=!0),b};return a=a.toLowerCase(),d(a)&&(c.type=a,c.coordinates=b),{type:function(a){return null==a?c.type:(a=a.toLowerCase(),d(a)&&(c.type=a),this)},coordinates:function(a){return null==a?c.coordinates:(c.coordinates=a,this)},radius:function(a){return null==a?c.radius:(c.radius=a,this)},_type:function(){return"shape"},toJSON:function(){return c}}},y.Sort=function(a){null==a&&(a="_score");var b={},c=a,d="_geo_distance",e="_script";return b[c]={},{field:function(d){var e=b[c];return null==d?a:(delete b[c],a=d,c=d,b[c]=e,this)},geoDistance:function(e){var f=b[c];if(null==e)return b[c][a];if(!r(e))throw new TypeError("Argument must be a GeoPoint");return delete b[c],c=d,b[c]=f,b[c][a]=e.toJSON(),this},script:function(a){var d=b[c];return null==a?b[c].script:(delete b[c],c=e,b[c]=d,b[c].script=a,this)},order:function(a){return null==a?b[c].order:(a=a.toLowerCase(),("asc"===a||"desc"===a)&&(b[c].order=a),this)},asc:function(){return b[c].order="asc",this},desc:function(){return b[c].order="desc",this},reverse:function(a){return null==a?b[c].reverse:(b[c].reverse=a,this)},missing:function(a){return null==a?b[c].missing:(b[c].missing=a,this)},ignoreUnmapped:function(a){return null==a?b[c].ignore_unmapped:(b[c].ignore_unmapped=a,this)},unit:function(a){return null==a?b[c].unit:(a=a.toLowerCase(),("mi"===a||"km"===a)&&(b[c].unit=a),this)},normalize:function(a){return null==a?b[c].normalize:(b[c].normalize=a,this)},distanceType:function(a){return null==a?b[c].distance_type:(a=a.toLowerCase(),("arc"===a||"plane"===a)&&(b[c].distance_type=a),this)},params:function(a){return null==a?b[c].params:(b[c].params=a,this)},lang:function(a){return null==a?b[c].lang:(b[c].lang=a,this)},type:function(a){return null==a?b[c].type:(a=a.toLowerCase(),("string"===a||"number"===a)&&(b[c].type=a),this)},mode:function(a){return null==a?b[c].mode:(a=a.toLowerCase(),("min"===a||"max"===a||"sum"===a||"avg"===a)&&(b[c].mode=a),this)},nestedPath:function(a){return null==a?b[c].nested_path:(b[c].nested_path=a,this)},nestedFilter:function(a){if(null==a)return b[c].nested_filter;if(!n(a))throw new TypeError("Argument must be a Filter");return b[c].nested_filter=a.toJSON(),this},_type:function(){return"sort"},toJSON:function(){return b}}},y.CompletionSuggester=function(a){var b,d=y.SuggesterMixin(a),e=d.toJSON();return e[a].completion={},b=y.SuggestContextMixin(e[a].completion),c(d,b,{fuzzy:function(b){return null==b?e[a].completion.fuzzy:(b&&null==e[a].completion.fuzzy?e[a].completion.fuzzy={}:b||null==e[a].completion.fuzzy||delete e[a].completion.fuzzy,this)},transpositions:function(b){return null==e[a].completion.fuzzy&&(e[a].completion.fuzzy={}),null==b?e[a].completion.fuzzy.transpositions:(e[a].completion.fuzzy.transpositions=b,this)},unicodeAware:function(b){return null==e[a].completion.fuzzy&&(e[a].completion.fuzzy={}),null==b?e[a].completion.fuzzy.unicode_aware:(e[a].completion.fuzzy.unicode_aware=b,this)},editDistance:function(b){return null==e[a].completion.fuzzy&&(e[a].completion.fuzzy={}),null==b?e[a].completion.fuzzy.edit_distance:(e[a].completion.fuzzy.edit_distance=b,this)},minLength:function(b){return null==e[a].completion.fuzzy&&(e[a].completion.fuzzy={}),null==b?e[a].completion.fuzzy.min_length:(e[a].completion.fuzzy.min_length=b,this)},prefixLength:function(b){return null==e[a].completion.fuzzy&&(e[a].completion.fuzzy={}),null==b?e[a].completion.fuzzy.prefix_length:(e[a].completion.fuzzy.prefix_length=b,this)}})},y.DirectGenerator=function(){var a={},b=y.DirectSettingsMixin(a);return c(b,{preFilter:function(b){return null==b?a.pre_filter:(a.pre_filter=b,this)},postFilter:function(b){return null==b?a.post_filter:(a.post_filter=b,this)},field:function(b){return null==b?a.field:(a.field=b,this)},size:function(b){return null==b?a.size:(a.size=b,this)},_type:function(){return"generator"},toJSON:function(){return a}})},y.PhraseSuggester=function(a){var b,d=y.SuggesterMixin(a),f=d.toJSON();return f[a].phrase={},b=y.SuggestContextMixin(f[a].phrase),c(d,b,{realWorldErrorLikelihood:function(b){return null==b?f[a].phrase.real_world_error_likelihood:(f[a].phrase.real_world_error_likelihood=b,this)},confidence:function(b){return null==b?f[a].phrase.confidence:(f[a].phrase.confidence=b,this)},separator:function(b){return null==b?f[a].phrase.separator:(f[a].phrase.separator=b,this)},maxErrors:function(b){return null==b?f[a].phrase.max_errors:(f[a].phrase.max_errors=b,this)},gramSize:function(b){return null==b?f[a].phrase.gram_size:(f[a].phrase.gram_size=b,this)},forceUnigrams:function(b){return null==b?f[a].phrase.force_unigrams:(f[a].phrase.force_unigrams=b,this)},tokenLimit:function(b){return null==b?f[a].phrase.token_limit:(f[a].phrase.token_limit=b,this)},linearSmoothing:function(b,c,d){return 0===arguments.length?f[a].phrase.smoothing:(f[a].phrase.smoothing={linear:{trigram_lambda:b,bigram_lambda:c,unigram_lambda:d}},this)},laplaceSmoothing:function(b){return null==b?f[a].phrase.smoothing:(f[a].phrase.smoothing={laplace:{alpha:b}},this)},stupidBackoffSmoothing:function(b){return null==b?f[a].phrase.smoothing:(f[a].phrase.smoothing={stupid_backoff:{discount:b}},this)},highlight:function(b,c){return 0===arguments.length?f[a].phrase.highlight:(f[a].phrase.highlight={pre_tag:b,post_tag:c},this)},directGenerator:function(b){var c,d;if(null==f[a].phrase.direct_generator&&(f[a].phrase.direct_generator=[]),null==b)return f[a].phrase.direct_generator;if(x(b))f[a].phrase.direct_generator.push(b.toJSON());else{if(!e(b))throw new TypeError("Argument must be a Generator or array of Generators");for(f[a].phrase.direct_generator=[],c=0,d=b.length;d>c;c++){if(!x(b[c]))throw new TypeError("Argument must be an array of Generators");f[a].phrase.direct_generator.push(b[c].toJSON())}}return this}})},y.TermSuggester=function(a){var b,d,e=y.SuggesterMixin(a),f=e.toJSON();return f[a].term={},b=y.DirectSettingsMixin(f[a].term),d=y.SuggestContextMixin(f[a].term),c(e,b,d)},y.noConflict=function(){return z.ejs=A,this}}).call(this); \ No newline at end of file diff --git a/src/query/CustomBoostFactorQuery.js b/src/query/CustomBoostFactorQuery.js deleted file mode 100644 index 5866efe..0000000 --- a/src/query/CustomBoostFactorQuery.js +++ /dev/null @@ -1,69 +0,0 @@ - /** - @class -
A query allows to wrap another query and multiply its score by the - provided boost_factor. This can sometimes be desired since boost value set - on specific queries gets normalized, while this query boost factor does not.
- - @name ejs.CustomBoostFactorQuery - @ejs query - @borrows ejs.QueryMixin.boost as boost - @borrows ejs.QueryMixin._type as _type - @borrows ejs.QueryMixin.toJSON as toJSON - - @desc - Boosts a queries score without that boost being normalized. - - @param {Object} qry A valid query object. - */ - ejs.CustomBoostFactorQuery = function (qry) { - - if (!isQuery(qry)) { - throw new TypeError('Argument must be a Query'); - } - - var - _common = ejs.QueryMixin('custom_boost_factor'), - query = _common.toJSON(); - - query.custom_boost_factor.query = qry.toJSON(); - - return extend(_common, { - - /** - Sets the query to be apply the custom boost to. - - @member ejs.CustomBoostFactorQuery - @param {Object} q A valid Query object - @returns {Object} returnsthis
so that calls can be chained.
- */
- query: function (q) {
- if (q == null) {
- return query.custom_boost_factor.query;
- }
-
- if (!isQuery(q)) {
- throw new TypeError('Argument must be a Query');
- }
-
- query.custom_boost_factor.query = q.toJSON();
- return this;
- },
-
- /**
- Sets the language used in the script.
-
- @member ejs.CustomBoostFactorQuery
- @param {Double} boost The boost value.
- @returns {Object} returns this
so that calls can be chained.
- */
- boostFactor: function (boost) {
- if (boost == null) {
- return query.custom_boost_factor.boost_factor;
- }
-
- query.custom_boost_factor.boost_factor = boost;
- return this;
- }
-
- });
- };
diff --git a/src/query/CustomFiltersScoreQuery.js b/src/query/CustomFiltersScoreQuery.js
deleted file mode 100644
index d58cc82..0000000
--- a/src/query/CustomFiltersScoreQuery.js
+++ /dev/null
@@ -1,204 +0,0 @@
- /**
- @class
- A custom_filters_score query allows to execute a query, and if the hit - matches a provided filter (ordered), use either a boost or a script - associated with it to compute the score.
- -This can considerably simplify and increase performance for parameterized - based scoring since filters are easily cached for faster performance, and - boosting / script is considerably simpler.
- - @name ejs.CustomFiltersScoreQuery - @ejs query - @borrows ejs.QueryMixin.boost as boost - @borrows ejs.QueryMixin._type as _type - @borrows ejs.QueryMixin.toJSON as toJSON - - @desc - Returned documents matched by the query and scored based on if the document - matched in a filter. - - @param {Query} qry A valid query object. - @param {(Object|Object[])} filters A single object or array of object. Each - object must have a 'filter' property and either a 'boost' or 'script' - property. - */ - ejs.CustomFiltersScoreQuery = function (qry, filters) { - - if (!isQuery(qry)) { - throw new TypeError('Argument must be a Query'); - } - - var - _common = ejs.QueryMixin('custom_filters_score'), - query = _common.toJSON(), - - // generate a valid filter object that can be inserted into the filters - // array. Returns null when an invalid filter is passed in. - genFilterObject = function (filter) { - var obj = null; - - if (filter.filter && isFilter(filter.filter)) { - obj = { - filter: filter.filter.toJSON() - }; - - if (filter.boost) { - obj.boost = filter.boost; - } else if (filter.script) { - obj.script = filter.script; - } else { - // invalid filter, must boost or script must be specified - obj = null; - } - } - - return obj; - }; - - query.custom_filters_score.query = qry.toJSON(); - query.custom_filters_score.filters = []; - - each((isArray(filters) ? filters : [filters]), function (filter) { - var fObj = genFilterObject(filter); - if (fObj !== null) { - query.custom_filters_score.filters.push(fObj); - } - }); - - return extend(_common, { - - /** - Sets the query to be apply the custom boost to. - - @member ejs.CustomFiltersScoreQuery - @param {Object} q A valid Query object - @returns {Object} returnsthis
so that calls can be chained.
- */
- query: function (q) {
- if (q == null) {
- return query.custom_filters_score.query;
- }
-
- if (!isQuery(q)) {
- throw new TypeError('Argument must be a Query');
- }
-
- query.custom_filters_score.query = q.toJSON();
- return this;
- },
-
- /**
- Sets the filters and their related boost or script scoring method.
- -Takes an array of objects where each object has a 'filter' property - and either a 'boost' or 'script' property. Pass a single object to - add to the current list of filters or pass a list of objects to - overwrite all existing filters.
- -
- {filter: someFilter, boost: 2.1}
-
-
- @member ejs.CustomFiltersScoreQuery
- @param {(Object|Object[])} fltrs An object or array of objects
- contining a filter and either a boost or script property.
- @returns {Object} returns this
so that calls can be chained.
- */
- filters: function (fltrs) {
- if (fltrs == null) {
- return query.custom_filters_score.filters;
- }
-
- if (isArray(fltrs)) {
- query.custom_filters_score.filters = [];
- }
-
- each((isArray(fltrs) ? fltrs : [fltrs]), function (f) {
- var fObj = genFilterObject(f);
- if (fObj !== null) {
- query.custom_filters_score.filters.push(fObj);
- }
- });
-
- return this;
- },
-
- /**
- A score_mode can be defined to control how multiple matching - filters control the score.
- -
By default, it is set to first which means the first matching filter
- will control the score of the result. It can also be set to
- min/max/total/avg/multiply
which will aggregate the result from all
- matching filters based on the aggregation type.
-
- @member ejs.CustomFiltersScoreQuery
- @param {String} s The scoring type as a string.
- @returns {Object} returns this
so that calls can be chained.
- */
- scoreMode: function (s) {
- if (s == null) {
- return query.custom_filters_score.score_mode;
- }
-
- s = s.toLowerCase();
- if (s === 'first' || s === 'min' || s === 'max' || s === 'total' || s === 'avg' || s === 'multiply') {
- query.custom_filters_score.score_mode = s;
- }
-
- return this;
- },
-
- /**
- Sets parameters that will be applied to the script. Overwrites
- any existing params.
-
- @member ejs.CustomFiltersScoreQuery
- @param {Object} q An object where the keys are the parameter name and
- values are the parameter value.
- @returns {Object} returns this
so that calls can be chained.
- */
- params: function (p) {
- if (p == null) {
- return query.custom_filters_score.params;
- }
-
- query.custom_filters_score.params = p;
- return this;
- },
-
- /**
- Sets the language used in the script.
-
- @member ejs.CustomFiltersScoreQuery
- @param {String} l The script language, defatuls to mvel.
- @returns {Object} returns this
so that calls can be chained.
- */
- lang: function (l) {
- if (l == null) {
- return query.custom_filters_score.lang;
- }
-
- query.custom_filters_score.lang = l;
- return this;
- },
-
- /**
- Sets the maximum value a computed boost can reach.
-
- @member ejs.CustomFiltersScoreQuery
- @param {Double} max A positive double
value.
- @returns {Object} returns this
so that calls can be chained.
- */
- maxBoost: function (max) {
- if (max == null) {
- return query.custom_filters_score.max_boost;
- }
-
- query.custom_filters_score.max_boost = max;
- return this;
- }
-
- });
- };
diff --git a/src/query/CustomScoreQuery.js b/src/query/CustomScoreQuery.js
deleted file mode 100644
index 27f6ebe..0000000
--- a/src/query/CustomScoreQuery.js
+++ /dev/null
@@ -1,130 +0,0 @@
- /**
- @class
-
A query that wraps another query and customize the scoring of it - optionally with a computation derived from other field values in the - doc (numeric ones) using script expression.
- - @name ejs.CustomScoreQuery - @ejs query - @borrows ejs.QueryMixin.boost as boost - @borrows ejs.QueryMixin._type as _type - @borrows ejs.QueryMixin.toJSON as toJSON - - @desc - Scores a query based on a script. - - @param {Object} qry A valid query or filter object. - @param {String} script A valid script expression. - */ - ejs.CustomScoreQuery = function (qry, script) { - - if (!isQuery(qry) && !isFilter(qry)) { - throw new TypeError('Argument must be a Query or Filter'); - } - - var - _common = ejs.QueryMixin('custom_score'), - query = _common.toJSON(); - - query.custom_score.script = script; - - if (isQuery(qry)) { - query.custom_score.query = qry.toJSON(); - } else if (isFilter(qry)) { - query.custom_score.filter = qry.toJSON(); - } - - return extend(_common, { - - /** - Sets the query to apply the custom score to. - - @member ejs.CustomScoreQuery - @param {Object} q A valid Query object - @returns {Object} returnsthis
so that calls can be chained.
- */
- query: function (q) {
- if (q == null) {
- return query.custom_score.query;
- }
-
- if (!isQuery(q)) {
- throw new TypeError('Argument must be a Query');
- }
-
- query.custom_score.query = q.toJSON();
- return this;
- },
-
- /**
- Sets the filter to apply the custom score to.
-
- @member ejs.CustomScoreQuery
- @param {Object} f A valid Filter object
- @returns {Object} returns this
so that calls can be chained.
- */
- filter: function (f) {
- if (f == null) {
- return query.custom_score.filter;
- }
-
- if (!isFilter(f)) {
- throw new TypeError('Argument must be a Filter');
- }
-
- query.custom_score.filter = f.toJSON();
- return this;
- },
-
- /**
- Sets the script that calculates the custom score
-
- @member ejs.CustomScoreQuery
- @param {String} s A valid script expression
- @returns {Object} returns this
so that calls can be chained.
- */
- script: function (s) {
- if (s == null) {
- return query.custom_score.script;
- }
-
- query.custom_score.script = s;
- return this;
- },
-
- /**
- Sets parameters that will be applied to the script. Overwrites
- any existing params.
-
- @member ejs.CustomScoreQuery
- @param {Object} p An object where the keys are the parameter name and
- values are the parameter value.
- @returns {Object} returns this
so that calls can be chained.
- */
- params: function (p) {
- if (p == null) {
- return query.custom_score.params;
- }
-
- query.custom_score.params = p;
- return this;
- },
-
- /**
- Sets the language used in the script.
-
- @member ejs.CustomScoreQuery
- @param {String} l The script language, defatuls to mvel.
- @returns {Object} returns this
so that calls can be chained.
- */
- lang: function (l) {
- if (l == null) {
- return query.custom_score.lang;
- }
-
- query.custom_score.lang = l;
- return this;
- }
-
- });
- };
diff --git a/src/query/FieldQuery.js b/src/query/FieldQuery.js
deleted file mode 100644
index 5f1acf4..0000000
--- a/src/query/FieldQuery.js
+++ /dev/null
@@ -1,463 +0,0 @@
- /**
- @class
- A query that executes against a given field or document property. It is a simplified version
- of the queryString
object.
-
- @name ejs.FieldQuery
- @ejs query
- @borrows ejs.QueryMixin._type as _type
- @borrows ejs.QueryMixin.toJSON as toJSON
-
- @desc
- A query that executes against a given field or document property.
-
- @param {String} field The field or document property to search against.
- @param {String} qstr The value to match.
- */
- ejs.FieldQuery = function (field, qstr) {
-
- var
- _common = ejs.QueryMixin('field'),
- query = _common.toJSON();
-
- query.field[field] = {
- query: qstr
- };
-
- return extend(_common, {
-
- /**
- The field to run the query against.
-
- @member ejs.FieldQuery
- @param {String} f A single field name.
- @returns {Object} returns this
so that calls can be chained.
- */
- field: function (f) {
- var oldValue = query.field[field];
-
- if (f == null) {
- return field;
- }
-
- delete query.field[field];
- field = f;
- query.field[f] = oldValue;
-
- return this;
- },
-
- /**
- Sets the query string.
- - @member ejs.FieldQuery - @param {String} q The lucene query string. - @returns {Object} returnsthis
so that calls can be chained.
- */
- query: function (q) {
- if (q == null) {
- return query.field[field].query;
- }
-
- query.field[field].query = q;
- return this;
- },
-
- /**
- Set the default Boolean
operator.
This operator is used to join individual query terms when no operator is
- explicity used in the query string (i.e., this AND that
).
- Defaults to OR
.
this
so that calls can be chained.
- */
- defaultOperator: function (op) {
- if (op == null) {
- return query.field[field].default_operator;
- }
-
- op = op.toUpperCase();
- if (op === 'AND' || op === 'OR') {
- query.field[field].default_operator = op;
- }
-
- return this;
- },
-
- /**
- Sets the analyzer name used to analyze the Query
object.
this
so that calls can be chained.
- */
- analyzer: function (analyzer) {
- if (analyzer == null) {
- return query.field[field].analyzer;
- }
-
- query.field[field].analyzer = analyzer;
- return this;
- },
-
- /**
- Sets the quote analyzer name used to analyze the query
- when in quoted text.
this
so that calls can be chained.
- */
- quoteAnalyzer: function (analyzer) {
- if (analyzer == null) {
- return query.field[field].quote_analyzer;
- }
-
- query.field[field].quote_analyzer = analyzer;
- return this;
- },
-
- /**
- Sets whether or not we should auto generate phrase queries *if* the - analyzer returns more than one term. Default: false.
- - @member ejs.FieldQuery - @param {Boolean} trueFalse Atrue/false
value.
- @returns {Object} returns this
so that calls can be chained.
- */
- autoGeneratePhraseQueries: function (trueFalse) {
- if (trueFalse == null) {
- return query.field[field].auto_generate_phrase_queries;
- }
-
- query.field[field].auto_generate_phrase_queries = trueFalse;
- return this;
- },
-
- /**
- Sets whether or not wildcard characters (* and ?) are allowed as the
- first character of the Query
.
Default: true
.
true/false
value.
- @returns {Object} returns this
so that calls can be chained.
- */
- allowLeadingWildcard: function (trueFalse) {
- if (trueFalse == null) {
- return query.field[field].allow_leading_wildcard;
- }
-
- query.field[field].allow_leading_wildcard = trueFalse;
- return this;
- },
-
- /**
- Sets whether or not terms from wildcard, prefix, fuzzy,
and
- range
queries should automatically be lowercased in the Query
- since they are not analyzed.
Default: true
.
true/false
value.
- @returns {Object} returns this
so that calls can be chained.
- */
- lowercaseExpandedTerms: function (trueFalse) {
- if (trueFalse == null) {
- return query.field[field].lowercase_expanded_terms;
- }
-
- query.field[field].lowercase_expanded_terms = trueFalse;
- return this;
- },
-
- /**
- Sets whether or not position increments will be used in the
- Query
.
Default: true
.
true/false
value.
- @returns {Object} returns this
so that calls can be chained.
- */
- enablePositionIncrements: function (trueFalse) {
- if (trueFalse == null) {
- return query.field[field].enable_position_increments;
- }
-
- query.field[field].enable_position_increments = trueFalse;
- return this;
- },
-
- /**
- Set the minimum similarity for fuzzy queries.
- -Default: 0.5
.
double
value between 0 and 1.
- @returns {Object} returns this
so that calls can be chained.
- */
- fuzzyMinSim: function (minSim) {
- if (minSim == null) {
- return query.field[field].fuzzy_min_sim;
- }
-
- query.field[field].fuzzy_min_sim = minSim;
- return this;
- },
-
- /**
- Sets the prefix length for fuzzy queries.
- -Default: 0
.
integer
value.
- @returns {Object} returns this
so that calls can be chained.
- */
- fuzzyPrefixLength: function (fuzzLen) {
- if (fuzzLen == null) {
- return query.field[field].fuzzy_prefix_length;
- }
-
- query.field[field].fuzzy_prefix_length = fuzzLen;
- return this;
- },
-
- /**
- Sets the max number of term expansions for fuzzy queries.
- - @member ejs.FieldQuery - @param {Integer} max A positiveinteger
value.
- @returns {Object} returns this
so that calls can be chained.
- */
- fuzzyMaxExpansions: function (max) {
- if (max == null) {
- return query.field[field].fuzzy_max_expansions;
- }
-
- query.field[field].fuzzy_max_expansions = max;
- return this;
- },
-
- /**
- Sets fuzzy rewrite method.
- -
Valid values are:
- -constant_score_auto
- tries to pick the best constant-score rewrite
- method based on term and document counts from the queryscoring_boolean
- translates each term into boolean should and
- keeps the scores as computed by the queryconstant_score_boolean
- same as scoring_boolean, expect no scores
- are computed.constant_score_filter
- first creates a private Filter, by visiting
- each term in sequence and marking all docs for that termtop_terms_boost_N
- first translates each term into boolean should
- and scores are only computed as the boost using the top N
- scoring terms. Replace N
with an integer value.top_terms_N
- first translates each term into boolean should
- and keeps the scores as computed by the query. Only the top N
- scoring terms are used. Replace N
with an integer value.Default is constant_score_auto
.
This is an advanced option, use with care.
- - @member ejs.FieldQuery - @param {String} m The rewrite method as a string. - @returns {Object} returnsthis
so that calls can be chained.
- */
- fuzzyRewrite: function (m) {
- if (m == null) {
- return query.field[field].fuzzy_rewrite;
- }
-
- m = m.toLowerCase();
- if (m === 'constant_score_auto' || m === 'scoring_boolean' ||
- m === 'constant_score_boolean' || m === 'constant_score_filter' ||
- m.indexOf('top_terms_boost_') === 0 ||
- m.indexOf('top_terms_') === 0) {
-
- query.field[field].fuzzy_rewrite = m;
- }
-
- return this;
- },
-
- /**
- Sets rewrite method.
- -Valid values are:
- -constant_score_auto
- tries to pick the best constant-score rewrite
- method based on term and document counts from the queryscoring_boolean
- translates each term into boolean should and
- keeps the scores as computed by the queryconstant_score_boolean
- same as scoring_boolean, expect no scores
- are computed.
-
- constant_score_filter
- first creates a private Filter, by visiting
- each term in sequence and marking all docs for that termtop_terms_boost_N
- first translates each term into boolean should
- and scores are only computed as the boost using the top N
- scoring terms. Replace N
with an integer value.top_terms_N
- first translates each term into boolean should
- and keeps the scores as computed by the query. Only the top N
- scoring terms are used. Replace N
with an integer value.Default is constant_score_auto
.
this
so that calls can be chained.
- */
- rewrite: function (m) {
- if (m == null) {
- return query.field[field].rewrite;
- }
-
- m = m.toLowerCase();
- if (m === 'constant_score_auto' || m === 'scoring_boolean' ||
- m === 'constant_score_boolean' || m === 'constant_score_filter' ||
- m.indexOf('top_terms_boost_') === 0 ||
- m.indexOf('top_terms_') === 0) {
-
- query.field[field].rewrite = m;
- }
-
- return this;
- },
-
- /**
- Sets the suffix to automatically add to the field name when - performing a quoted search.
- - @member ejs.FieldQuery - @param {String} s The suffix as a string. - @returns {Object} returnsthis
so that calls can be chained.
- */
- quoteFieldSuffix: function (s) {
- if (s == null) {
- return query.field[field].quote_field_suffix;
- }
-
- query.field[field].quote_field_suffix = s;
- return this;
- },
-
- /**
- Sets the default slop for phrases. If zero, then exact phrase matches - are required.
- -Default: 0
.
integer
value.
- @returns {Object} returns this
so that calls can be chained.
- */
- phraseSlop: function (slop) {
- if (slop == null) {
- return query.field[field].phrase_slop;
- }
-
- query.field[field].phrase_slop = slop;
- return this;
- },
-
- /**
- Sets whether or not we should attempt to analyzed wilcard terms in the
- Query
.
By default, wildcard terms are not analyzed. Analysis of wildcard characters is not perfect.
- -Default: false
.
true/false
value.
- @returns {Object} returns this
so that calls can be chained.
- */
- analyzeWildcard: function (trueFalse) {
- if (trueFalse == null) {
- return query.field[field].analyze_wildcard;
- }
-
- query.field[field].analyze_wildcard = trueFalse;
- return this;
- },
-
- /**
- If the query string should be escaped or not.
- - @member ejs.FieldQuery - @param {Boolean} trueFalse Atrue/false
value.
- @returns {Object} returns this
so that calls can be chained.
- */
- escape: function (trueFalse) {
- if (trueFalse == null) {
- return query.field[field].escape;
- }
-
- query.field[field].escape = trueFalse;
- return this;
- },
-
- /**
- Sets a percent value controlling how many should
clauses in the
- resulting Query
should match.
integer
between 0 and 100.
- @returns {Object} returns this
so that calls can be chained.
- */
- minimumShouldMatch: function (minMatch) {
- if (minMatch == null) {
- return query.field[field].minimum_should_match;
- }
-
- query.field[field].minimum_should_match = minMatch;
- return this;
- },
-
- /**
- Sets the boost value of the Query
.
Default: 1.0
.
double
value.
- @returns {Object} returns this
so that calls can be chained.
- */
- boost: function (boost) {
- if (boost == null) {
- return query.field[field].boost;
- }
-
- query.field[field].boost = boost;
- return this;
- },
-
- });
- };
diff --git a/tests/query_test.js b/tests/query_test.js
index 3bc558a..f0b3729 100644
--- a/tests/query_test.js
+++ b/tests/query_test.js
@@ -28,13 +28,12 @@ exports.queries = {
done();
},
exists: function (test) {
- test.expect(39);
-
+ test.expect(35);
+
test.ok(ejs.CommonTermsQuery, 'CommonTermsQuery');
test.ok(ejs.RegexpQuery, 'RegexpQuery');
test.ok(ejs.GeoShapeQuery, 'GeoShapeQuery');
test.ok(ejs.IndicesQuery, 'IndicesQuery');
- test.ok(ejs.CustomFiltersScoreQuery, 'CustomFiltersScoreQuery');
test.ok(ejs.WildcardQuery, 'WildcardQuery');
test.ok(ejs.TopChildrenQuery, 'TopChildrenQuery');
test.ok(ejs.TermsQuery, 'TermsQuery');
@@ -47,15 +46,12 @@ exports.queries = {
test.ok(ejs.FuzzyQuery, 'FuzzyQuery');
test.ok(ejs.FuzzyLikeThisFieldQuery, 'FuzzyLikeThisFieldQuery');
test.ok(ejs.FuzzyLikeThisQuery, 'FuzzyLikeThisQuery');
- test.ok(ejs.CustomBoostFactorQuery, 'CustomBoostFactorQuery');
- test.ok(ejs.CustomScoreQuery, 'CustomScoreQuery');
test.ok(ejs.IdsQuery, 'IdsQuery');
test.ok(ejs.BoostingQuery, 'BoostingQuery');
test.ok(ejs.MatchQuery, 'MatchQuery');
test.ok(ejs.MultiMatchQuery, 'MultiMatchQuery');
test.ok(ejs.TermQuery, 'TermQuery');
test.ok(ejs.BoolQuery, 'BoolQuery');
- test.ok(ejs.FieldQuery, 'FieldQuery');
test.ok(ejs.DisMaxQuery, 'DisMaxQuery');
test.ok(ejs.QueryStringQuery, 'QueryStringQuery');
test.ok(ejs.FilteredQuery, 'FilteredQuery');
@@ -98,7 +94,7 @@ exports.queries = {
}
};
doTest();
-
+
commonQuery = ejs.CommonTermsQuery('field', 'qstr');
expected = {
common: {
@@ -108,7 +104,7 @@ exports.queries = {
}
};
doTest();
-
+
commonQuery.field('field2');
expected = {
common: {
@@ -118,11 +114,11 @@ exports.queries = {
}
};
doTest();
-
+
commonQuery.query('qstr2');
expected.common.field2.query = 'qstr2';
doTest();
-
+
commonQuery.boost(1.5);
expected.common.field2.boost = 1.5;
doTest();
@@ -130,11 +126,11 @@ exports.queries = {
commonQuery.disableCoord(true);
expected.common.field2.disable_coord = true;
doTest();
-
+
commonQuery.cutoffFrequency(0.65);
expected.common.field2.cutoff_frequency = 0.65;
doTest();
-
+
commonQuery.highFreqOperator('and');
expected.common.field2.high_freq_operator = 'and';
doTest();
@@ -156,7 +152,7 @@ exports.queries = {
commonQuery.lowFreqOperator('or');
expected.common.field2.low_freq_operator = 'or';
doTest();
-
+
commonQuery.analyzer('the analyzer');
expected.common.field2.analyzer = 'the analyzer';
doTest();
@@ -164,18 +160,18 @@ exports.queries = {
commonQuery.minimumShouldMatch(10);
expected.common.field2.minimum_should_match = {low_freq: 10};
doTest();
-
+
commonQuery.minimumShouldMatchLowFreq(5);
expected.common.field2.minimum_should_match.low_freq = 5;
doTest();
-
+
commonQuery.minimumShouldMatchHighFreq(10);
expected.common.field2.minimum_should_match.high_freq = 10;
doTest();
-
+
test.strictEqual(commonQuery._type(), 'query');
-
-
+
+
test.done();
},
RegexpQuery: function (test) {
@@ -198,11 +194,11 @@ exports.queries = {
test.ok(regexQuery, 'RegexpQuery exists');
test.ok(regexQuery.toJSON(), 'toJSON() works');
doTest();
-
+
regexQuery.value('regex2');
expected.regexp.f1.value = 'regex2';
doTest();
-
+
regexQuery.field('f2');
expected = {
regexp: {
@@ -212,48 +208,48 @@ exports.queries = {
}
};
doTest();
-
+
regexQuery.boost(1.2);
expected.regexp.f2.boost = 1.2;
doTest();
-
+
regexQuery.rewrite('constant_score_auto');
expected.regexp.f2.rewrite = 'constant_score_auto';
doTest();
-
+
regexQuery.rewrite('invalid');
doTest();
-
+
regexQuery.rewrite('scoring_boolean');
expected.regexp.f2.rewrite = 'scoring_boolean';
doTest();
-
+
regexQuery.rewrite('constant_score_boolean');
expected.regexp.f2.rewrite = 'constant_score_boolean';
doTest();
-
+
regexQuery.rewrite('constant_score_filter');
expected.regexp.f2.rewrite = 'constant_score_filter';
doTest();
-
+
regexQuery.rewrite('top_terms_boost_5');
expected.regexp.f2.rewrite = 'top_terms_boost_5';
doTest();
-
+
regexQuery.rewrite('top_terms_9');
expected.regexp.f2.rewrite = 'top_terms_9';
doTest();
-
+
regexQuery.flags('INTERSECTION|EMPTY');
expected.regexp.f2.flags = 'INTERSECTION|EMPTY';
doTest();
-
+
regexQuery.flagsValue(-1);
expected.regexp.f2.flags_value = -1;
doTest();
-
+
test.strictEqual(regexQuery._type(), 'query');
-
+
test.done();
},
@@ -262,7 +258,7 @@ exports.queries = {
var geoShapeQuery = ejs.GeoShapeQuery('f1'),
shape1 = ejs.Shape('envelope', [[-45.0, 45.0], [45.0, -45.0]]),
- shape2 = ejs.Shape('polygon', [[-180.0, 10.0], [20.0, 90.0],
+ shape2 = ejs.Shape('polygon', [[-180.0, 10.0], [20.0, 90.0],
[180.0, -5.0], [-30.0, -90.0]]),
iShape1 = ejs.IndexedShape('countries', 'New Zealand'),
iShape2 = ejs.IndexedShape('state', 'CA')
@@ -286,7 +282,7 @@ exports.queries = {
geoShapeQuery.shape(shape1);
expected.geo_shape.f1.shape = shape1.toJSON();
doTest();
-
+
geoShapeQuery.field('f2');
expected = {
geo_shape: {
@@ -296,53 +292,53 @@ exports.queries = {
}
};
doTest();
-
+
geoShapeQuery.shape(shape2);
expected.geo_shape.f2.shape = shape2.toJSON();
doTest();
-
+
geoShapeQuery.relation('intersects');
expected.geo_shape.f2.relation = 'intersects';
doTest();
-
+
geoShapeQuery.relation('INVALID');
doTest();
-
+
geoShapeQuery.relation('DisJoint');
expected.geo_shape.f2.relation = 'disjoint';
doTest();
-
+
geoShapeQuery.relation('WITHIN');
expected.geo_shape.f2.relation = 'within';
doTest();
-
+
geoShapeQuery.indexedShape(iShape1);
delete expected.geo_shape.f2.shape;
expected.geo_shape.f2.indexed_shape = iShape1.toJSON();
doTest();
-
+
geoShapeQuery.indexedShape(iShape2);
expected.geo_shape.f2.indexed_shape = iShape2.toJSON();
doTest();
-
+
geoShapeQuery.strategy('recursive');
expected.geo_shape.f2.strategy = 'recursive';
doTest();
-
+
geoShapeQuery.strategy('INVALID');
doTest();
-
+
geoShapeQuery.strategy('TERM');
expected.geo_shape.f2.strategy = 'term';
doTest();
-
+
geoShapeQuery.boost(1.5);
expected.geo_shape.f2.boost = 1.5;
doTest();
-
+
test.strictEqual(geoShapeQuery._type(), 'query');
-
-
+
+
test.done();
},
IndicesQuery: function (test) {
@@ -371,57 +367,57 @@ exports.queries = {
indicesQuery = ejs.IndicesQuery(termQuery, ['i2', 'i3']);
expected.indices.indices = ['i2', 'i3'];
doTest();
-
+
indicesQuery.indices('i4');
expected.indices.indices.push('i4');
doTest();
-
+
indicesQuery.indices(['i5']);
expected.indices.indices = ['i5'];
doTest();
-
+
indicesQuery.query(termQuery2);
expected.indices.query = termQuery2.toJSON();
doTest();
-
+
indicesQuery.noMatchQuery('invalid');
doTest();
-
+
indicesQuery.noMatchQuery('none');
expected.indices.no_match_query = 'none';
doTest();
-
+
indicesQuery.noMatchQuery('ALL');
expected.indices.no_match_query = 'all';
doTest();
-
+
indicesQuery.noMatchQuery(termQuery3);
expected.indices.no_match_query = termQuery3.toJSON();
doTest();
-
+
indicesQuery.boost(1.5);
expected.indices.boost = 1.5;
doTest();
-
+
indicesQuery.query(termQuery2);
expected.indices.query = termQuery2.toJSON();
doTest();
-
+
test.strictEqual(indicesQuery._type(), 'query');
-
+
test.throws(function () {
ejs.IndicesQuery('invalid', 'index1');
}, TypeError);
-
+
test.throws(function () {
ejs.IndicesQuery(termQuery2, 3);
}, TypeError);
-
+
test.throws(function () {
indicesQuery.query('invalid');
}, TypeError);
-
+
test.throws(function () {
indicesQuery.noMatchQuery(2);
}, TypeError);
@@ -432,137 +428,6 @@ exports.queries = {
test.done();
},
- CustomFiltersScoreQuery: function (test) {
- test.expect(24);
-
- var termQuery = ejs.TermQuery('t1', 'v1'),
- termQuery2 = ejs.TermQuery('t2', 'v2'),
- termFilter = ejs.TermFilter('tf1', 'fv1'),
- termFilter2 = ejs.TermFilter('tf2', 'fv2'),
- cfsQuery = ejs.CustomFiltersScoreQuery(termQuery, [
- {filter: termFilter, boost: 1.2},
- {filter: termFilter2, script: 's'}
- ]),
- expected,
- doTest = function () {
- test.deepEqual(cfsQuery.toJSON(), expected);
- };
-
- expected = {
- custom_filters_score: {
- query: termQuery.toJSON(),
- filters: [{
- filter: termFilter.toJSON(),
- boost: 1.2
- }, {
- filter: termFilter2.toJSON(),
- script: 's'
- }]
- }
- };
-
- test.ok(cfsQuery, 'CustomFiltersScoreQuery exists');
- test.ok(cfsQuery.toJSON(), 'toJSON() works');
- doTest();
-
- cfsQuery = ejs.CustomFiltersScoreQuery(termQuery, {filter: termFilter, boost: 1.2});
- expected = {
- custom_filters_score: {
- query: termQuery.toJSON(),
- filters: [{
- filter: termFilter.toJSON(),
- boost: 1.2
- }]
- }
- };
- doTest();
-
- cfsQuery.boost(1.5);
- expected.custom_filters_score.boost = 1.5;
- doTest();
-
- cfsQuery.query(termQuery2);
- expected.custom_filters_score.query = termQuery2.toJSON();
- doTest();
-
- // invalid filter because no boost or script, results in empty filters.
- cfsQuery.filters([{filter: termFilter, invalid: true}]);
- expected.custom_filters_score.filters = [];
- doTest();
-
- // overwrite existing
- cfsQuery.filters([{filter: termFilter, script: 's'}]);
- expected.custom_filters_score.filters = [{filter: termFilter.toJSON(), script: 's'}];
- doTest();
-
- cfsQuery.filters([{filter: termFilter, invalid: true}, {filter: termFilter2, boost: 2}]);
- expected.custom_filters_score.filters = [{filter: termFilter2.toJSON(), boost: 2}];
- doTest();
-
- // append
- cfsQuery.filters({filter: termFilter2, boost: 5.5});
- expected.custom_filters_score.filters.push({filter: termFilter2.toJSON(), boost: 5.5});
- doTest();
-
- cfsQuery.filters([{filter: termFilter, script: 's'}, {filter: termFilter2, boost: 2.2}]);
- expected.custom_filters_score.filters = [
- {filter: termFilter.toJSON(), script: 's'},
- {filter: termFilter2.toJSON(), boost: 2.2}
- ];
- doTest();
-
- cfsQuery.scoreMode('first');
- expected.custom_filters_score.score_mode = 'first';
- doTest();
-
- cfsQuery.scoreMode('INVALID');
- doTest();
-
- cfsQuery.scoreMode('MIN');
- expected.custom_filters_score.score_mode = 'min';
- doTest();
-
- cfsQuery.scoreMode('max');
- expected.custom_filters_score.score_mode = 'max';
- doTest();
-
- cfsQuery.scoreMode('TOTAL');
- expected.custom_filters_score.score_mode = 'total';
- doTest();
-
- cfsQuery.scoreMode('avg');
- expected.custom_filters_score.score_mode = 'avg';
- doTest();
-
- cfsQuery.scoreMode('Multiply');
- expected.custom_filters_score.score_mode = 'multiply';
- doTest();
-
- cfsQuery.params({param1: true, param2: false});
- expected.custom_filters_score.params = {param1: true, param2: false};
- doTest();
-
- cfsQuery.lang('mvel');
- expected.custom_filters_score.lang = 'mvel';
- doTest();
-
- cfsQuery.maxBoost(6.0);
- expected.custom_filters_score.max_boost = 6.0;
- doTest();
-
- test.strictEqual(cfsQuery._type(), 'query');
-
-
- test.throws(function () {
- ejs.CustomFiltersScoreQuery('invalid', {filter: termFilter, boost: 1.2});
- }, TypeError);
-
- test.throws(function () {
- cfsQuery.query('junk');
- }, TypeError);
-
- test.done();
- },
WildcardQuery: function (test) {
test.expect(14);
@@ -591,30 +456,30 @@ exports.queries = {
wildcardQuery.rewrite('constant_score_auto');
expected.wildcard.f1.rewrite = 'constant_score_auto';
doTest();
-
+
wildcardQuery.rewrite('invalid');
doTest();
-
+
wildcardQuery.rewrite('scoring_boolean');
expected.wildcard.f1.rewrite = 'scoring_boolean';
doTest();
-
+
wildcardQuery.rewrite('constant_score_boolean');
expected.wildcard.f1.rewrite = 'constant_score_boolean';
doTest();
-
+
wildcardQuery.rewrite('constant_score_filter');
expected.wildcard.f1.rewrite = 'constant_score_filter';
doTest();
-
+
wildcardQuery.rewrite('top_terms_boost_5');
expected.wildcard.f1.rewrite = 'top_terms_boost_5';
doTest();
-
+
wildcardQuery.rewrite('top_terms_9');
expected.wildcard.f1.rewrite = 'top_terms_9';
doTest();
-
+
wildcardQuery.field('f2');
expected = {
wildcard: {
@@ -626,13 +491,13 @@ exports.queries = {
}
};
doTest();
-
+
wildcardQuery.value('wild?card');
expected.wildcard.f2.value = 'wild?card';
doTest();
-
+
test.strictEqual(wildcardQuery._type(), 'query');
-
+
test.done();
},
@@ -657,76 +522,76 @@ exports.queries = {
test.ok(topChildren, 'TopChildrenQuery exists');
test.ok(topChildren.toJSON(), 'toJSON() works');
doTest();
-
+
topChildren.query(termQuery2);
expected.top_children.query = termQuery2.toJSON();
doTest();
-
+
topChildren.type('t2');
expected.top_children.type = 't2';
doTest();
-
+
topChildren.boost(1.2);
expected.top_children.boost = 1.2;
doTest();
-
+
topChildren.score('silently fail');
doTest();
-
+
topChildren.score('max');
expected.top_children.score = 'max';
doTest();
-
+
topChildren.score('SUM');
expected.top_children.score = 'sum';
doTest();
-
+
topChildren.score('avg');
expected.top_children.score = 'avg';
doTest();
-
+
topChildren.score('total');
expected.top_children.score = 'total';
doTest();
-
+
topChildren.scoreMode('silently fail');
doTest();
-
+
topChildren.scoreMode('max');
expected.top_children.score_mode = 'max';
doTest();
-
+
topChildren.scoreMode('SUM');
expected.top_children.score_mode = 'sum';
doTest();
-
+
topChildren.scoreMode('avg');
expected.top_children.score_mode = 'avg';
doTest();
-
+
topChildren.scoreMode('total');
expected.top_children.score_mode = 'total';
doTest();
-
+
topChildren.factor(7);
expected.top_children.factor = 7;
doTest();
-
+
topChildren.incrementalFactor(3);
expected.top_children.incremental_factor = 3;
doTest();
-
+
test.strictEqual(topChildren._type(), 'query');
-
+
test.throws(function () {
ejs.TopChildrenQuery('invalid', 'type');
}, TypeError);
-
+
test.throws(function () {
topChildren.query('invalid');
}, TypeError);
-
+
test.done();
},
TermsQuery: function (test) {
@@ -755,7 +620,7 @@ exports.queries = {
}
};
doTest();
-
+
termsQuery.boost(1.5);
expected.terms.boost = 1.5;
doTest();
@@ -763,7 +628,7 @@ exports.queries = {
termsQuery.minimumShouldMatch(2);
expected.terms.minimum_should_match = 2;
doTest();
-
+
termsQuery.field('f2');
expected = {
terms: {
@@ -773,30 +638,30 @@ exports.queries = {
}
};
doTest();
-
+
termsQuery.terms('t4');
expected.terms.f2.push('t4');
doTest();
-
+
termsQuery.terms(['t5', 't6']);
expected.terms.f2 = ['t5', 't6'];
doTest();
-
+
termsQuery.disableCoord(true);
expected.terms.disable_coord = true;
doTest();
-
+
test.strictEqual(termsQuery._type(), 'query');
-
+
test.throws(function () {
ejs.TermsQuery('f1', 3);
}, TypeError);
-
+
test.throws(function () {
termsQuery.terms(2);
}, TypeError);
-
+
test.done();
},
RangeQuery: function (test) {
@@ -817,11 +682,11 @@ exports.queries = {
test.ok(rangeQuery, 'RangeQuery exists');
test.ok(rangeQuery.toJSON(), 'toJSON() works');
doTest();
-
+
rangeQuery.from(1);
expected.range.f1.from = 1;
doTest();
-
+
rangeQuery.field('f2');
expected = {
range: {
@@ -831,41 +696,41 @@ exports.queries = {
}
};
doTest();
-
+
rangeQuery.to(3);
expected.range.f2.to = 3;
doTest();
-
+
rangeQuery.includeLower(false);
expected.range.f2.include_lower = false;
doTest();
-
+
rangeQuery.includeUpper(true);
expected.range.f2.include_upper = true;
doTest();
-
+
rangeQuery.gt(4);
expected.range.f2.gt = 4;
doTest();
-
+
rangeQuery.gte(4);
expected.range.f2.gte = 4;
doTest();
-
+
rangeQuery.lt(6);
expected.range.f2.lt = 6;
doTest();
-
+
rangeQuery.lte(6);
expected.range.f2.lte = 6;
doTest();
-
+
rangeQuery.boost(1.2);
expected.range.f2.boost = 1.2;
doTest();
-
+
test.strictEqual(rangeQuery._type(), 'query');
-
+
test.done();
},
@@ -889,11 +754,11 @@ exports.queries = {
test.ok(prefixQuery, 'PrefixQuery exists');
test.ok(prefixQuery.toJSON(), 'toJSON() works');
doTest();
-
+
prefixQuery.value('prefix2');
expected.prefix.f1.value = 'prefix2';
doTest();
-
+
prefixQuery.field('f2');
expected = {
prefix: {
@@ -903,40 +768,40 @@ exports.queries = {
}
};
doTest();
-
+
prefixQuery.boost(1.2);
expected.prefix.f2.boost = 1.2;
doTest();
-
+
prefixQuery.rewrite('constant_score_auto');
expected.prefix.f2.rewrite = 'constant_score_auto';
doTest();
-
+
prefixQuery.rewrite('invalid');
doTest();
-
+
prefixQuery.rewrite('scoring_boolean');
expected.prefix.f2.rewrite = 'scoring_boolean';
doTest();
-
+
prefixQuery.rewrite('constant_score_boolean');
expected.prefix.f2.rewrite = 'constant_score_boolean';
doTest();
-
+
prefixQuery.rewrite('constant_score_filter');
expected.prefix.f2.rewrite = 'constant_score_filter';
doTest();
-
+
prefixQuery.rewrite('top_terms_boost_5');
expected.prefix.f2.rewrite = 'top_terms_boost_5';
doTest();
-
+
prefixQuery.rewrite('top_terms_9');
expected.prefix.f2.rewrite = 'top_terms_9';
doTest();
-
+
test.strictEqual(prefixQuery._type(), 'query');
-
+
test.done();
},
@@ -960,11 +825,11 @@ exports.queries = {
test.ok(mltQuery, 'MoreLikeThisFieldQuery exists');
test.ok(mltQuery.toJSON(), 'toJSON() works');
doTest();
-
+
mltQuery.likeText('like text 2');
expected.mlt_field.f1.like_text = 'like text 2';
doTest();
-
+
mltQuery.field('f2');
expected = {
mlt_field: {
@@ -974,57 +839,57 @@ exports.queries = {
}
};
doTest();
-
+
mltQuery.percentTermsToMatch(0.7);
expected.mlt_field.f2.percent_terms_to_match = 0.7;
doTest();
-
+
mltQuery.minTermFreq(3);
expected.mlt_field.f2.min_term_freq = 3;
doTest();
-
+
mltQuery.maxQueryTerms(6);
expected.mlt_field.f2.max_query_terms = 6;
doTest();
-
+
mltQuery.stopWords(['s1', 's2']);
expected.mlt_field.f2.stop_words = ['s1', 's2'];
doTest();
-
+
mltQuery.minDocFreq(2);
expected.mlt_field.f2.min_doc_freq = 2;
doTest();
-
+
mltQuery.maxDocFreq(4);
expected.mlt_field.f2.max_doc_freq = 4;
doTest();
-
+
mltQuery.minWordLen(3);
expected.mlt_field.f2.min_word_len = 3;
doTest();
-
+
mltQuery.maxWordLen(6);
expected.mlt_field.f2.max_word_len = 6;
doTest();
-
+
mltQuery.boostTerms(1.3);
expected.mlt_field.f2.boost_terms = 1.3;
doTest();
-
+
mltQuery.failOnUnsupportedField(false);
expected.mlt_field.f2.fail_on_unsupported_field = false;
doTest();
-
+
mltQuery.analyzer('some analyzer');
expected.mlt_field.f2.analyzer = 'some analyzer';
doTest();
-
+
mltQuery.boost(1.2);
expected.mlt_field.f2.boost = 1.2;
doTest();
-
+
test.strictEqual(mltQuery._type(), 'query');
-
+
test.done();
},
@@ -1047,7 +912,7 @@ exports.queries = {
test.ok(mltQuery, 'MoreLikeThisQuery exists');
test.ok(mltQuery.toJSON(), 'toJSON() works');
doTest();
-
+
mltQuery = ejs.MoreLikeThisQuery('f', 'like text');
expected = {
mlt: {
@@ -1056,78 +921,78 @@ exports.queries = {
}
};
doTest();
-
+
mltQuery.fields('f2');
expected.mlt.fields.push('f2');
doTest();
-
+
mltQuery.fields(['f3', 'f4']);
expected.mlt.fields = ['f3', 'f4'];
doTest();
-
+
mltQuery.likeText('like text 2');
expected.mlt.like_text = 'like text 2';
doTest();
-
+
mltQuery.percentTermsToMatch(0.7);
expected.mlt.percent_terms_to_match = 0.7;
doTest();
-
+
mltQuery.minTermFreq(3);
expected.mlt.min_term_freq = 3;
doTest();
-
+
mltQuery.maxQueryTerms(6);
expected.mlt.max_query_terms = 6;
doTest();
-
+
mltQuery.stopWords(['s1', 's2']);
expected.mlt.stop_words = ['s1', 's2'];
doTest();
-
+
mltQuery.minDocFreq(2);
expected.mlt.min_doc_freq = 2;
doTest();
-
+
mltQuery.maxDocFreq(4);
expected.mlt.max_doc_freq = 4;
doTest();
-
+
mltQuery.minWordLen(3);
expected.mlt.min_word_len = 3;
doTest();
-
+
mltQuery.maxWordLen(6);
expected.mlt.max_word_len = 6;
doTest();
-
+
mltQuery.boostTerms(1.3);
expected.mlt.boost_terms = 1.3;
doTest();
-
+
mltQuery.failOnUnsupportedField(false);
expected.mlt.fail_on_unsupported_field = false;
doTest();
-
+
mltQuery.analyzer('some analyzer');
expected.mlt.analyzer = 'some analyzer';
doTest();
-
+
mltQuery.boost(1.2);
expected.mlt.boost = 1.2;
doTest();
-
+
test.strictEqual(mltQuery._type(), 'query');
-
+
test.throws(function () {
ejs.MoreLikeThisQuery(9, 'like');
}, TypeError);
-
+
test.throws(function () {
mltQuery.fields(3);
}, TypeError);
-
+
test.done();
},
HasParentQuery: function (test) {
@@ -1151,52 +1016,52 @@ exports.queries = {
test.ok(hasParentQuery, 'HasParentQuery exists');
test.ok(hasParentQuery.toJSON(), 'toJSON() works');
doTest();
-
+
hasParentQuery.query(termQuery2);
expected.has_parent.query = termQuery2.toJSON();
doTest();
-
+
hasParentQuery.parentType('t2');
expected.has_parent.parent_type = 't2';
doTest();
-
+
hasParentQuery.scoreType('none');
expected.has_parent.score_type = 'none';
doTest();
-
+
hasParentQuery.scoreType('INVALID');
doTest();
-
+
hasParentQuery.scoreType('SCORE');
expected.has_parent.score_type = 'score';
doTest();
-
+
hasParentQuery.scoreMode('none');
expected.has_parent.score_mode = 'none';
doTest();
-
+
hasParentQuery.scoreMode('INVALID');
doTest();
-
+
hasParentQuery.scoreMode('SCORE');
expected.has_parent.score_mode = 'score';
doTest();
-
+
hasParentQuery.boost(1.2);
expected.has_parent.boost = 1.2;
doTest();
-
+
test.strictEqual(hasParentQuery._type(), 'query');
-
+
test.throws(function () {
ejs.HasParentQuery('invalid', 'type');
}, TypeError);
-
+
test.throws(function () {
hasParentQuery.query('invalid');
}, TypeError);
-
+
test.done();
},
HasChildQuery: function (test) {
@@ -1220,72 +1085,72 @@ exports.queries = {
test.ok(hasChildQuery, 'HasChildQuery exists');
test.ok(hasChildQuery.toJSON(), 'toJSON() works');
doTest();
-
+
hasChildQuery.query(termQuery2);
expected.has_child.query = termQuery2.toJSON();
doTest();
-
+
hasChildQuery.type('t2');
expected.has_child.type = 't2';
doTest();
-
+
hasChildQuery.scoreType('none');
expected.has_child.score_type = 'none';
doTest();
-
+
hasChildQuery.scoreType('INVALID');
doTest();
-
+
hasChildQuery.scoreType('MAX');
expected.has_child.score_type = 'max';
doTest();
-
+
hasChildQuery.scoreType('Avg');
expected.has_child.score_type = 'avg';
doTest();
-
+
hasChildQuery.scoreType('sum');
expected.has_child.score_type = 'sum';
doTest();
-
+
hasChildQuery.scoreMode('none');
expected.has_child.score_mode = 'none';
doTest();
-
+
hasChildQuery.scoreMode('INVALID');
doTest();
-
+
hasChildQuery.scoreMode('MAX');
expected.has_child.score_mode = 'max';
doTest();
-
+
hasChildQuery.scoreMode('Avg');
expected.has_child.score_mode = 'avg';
doTest();
-
+
hasChildQuery.scoreMode('sum');
expected.has_child.score_mode = 'sum';
doTest();
-
+
hasChildQuery.shortCircuitCutoff(8192);
expected.has_child.short_circuit_cutoff = 8192;
doTest();
-
+
hasChildQuery.boost(1.2);
expected.has_child.boost = 1.2;
doTest();
-
+
test.strictEqual(hasChildQuery._type(), 'query');
-
+
test.throws(function () {
ejs.HasChildQuery('invalid', 'type');
}, TypeError);
-
+
test.throws(function () {
hasChildQuery.query('invalid');
}, TypeError);
-
+
test.done();
},
FuzzyQuery: function (test) {
@@ -1308,11 +1173,11 @@ exports.queries = {
test.ok(fuzzyQuery, 'FuzzyQuery exists');
test.ok(fuzzyQuery.toJSON(), 'toJSON() works');
doTest();
-
+
fuzzyQuery.value('fuzz2');
expected.fuzzy.f1.value = 'fuzz2';
doTest();
-
+
fuzzyQuery.field('f2');
expected = {
fuzzy: {
@@ -1322,56 +1187,56 @@ exports.queries = {
}
};
doTest();
-
+
fuzzyQuery.transpositions(false);
expected.fuzzy.f2.transpositions = false;
doTest();
-
+
fuzzyQuery.maxExpansions(10);
expected.fuzzy.f2.max_expansions = 10;
doTest();
-
+
fuzzyQuery.minSimilarity(0.6);
expected.fuzzy.f2.min_similarity = 0.6;
doTest();
-
+
fuzzyQuery.prefixLength(4);
expected.fuzzy.f2.prefix_length = 4;
doTest();
-
+
fuzzyQuery.rewrite('constant_score_auto');
expected.fuzzy.f2.rewrite = 'constant_score_auto';
doTest();
-
+
fuzzyQuery.rewrite('invalid');
doTest();
-
+
fuzzyQuery.rewrite('scoring_boolean');
expected.fuzzy.f2.rewrite = 'scoring_boolean';
doTest();
-
+
fuzzyQuery.rewrite('constant_score_boolean');
expected.fuzzy.f2.rewrite = 'constant_score_boolean';
doTest();
-
+
fuzzyQuery.rewrite('constant_score_filter');
expected.fuzzy.f2.rewrite = 'constant_score_filter';
doTest();
-
+
fuzzyQuery.rewrite('top_terms_boost_5');
expected.fuzzy.f2.rewrite = 'top_terms_boost_5';
doTest();
-
+
fuzzyQuery.rewrite('top_terms_9');
expected.fuzzy.f2.rewrite = 'top_terms_9';
doTest();
-
+
fuzzyQuery.boost(1.2);
expected.fuzzy.f2.boost = 1.2;
doTest();
-
+
test.strictEqual(fuzzyQuery._type(), 'query');
-
+
test.done();
},
@@ -1395,11 +1260,11 @@ exports.queries = {
test.ok(fltQuery, 'FuzzyLikeThisFieldQuery exists');
test.ok(fltQuery.toJSON(), 'toJSON() works');
doTest();
-
+
fltQuery.likeText('like text 2');
expected.flt_field.f1.like_text = 'like text 2';
doTest();
-
+
fltQuery.field('f2');
expected = {
flt_field: {
@@ -1409,37 +1274,37 @@ exports.queries = {
}
};
doTest();
-
+
fltQuery.ignoreTf(false);
expected.flt_field.f2.ignore_tf = false;
doTest();
-
+
fltQuery.maxQueryTerms(10);
expected.flt_field.f2.max_query_terms = 10;
doTest();
-
+
fltQuery.minSimilarity(0.6);
expected.flt_field.f2.min_similarity = 0.6;
doTest();
-
+
fltQuery.prefixLength(4);
expected.flt_field.f2.prefix_length = 4;
doTest();
-
+
fltQuery.analyzer('some analyzer');
expected.flt_field.f2.analyzer = 'some analyzer';
doTest();
-
+
fltQuery.failOnUnsupportedField(false);
expected.flt_field.f2.fail_on_unsupported_field = false;
doTest();
-
+
fltQuery.boost(1.2);
expected.flt_field.f2.boost = 1.2;
doTest();
-
+
test.strictEqual(fltQuery._type(), 'query');
-
+
test.done();
},
@@ -1461,182 +1326,58 @@ exports.queries = {
test.ok(fltQuery, 'FuzzyLikeThisQuery exists');
test.ok(fltQuery.toJSON(), 'toJSON() works');
doTest();
-
+
fltQuery.fields('f1');
expected.flt.fields = ['f1'];
doTest();
-
+
fltQuery.fields('f2');
expected.flt.fields.push('f2');
doTest();
-
+
fltQuery.fields(['f3', 'f4']);
expected.flt.fields = ['f3', 'f4'];
doTest();
-
+
fltQuery.likeText('like text 2');
expected.flt.like_text = 'like text 2';
doTest();
-
+
fltQuery.ignoreTf(false);
expected.flt.ignore_tf = false;
doTest();
-
+
fltQuery.maxQueryTerms(10);
expected.flt.max_query_terms = 10;
doTest();
-
+
fltQuery.minSimilarity(0.6);
expected.flt.min_similarity = 0.6;
doTest();
-
+
fltQuery.prefixLength(4);
expected.flt.prefix_length = 4;
doTest();
-
+
fltQuery.analyzer('some analyzer');
expected.flt.analyzer = 'some analyzer';
doTest();
-
+
fltQuery.failOnUnsupportedField(false);
expected.flt.fail_on_unsupported_field = false;
doTest();
-
+
fltQuery.boost(1.2);
expected.flt.boost = 1.2;
doTest();
-
- test.strictEqual(fltQuery._type(), 'query');
-
-
- test.throws(function () {
- fltQuery.fields(2);
- }, TypeError);
-
- test.done();
- },
- CustomBoostFactorQuery: function (test) {
- test.expect(9);
-
- var termQuery = ejs.TermQuery('t1', 'v1'),
- termQuery2 = ejs.TermQuery('t2', 'v2'),
- cbfQuery = ejs.CustomBoostFactorQuery(termQuery),
- expected,
- doTest = function () {
- test.deepEqual(cbfQuery.toJSON(), expected);
- };
-
- expected = {
- custom_boost_factor: {
- query: termQuery.toJSON()
- }
- };
- test.ok(cbfQuery, 'CustomBoostFactorQuery exists');
- test.ok(cbfQuery.toJSON(), 'toJSON() works');
- doTest();
-
- cbfQuery.query(termQuery2);
- expected.custom_boost_factor.query = termQuery2.toJSON();
- doTest();
-
- cbfQuery.boostFactor(5.1);
- expected.custom_boost_factor.boost_factor = 5.1;
- doTest();
-
- cbfQuery.boost(1.2);
- expected.custom_boost_factor.boost = 1.2;
- doTest();
-
- test.strictEqual(cbfQuery._type(), 'query');
-
-
- test.throws(function () {
- ejs.CustomBoostFactorQuery('invalid');
- }, TypeError);
-
- test.throws(function () {
- cbfQuery.query('invalid');
- }, TypeError);
-
- test.done();
- },
- CustomScoreQuery: function (test) {
- test.expect(15);
-
- var termQuery = ejs.TermQuery('t1', 'v1'),
- termQuery2 = ejs.TermQuery('t2', 'v2'),
- termFilter = ejs.TermFilter('tf1', 'vf1'),
- termFilter2 = ejs.TermFilter('tf2', 'vf2'),
- customScoreQuery = ejs.CustomScoreQuery(termQuery, 's1'),
- expected,
- doTest = function () {
- test.deepEqual(customScoreQuery.toJSON(), expected);
- };
-
- expected = {
- custom_score: {
- script: 's1',
- query: termQuery.toJSON()
- }
- };
-
- test.ok(customScoreQuery, 'CustomScoreQuery exists');
- test.ok(customScoreQuery.toJSON(), 'toJSON() works');
- doTest();
-
- customScoreQuery = ejs.CustomScoreQuery(termFilter, 's1');
- expected = {
- custom_score: {
- script: 's1',
- filter: termFilter.toJSON()
- }
- };
- doTest();
-
- customScoreQuery.query(termQuery2);
- expected.custom_score.query = termQuery2.toJSON();
- doTest();
-
- customScoreQuery.filter(termFilter2);
- expected.custom_score.filter = termFilter2.toJSON();
- doTest();
-
- customScoreQuery.script('s2');
- expected.custom_score.script = 's2';
- doTest();
-
- customScoreQuery.lang('native');
- expected.custom_score.lang = 'native';
- doTest();
-
- customScoreQuery.boost(1.2);
- expected.custom_score.boost = 1.2;
- doTest();
-
- customScoreQuery.params({p1: 'v1', p2: 'v2'});
- expected.custom_score.params = {p1: 'v1', p2: 'v2'};
- doTest();
-
- customScoreQuery.params({p3: 'v3'});
- expected.custom_score.params = {p3: 'v3'};
- doTest();
-
- test.strictEqual(customScoreQuery._type(), 'query');
-
+ test.strictEqual(fltQuery._type(), 'query');
+
test.throws(function () {
- ejs.CustomScoreQuery('invalid', 's');
- }, TypeError);
-
- test.throws(function () {
- customScoreQuery.query('invalid');
- }, TypeError);
-
- test.throws(function () {
- customScoreQuery.filter('invalid');
+ fltQuery.fields(2);
}, TypeError);
-
+
test.done();
},
IdsQuery: function (test) {
@@ -1657,50 +1398,50 @@ exports.queries = {
test.ok(idsQuery, 'IdsQuery exists');
test.ok(idsQuery.toJSON(), 'toJSON() works');
doTest();
-
+
idsQuery = ejs.IdsQuery(['id2', 'id3']);
expected.ids.values = ['id2', 'id3'];
doTest();
-
+
idsQuery.values('id4');
expected.ids.values.push('id4');
doTest();
-
+
idsQuery.values(['id5', 'id6']);
expected.ids.values = ['id5', 'id6'];
doTest();
-
+
idsQuery.type('type1');
expected.ids.type = ['type1'];
doTest();
-
+
idsQuery.type('type2');
expected.ids.type.push('type2');
doTest();
-
+
idsQuery.type(['type3', 'type4']);
expected.ids.type = ['type3', 'type4'];
doTest();
-
+
idsQuery.boost(0.5);
expected.ids.boost = 0.5;
doTest();
-
+
test.strictEqual(idsQuery._type(), 'query');
-
+
test.throws(function () {
ejs.IdsQuery(2);
}, TypeError);
-
+
test.throws(function () {
idsQuery.values(5);
}, TypeError);
-
+
test.throws(function () {
idsQuery.type(9);
}, TypeError);
-
+
test.done();
},
BoostingQuery: function (test) {
@@ -1729,38 +1470,38 @@ exports.queries = {
boostingQuery.positive(termQuery2);
expected.boosting.positive = termQuery2.toJSON();
doTest();
-
+
boostingQuery.negative(termQuery1);
expected.boosting.negative = termQuery1.toJSON();
doTest();
-
+
boostingQuery.negativeBoost(0.6);
expected.boosting.negative_boost = 0.6;
doTest();
-
+
boostingQuery.boost(3);
expected.boosting.boost = 3;
doTest();
-
+
test.strictEqual(boostingQuery._type(), 'query');
-
+
test.throws(function () {
ejs.BoostingQuery('invalid', termQuery1, 0.2);
}, TypeError);
-
+
test.throws(function () {
ejs.BoostingQuery(termQuery1, 'invalid', 0.2);
}, TypeError);
-
+
test.throws(function () {
boostingQuery.positive('invalid');
}, TypeError);
-
+
test.throws(function () {
boostingQuery.negative('invalid');
}, TypeError);
-
+
test.done();
},
MatchQuery: function (test) {
@@ -1810,7 +1551,7 @@ exports.queries = {
matchQuery.cutoffFrequency(0.6);
expected.match.t1.cutoff_frequency = 0.6;
doTest();
-
+
matchQuery.fuzziness(0.5);
expected.match.t1.fuzziness = 0.5;
doTest();
@@ -1845,82 +1586,82 @@ exports.queries = {
matchQuery.minimumShouldMatch(10);
expected.match.t1.minimum_should_match = 10;
doTest();
-
+
matchQuery.fuzzyRewrite('constant_score_auto');
expected.match.t1.fuzzy_rewrite = 'constant_score_auto';
doTest();
-
+
matchQuery.fuzzyRewrite('invalid');
doTest();
-
+
matchQuery.fuzzyRewrite('scoring_boolean');
expected.match.t1.fuzzy_rewrite = 'scoring_boolean';
doTest();
-
+
matchQuery.fuzzyRewrite('constant_score_boolean');
expected.match.t1.fuzzy_rewrite = 'constant_score_boolean';
doTest();
-
+
matchQuery.fuzzyRewrite('constant_score_filter');
expected.match.t1.fuzzy_rewrite = 'constant_score_filter';
doTest();
-
+
matchQuery.fuzzyRewrite('top_terms_boost_5');
expected.match.t1.fuzzy_rewrite = 'top_terms_boost_5';
doTest();
-
+
matchQuery.fuzzyRewrite('top_terms_9');
expected.match.t1.fuzzy_rewrite = 'top_terms_9';
doTest();
-
+
matchQuery.rewrite('constant_score_auto');
expected.match.t1.rewrite = 'constant_score_auto';
doTest();
-
+
matchQuery.rewrite('invalid');
doTest();
-
+
matchQuery.rewrite('scoring_boolean');
expected.match.t1.rewrite = 'scoring_boolean';
doTest();
-
+
matchQuery.rewrite('constant_score_boolean');
expected.match.t1.rewrite = 'constant_score_boolean';
doTest();
-
+
matchQuery.rewrite('constant_score_filter');
expected.match.t1.rewrite = 'constant_score_filter';
doTest();
-
+
matchQuery.rewrite('top_terms_boost_5');
expected.match.t1.rewrite = 'top_terms_boost_5';
doTest();
-
+
matchQuery.rewrite('top_terms_9');
expected.match.t1.rewrite = 'top_terms_9';
doTest();
-
+
matchQuery.fuzzyTranspositions(true);
expected.match.t1.fuzzy_transpositions = true;
doTest();
-
+
matchQuery.lenient(true);
expected.match.t1.lenient = true;
doTest();
-
+
matchQuery.zeroTermsQuery('all');
expected.match.t1.zero_terms_query = 'all';
doTest();
-
+
matchQuery.zeroTermsQuery('invalid');
doTest();
-
+
matchQuery.zeroTermsQuery('NONE');
expected.match.t1.zero_terms_query = 'none';
doTest();
-
+
test.strictEqual(matchQuery._type(), 'query');
-
+
test.done();
},
@@ -1943,7 +1684,7 @@ exports.queries = {
mmQuery = ejs.MultiMatchQuery(['t1', 't2'], 'v1');
expected.multi_match.fields = ['t1', 't2'];
doTest();
-
+
test.ok(mmQuery, 'MultiMatchQuery exists');
test.ok(mmQuery.toJSON(), 'toJSON() works');
doTest();
@@ -1959,19 +1700,19 @@ exports.queries = {
mmQuery.fields(['f3', 'f4']);
expected.multi_match.fields = ['f3', 'f4'];
doTest();
-
+
mmQuery.fields('f5');
expected.multi_match.fields.push('f5');
doTest();
-
+
mmQuery.useDisMax(true);
expected.multi_match.use_dis_max = true;
doTest();
-
+
mmQuery.tieBreaker(0.6);
expected.multi_match.tie_breaker = 0.6;
doTest();
-
+
mmQuery.type('boolean');
expected.multi_match.type = 'boolean';
doTest();
@@ -1990,7 +1731,7 @@ exports.queries = {
mmQuery.cutoffFrequency(0.6);
expected.multi_match.cutoff_frequency = 0.6;
doTest();
-
+
mmQuery.fuzziness(0.5);
expected.multi_match.fuzziness = 0.5;
doTest();
@@ -2025,87 +1766,87 @@ exports.queries = {
mmQuery.minimumShouldMatch(10);
expected.multi_match.minimum_should_match = 10;
doTest();
-
+
mmQuery.fuzzyRewrite('constant_score_auto');
expected.multi_match.fuzzy_rewrite = 'constant_score_auto';
doTest();
-
+
mmQuery.fuzzyRewrite('invalid');
doTest();
-
+
mmQuery.fuzzyRewrite('scoring_boolean');
expected.multi_match.fuzzy_rewrite = 'scoring_boolean';
doTest();
-
+
mmQuery.fuzzyRewrite('constant_score_boolean');
expected.multi_match.fuzzy_rewrite = 'constant_score_boolean';
doTest();
-
+
mmQuery.fuzzyRewrite('constant_score_filter');
expected.multi_match.fuzzy_rewrite = 'constant_score_filter';
doTest();
-
+
mmQuery.fuzzyRewrite('top_terms_boost_5');
expected.multi_match.fuzzy_rewrite = 'top_terms_boost_5';
doTest();
-
+
mmQuery.fuzzyRewrite('top_terms_9');
expected.multi_match.fuzzy_rewrite = 'top_terms_9';
doTest();
-
+
mmQuery.rewrite('constant_score_auto');
expected.multi_match.rewrite = 'constant_score_auto';
doTest();
-
+
mmQuery.rewrite('invalid');
doTest();
-
+
mmQuery.rewrite('scoring_boolean');
expected.multi_match.rewrite = 'scoring_boolean';
doTest();
-
+
mmQuery.rewrite('constant_score_boolean');
expected.multi_match.rewrite = 'constant_score_boolean';
doTest();
-
+
mmQuery.rewrite('constant_score_filter');
expected.multi_match.rewrite = 'constant_score_filter';
doTest();
-
+
mmQuery.rewrite('top_terms_boost_5');
expected.multi_match.rewrite = 'top_terms_boost_5';
doTest();
-
+
mmQuery.rewrite('top_terms_9');
expected.multi_match.rewrite = 'top_terms_9';
doTest();
-
+
mmQuery.lenient(true);
expected.multi_match.lenient = true;
doTest();
-
+
mmQuery.zeroTermsQuery('all');
expected.multi_match.zero_terms_query = 'all';
doTest();
-
+
mmQuery.zeroTermsQuery('invalid');
doTest();
-
+
mmQuery.zeroTermsQuery('NONE');
expected.multi_match.zero_terms_query = 'none';
doTest();
-
+
test.strictEqual(mmQuery._type(), 'query');
-
+
test.throws(function () {
ejs.MultiMatchQuery(3, 'v');
}, TypeError);
-
+
test.throws(function () {
mmQuery.fields(2);
}, TypeError);
-
+
test.done();
},
TermQuery: function (test) {
@@ -2143,13 +1884,13 @@ exports.queries = {
}
};
doTest();
-
+
termQuery.term('t2');
expected.term.f2.term = 't2';
doTest();
-
+
test.strictEqual(termQuery._type(), 'query');
-
+
test.done();
},
@@ -2181,7 +1922,7 @@ exports.queries = {
boolQuery.must([termQuery2, termQuery3]);
expected.bool.must = [termQuery2.toJSON(), termQuery3.toJSON()];
doTest();
-
+
boolQuery.mustNot(termQuery2);
expected.bool.must_not = [termQuery2.toJSON()];
doTest();
@@ -2189,7 +1930,7 @@ exports.queries = {
boolQuery.mustNot([termQuery3, termQuery4]);
expected.bool.must_not = [termQuery3.toJSON(), termQuery4.toJSON()];
doTest();
-
+
boolQuery.should(termQuery3);
expected.bool.should = [termQuery3.toJSON()];
doTest();
@@ -2201,7 +1942,7 @@ exports.queries = {
boolQuery.should([termQuery1, termQuery3]);
expected.bool.should = [termQuery1.toJSON(), termQuery3.toJSON()];
doTest();
-
+
boolQuery.boost(1.5);
expected.bool.boost = 1.5;
doTest();
@@ -2209,7 +1950,7 @@ exports.queries = {
boolQuery.adjustPureNegative(false);
expected.bool.adjust_pure_negative = false;
doTest();
-
+
boolQuery.disableCoord(false);
expected.bool.disable_coord = false;
doTest();
@@ -2219,196 +1960,31 @@ exports.queries = {
doTest();
test.strictEqual(boolQuery._type(), 'query');
-
-
+
+
test.throws(function () {
boolQuery.must('junk');
}, TypeError);
-
+
test.throws(function () {
boolQuery.must([termQuery1, 'junk']);
}, TypeError);
-
+
test.throws(function () {
boolQuery.mustNot('junk');
}, TypeError);
-
+
test.throws(function () {
boolQuery.mustNot([termQuery1, 'junk']);
}, TypeError);
-
+
test.throws(function () {
boolQuery.should('junk');
}, TypeError);
-
+
test.throws(function () {
boolQuery.should([termQuery1, 'junk']);
}, TypeError);
-
- test.done();
- },
- FieldQuery: function (test) {
- test.expect(38);
-
- var fieldQuery = ejs.FieldQuery('f', 'v1'),
- expected,
- doTest = function () {
- test.deepEqual(fieldQuery.toJSON(), expected);
- };
-
- expected = {
- field: {
- f: {
- query: 'v1'
- }
- }
- };
-
- test.ok(fieldQuery, 'FieldQuery exists');
- test.ok(fieldQuery.toJSON(), 'toJSON() works');
- doTest();
-
- fieldQuery.field('f1');
- expected = {
- field: {
- f1: {
- query: 'v1'
- }
- }
- };
- doTest();
-
- fieldQuery.query('v2');
- expected.field.f1.query = 'v2';
- doTest();
-
- fieldQuery.defaultOperator('and');
- expected.field.f1.default_operator = 'AND';
- doTest();
-
- fieldQuery.defaultOperator('or');
- expected.field.f1.default_operator = 'OR';
- doTest();
-
- fieldQuery.defaultOperator('invalid');
- doTest();
-
- fieldQuery.analyzer('someAnalyzer');
- expected.field.f1.analyzer = 'someAnalyzer';
- doTest();
-
- fieldQuery.quoteAnalyzer('qAnalyzer');
- expected.field.f1.quote_analyzer = 'qAnalyzer';
- doTest();
-
- fieldQuery.autoGeneratePhraseQueries(false);
- expected.field.f1.auto_generate_phrase_queries = false;
- doTest();
-
- fieldQuery.allowLeadingWildcard(true);
- expected.field.f1.allow_leading_wildcard = true;
- doTest();
-
- fieldQuery.lowercaseExpandedTerms(false);
- expected.field.f1.lowercase_expanded_terms = false;
- doTest();
-
- fieldQuery.enablePositionIncrements(true);
- expected.field.f1.enable_position_increments = true;
- doTest();
-
- fieldQuery.fuzzyMinSim(0.2);
- expected.field.f1.fuzzy_min_sim = 0.2;
- doTest();
-
- fieldQuery.boost(1.5);
- expected.field.f1.boost = 1.5;
- doTest();
-
- fieldQuery.fuzzyPrefixLength(4);
- expected.field.f1.fuzzy_prefix_length = 4;
- doTest();
-
- fieldQuery.fuzzyMaxExpansions(6);
- expected.field.f1.fuzzy_max_expansions = 6;
- doTest();
-
- fieldQuery.fuzzyRewrite('constant_score_auto');
- expected.field.f1.fuzzy_rewrite = 'constant_score_auto';
- doTest();
-
- fieldQuery.fuzzyRewrite('invalid');
- doTest();
-
- fieldQuery.fuzzyRewrite('scoring_boolean');
- expected.field.f1.fuzzy_rewrite = 'scoring_boolean';
- doTest();
-
- fieldQuery.fuzzyRewrite('constant_score_boolean');
- expected.field.f1.fuzzy_rewrite = 'constant_score_boolean';
- doTest();
-
- fieldQuery.fuzzyRewrite('constant_score_filter');
- expected.field.f1.fuzzy_rewrite = 'constant_score_filter';
- doTest();
-
- fieldQuery.fuzzyRewrite('top_terms_boost_5');
- expected.field.f1.fuzzy_rewrite = 'top_terms_boost_5';
- doTest();
-
- fieldQuery.fuzzyRewrite('top_terms_9');
- expected.field.f1.fuzzy_rewrite = 'top_terms_9';
- doTest();
-
- fieldQuery.rewrite('constant_score_auto');
- expected.field.f1.rewrite = 'constant_score_auto';
- doTest();
-
- fieldQuery.rewrite('invalid');
- doTest();
-
- fieldQuery.rewrite('scoring_boolean');
- expected.field.f1.rewrite = 'scoring_boolean';
- doTest();
-
- fieldQuery.rewrite('constant_score_boolean');
- expected.field.f1.rewrite = 'constant_score_boolean';
- doTest();
-
- fieldQuery.rewrite('constant_score_filter');
- expected.field.f1.rewrite = 'constant_score_filter';
- doTest();
-
- fieldQuery.rewrite('top_terms_boost_5');
- expected.field.f1.rewrite = 'top_terms_boost_5';
- doTest();
-
- fieldQuery.rewrite('top_terms_9');
- expected.field.f1.rewrite = 'top_terms_9';
- doTest();
-
- fieldQuery.quoteFieldSuffix('s');
- expected.field.f1.quote_field_suffix = 's';
- doTest();
-
- fieldQuery.escape(true);
- expected.field.f1.escape = true;
- doTest();
-
- fieldQuery.phraseSlop(2);
- expected.field.f1.phrase_slop = 2;
- doTest();
-
- fieldQuery.analyzeWildcard(false);
- expected.field.f1.analyze_wildcard = false;
- doTest();
-
- fieldQuery.minimumShouldMatch(5);
- expected.field.f1.minimum_should_match = 5;
- doTest();
-
- test.strictEqual(fieldQuery._type(), 'query');
-
test.done();
},
@@ -2417,7 +1993,7 @@ exports.queries = {
var disMaxQuery = ejs.DisMaxQuery(),
termQuery1 = ejs.TermQuery('t1', 'v1').boost(1.5),
- fieldQuery1 = ejs.FieldQuery('f1', 'v1'),
+ termQuery2 = ejs.TermQuery('t2', 'v2'),
boolQuery1 = ejs.BoolQuery().must(termQuery1).boost(2),
expected,
doTest = function () {
@@ -2432,8 +2008,8 @@ exports.queries = {
test.ok(disMaxQuery.toJSON(), 'toJSON() works');
doTest();
- disMaxQuery.queries(fieldQuery1);
- expected.dis_max.queries = [fieldQuery1.toJSON()];
+ disMaxQuery.queries(termQuery2);
+ expected.dis_max.queries = [termQuery2.toJSON()];
doTest();
disMaxQuery.queries(boolQuery1);
@@ -2443,7 +2019,7 @@ exports.queries = {
disMaxQuery.queries([termQuery1, boolQuery1]);
expected.dis_max.queries = [termQuery1.toJSON(), boolQuery1.toJSON()];
doTest();
-
+
disMaxQuery.boost(3);
expected.dis_max.boost = 3;
doTest();
@@ -2453,16 +2029,16 @@ exports.queries = {
doTest();
test.strictEqual(disMaxQuery._type(), 'query');
-
+
test.throws(function () {
disMaxQuery.queries('invalid');
}, TypeError);
-
+
test.throws(function () {
disMaxQuery.queries([termQuery1, 'invalid']);
}, TypeError);
-
+
test.done();
},
QueryStringQuery: function (test) {
@@ -2499,7 +2075,7 @@ exports.queries = {
queryString.fields('field3');
expected.query_string.fields.push('field3');
doTest();
-
+
queryString.useDisMax(true);
expected.query_string.use_dis_max = true;
doTest();
@@ -2566,84 +2142,84 @@ exports.queries = {
queryString.fuzzyMaxExpansions(6);
expected.query_string.fuzzy_max_expansions = 6;
doTest();
-
+
queryString.fuzzyRewrite('constant_score_auto');
expected.query_string.fuzzy_rewrite = 'constant_score_auto';
doTest();
-
+
queryString.fuzzyRewrite('invalid');
doTest();
-
+
queryString.fuzzyRewrite('scoring_boolean');
expected.query_string.fuzzy_rewrite = 'scoring_boolean';
doTest();
-
+
queryString.fuzzyRewrite('constant_score_boolean');
expected.query_string.fuzzy_rewrite = 'constant_score_boolean';
doTest();
-
+
queryString.fuzzyRewrite('constant_score_filter');
expected.query_string.fuzzy_rewrite = 'constant_score_filter';
doTest();
-
+
queryString.fuzzyRewrite('top_terms_boost_5');
expected.query_string.fuzzy_rewrite = 'top_terms_boost_5';
doTest();
-
+
queryString.fuzzyRewrite('top_terms_9');
expected.query_string.fuzzy_rewrite = 'top_terms_9';
doTest();
-
+
queryString.rewrite('constant_score_auto');
expected.query_string.rewrite = 'constant_score_auto';
doTest();
-
+
queryString.rewrite('invalid');
doTest();
-
+
queryString.rewrite('scoring_boolean');
expected.query_string.rewrite = 'scoring_boolean';
doTest();
-
+
queryString.rewrite('constant_score_boolean');
expected.query_string.rewrite = 'constant_score_boolean';
doTest();
-
+
queryString.rewrite('constant_score_filter');
expected.query_string.rewrite = 'constant_score_filter';
doTest();
-
+
queryString.rewrite('top_terms_boost_5');
expected.query_string.rewrite = 'top_terms_boost_5';
doTest();
-
+
queryString.rewrite('top_terms_9');
expected.query_string.rewrite = 'top_terms_9';
doTest();
-
+
queryString.quoteFieldSuffix('s');
expected.query_string.quote_field_suffix = 's';
doTest();
-
+
queryString.escape(true);
expected.query_string.escape = true;
doTest();
-
+
queryString.quoteAnalyzer('qAnalyzer');
expected.query_string.quote_analyzer = 'qAnalyzer';
doTest();
-
+
queryString.lenient(true);
expected.query_string.lenient = true;
doTest();
-
+
test.strictEqual(queryString._type(), 'query');
-
+
test.throws(function () {
queryString.fields(2);
}, TypeError);
-
+
test.done();
},
FilteredQuery: function (test) {
@@ -2678,69 +2254,69 @@ exports.queries = {
}
};
doTest();
-
+
filterQuery.filter(termFilter2);
expected.filtered.filter = termFilter2.toJSON();
doTest();
-
+
filterQuery.query(termQuery3);
expected.filtered.query = termQuery3.toJSON();
doTest();
-
+
filterQuery.strategy('query_first');
expected.filtered.strategy = 'query_first';
doTest();
-
+
filterQuery.strategy('INVALID');
doTest();
-
+
filterQuery.strategy('random_access_always');
expected.filtered.strategy = 'random_access_always';
doTest();
-
+
filterQuery.strategy('LEAP_FROG');
expected.filtered.strategy = 'leap_frog';
doTest();
-
+
filterQuery.strategy('leap_frog_filter_first');
expected.filtered.strategy = 'leap_frog_filter_first';
doTest();
-
+
filterQuery.strategy('random_access_5');
expected.filtered.strategy = 'random_access_5';
doTest();
-
+
filterQuery.cache(true);
expected.filtered._cache = true;
doTest();
-
+
filterQuery.cacheKey('filter_cache_key');
expected.filtered._cache_key = 'filter_cache_key';
doTest();
-
+
filterQuery.boost(2.6);
expected.filtered.boost = 2.6;
doTest();
-
+
test.strictEqual(filterQuery._type(), 'query');
-
+
test.throws(function () {
ejs.FilteredQuery('invalid', termFilter1);
}, TypeError);
-
+
test.throws(function () {
ejs.FilteredQuery(termQuery1, 'invalid');
}, TypeError);
-
+
test.throws(function () {
filterQuery.query('invalid');
}, TypeError);
-
+
test.throws(function () {
filterQuery.filter('invalid');
}, TypeError);
-
+
test.done();
},
NestedQuery: function (test) {
@@ -2773,57 +2349,57 @@ exports.queries = {
nestedQuery.query(termQuery1);
expected.nested.query = termQuery1.toJSON();
doTest();
-
+
nestedQuery.filter(termFilter1);
expected.nested.filter = termFilter1.toJSON();
doTest();
-
+
nestedQuery.query(termQuery2);
expected.nested.query = termQuery2.toJSON();
doTest();
-
+
nestedQuery.filter(termFilter2);
expected.nested.filter = termFilter2.toJSON();
doTest();
-
+
nestedQuery.scoreMode('avg');
expected.nested.score_mode = 'avg';
doTest();
nestedQuery.scoreMode('INVALID');
doTest();
-
+
nestedQuery.scoreMode('TOTAL');
expected.nested.score_mode = 'total';
doTest();
-
+
nestedQuery.scoreMode('Max');
expected.nested.score_mode = 'max';
doTest();
-
+
nestedQuery.scoreMode('none');
expected.nested.score_mode = 'none';
doTest();
-
+
nestedQuery.scoreMode('sum');
expected.nested.score_mode = 'sum';
doTest();
-
+
nestedQuery.boost(3.2);
expected.nested.boost = 3.2;
doTest();
test.strictEqual(nestedQuery._type(), 'query');
-
+
test.throws(function () {
nestedQuery.query('invalid');
}, TypeError);
-
+
test.throws(function () {
nestedQuery.filter('invalid');
}, TypeError);
-
+
test.done();
},
ConstantScoreQuery: function (test) {
@@ -2850,7 +2426,7 @@ exports.queries = {
doTest();
test.strictEqual(constantScoreQuery._type(), 'query');
-
+
constantScoreQuery = ejs.ConstantScoreQuery();
constantScoreQuery.filter(termFilter1);
@@ -2864,21 +2440,21 @@ exports.queries = {
constantScoreQuery.cache(true);
expected.constant_score._cache = true;
doTest();
-
+
constantScoreQuery.cacheKey('key');
expected.constant_score._cache_key = 'key';
doTest();
-
-
+
+
test.throws(function () {
constantScoreQuery.query('invalid');
}, TypeError);
-
+
test.throws(function () {
constantScoreQuery.filter('invalid');
}, TypeError);
-
+
test.done();
},
MatchAllQuery: function (test) {
@@ -2901,9 +2477,9 @@ exports.queries = {
matchAllQuery.boost(2.2);
expected.match_all.boost = 2.2;
doTest();
-
+
test.strictEqual(matchAllQuery._type(), 'query');
-
+
test.done();
},
@@ -2937,17 +2513,17 @@ exports.queries = {
}
};
doTest();
-
+
spanTermQuery.term('v2');
expected.span_term.t2.term = 'v2';
doTest();
-
+
spanTermQuery.boost(1.5);
expected.span_term.t2.boost = 1.5;
doTest();
test.strictEqual(spanTermQuery._type(), 'query');
-
+
test.done();
},
@@ -2991,7 +2567,7 @@ exports.queries = {
}
};
doTest();
-
+
spanNearQuery.slop(3);
expected.span_near.slop = 3;
doTest();
@@ -3009,24 +2585,24 @@ exports.queries = {
doTest();
test.strictEqual(spanNearQuery._type(), 'query');
-
+
test.throws(function () {
ejs.SpanNearQuery('invalid', 2);
}, TypeError);
-
+
test.throws(function () {
ejs.SpanNearQuery([spanTermQuery1, 'invalid'], 4);
}, TypeError);
-
+
test.throws(function () {
spanNearQuery.clauses('invalid');
}, TypeError);
-
+
test.throws(function () {
spanNearQuery.clauses([spanTermQuery2, 'invalid']);
}, TypeError);
-
+
test.done();
},
SpanNotQuery: function (test) {
@@ -3064,26 +2640,26 @@ exports.queries = {
spanNotQuery.boost(4.1);
expected.span_not.boost = 4.1;
doTest();
-
+
test.strictEqual(spanNotQuery._type(), 'query');
-
+
test.throws(function () {
ejs.SpanNotQuery('invalid', spanTermQuery1);
}, TypeError);
-
+
test.throws(function () {
ejs.SpanNotQuery(spanTermQuery1, 'invalid');
}, TypeError);
-
+
test.throws(function () {
spanNotQuery.include('invalid');
}, TypeError);
-
+
test.throws(function () {
spanNotQuery.exclude('invalid');
}, TypeError);
-
+
test.done();
},
SpanOrQuery: function (test) {
@@ -3109,7 +2685,7 @@ exports.queries = {
test.ok(spanOrQuery, 'SpanOrQuery exists');
test.ok(spanOrQuery.toJSON(), 'toJSON() works');
doTest();
-
+
spanOrQuery = ejs.SpanOrQuery([spanTermQuery2, spanTermQuery3]);
expected.span_or.clauses = [spanTermQuery2.toJSON(), spanTermQuery3.toJSON()];
doTest();
@@ -3125,26 +2701,26 @@ exports.queries = {
spanOrQuery.boost(1.1);
expected.span_or.boost = 1.1;
doTest();
-
+
test.strictEqual(spanOrQuery._type(), 'query');
-
+
test.throws(function () {
ejs.SpanOrQuery('invalid');
}, TypeError);
-
+
test.throws(function () {
ejs.SpanOrQuery([spanTermQuery1, 'invalid']);
}, TypeError);
-
+
test.throws(function () {
spanOrQuery.clauses('invalid');
}, TypeError);
-
+
test.throws(function () {
spanOrQuery.clauses([spanTermQuery1, 'invalid']);
}, TypeError);
-
+
test.done();
},
SpanFirstQuery: function (test) {
@@ -3180,18 +2756,18 @@ exports.queries = {
spanFirstQuery.boost(3.1);
expected.span_first.boost = 3.1;
doTest();
-
+
test.strictEqual(spanFirstQuery._type(), 'query');
-
+
test.throws(function () {
ejs.SpanFirstQuery('invalid', 3);
}, TypeError);
-
+
test.throws(function () {
spanFirstQuery.match('invalid');
}, TypeError);
-
+
test.done();
},
SpanMultiTermQuery: function (test) {
@@ -3218,22 +2794,22 @@ exports.queries = {
spanMultiTermQuery = ejs.SpanMultiTermQuery(mtQuery1);
expected.span_multi.match = mtQuery1.toJSON();
doTest();
-
+
spanMultiTermQuery.match(mtQuery2);
expected.span_multi.match = mtQuery2.toJSON();
doTest();
-
+
test.strictEqual(spanMultiTermQuery._type(), 'query');
-
+
test.throws(function () {
ejs.SpanMultiTermQuery('invalid');
}, TypeError);
-
+
test.throws(function () {
spanMultiTermQuery.match('invalid');
}, TypeError);
-
+
test.done();
},
FieldMaskingSpanQuery: function (test) {
@@ -3269,18 +2845,18 @@ exports.queries = {
fieldMaskingSpanQuery.boost(5.1);
expected.field_masking_span.boost = 5.1;
doTest();
-
+
test.strictEqual(fieldMaskingSpanQuery._type(), 'query');
-
+
test.throws(function () {
ejs.FieldMaskingSpanQuery('invalid', 'mf');
}, TypeError);
-
+
test.throws(function () {
fieldMaskingSpanQuery.query('invalid');
}, TypeError);
-
+
test.done();
}
};