forked from fullscale/elastic.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
elastic.min.js
8 lines (7 loc) · 96.5 KB
/
elastic.min.js
1
2
3
4
5
6
7
8
/*! 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,A=this,B=A&&A.ejs,C=Array.prototype,D=Object.prototype,E=C.slice,F=D.toString,G=D.hasOwnProperty,H=C.forEach,I=Array.isArray,J=C.indexOf,K={};z="undefined"!=typeof exports?exports:A.ejs={},a=function(a,b){return G.call(a,b)},b=function(b,c,d){if(null!=b)if(H&&b.forEach===H)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)===K)return}else for(var g in b)if(a(b,g)&&c.call(d,b[g],g,b)===K)return},c=function(a){return b(E.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(J&&a.indexOf===J)return a.indexOf(b);for(;d>c;c++)if(a[c]===b)return c;return-1},e=I||function(a){return"[object Array]"===F.call(a)},f=function(a){return a===Object(a)},g=function(a){return"[object String]"===F.call(a)},h=function(a){return"[object Number]"===F.call(a)},i=function(a){return a===!0||a===!1||"[object Boolean]"===F.call(a)},j="function"!=typeof/./?function(a){return"function"==typeof a}:function(a){return"[object Function]"===F.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=function(a){return k(a)&&"score function"===a._type()},z.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}}},z.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)}}},z.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}}},z.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}}},z.MetricsAggregationMixin=function(a,b){var d=z.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)}})},z.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}}},z.ScoreFunctionMixin=function(a){var b={};return b[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},_type:function(){return"score function"},toJSON:function(){return b}}},z.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)}}},z.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}}},z.DateHistogramFacet=function(a){var b=z.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)}})},z.FilterFacet=function(a){var b=z.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}})},z.GeoDistanceFacet=function(a){var b=z.FacetMixin(a),d=b.toJSON(),e=z.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)}})},z.HistogramFacet=function(a){var b=z.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)}})},z.QueryFacet=function(a){var b=z.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}})},z.RangeFacet=function(a){var b=z.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)}})},z.StatisticalFacet=function(a){var b=z.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)}})},z.TermStatsFacet=function(a){var b=z.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)}})},z.TermsFacet=function(a){var b=z.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)}})},z.AvgAggregation=function(a){{var b=z.MetricsAggregationMixin(a,"avg");b.toJSON()}return b},z.CardinalityAggregation=function(a){var b=z.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)}})},z.DateHistogramAggregation=function(a){var b=z.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)}})},z.DateRangeAggregation=function(a){var b=z.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)}})},z.ExtendedStatsAggregation=function(a){{var b=z.MetricsAggregationMixin(a,"extended_stats");b.toJSON()}return b},z.FilterAggregation=function(a){var b=z.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}})},z.GeoDistanceAggregation=function(a){var b=z.AggregationMixin(a),d=z.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)}})},z.GeoHashGridAggregation=function(a){var b=z.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)}})},z.GlobalAggregation=function(a){var b=z.AggregationMixin(a),c=b.toJSON();return c[a].global={},b},z.HistogramAggregation=function(a){var b=z.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)}})},z.IPv4RangeAggregation=function(a){var b=z.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)}})},z.MaxAggregation=function(a){{var b=z.MetricsAggregationMixin(a,"max");b.toJSON()}return b},z.MinAggregation=function(a){{var b=z.MetricsAggregationMixin(a,"min");b.toJSON()}return b},z.MissingAggregation=function(a){var b=z.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)}})},z.NestedAggregation=function(a){var b=z.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)}})},z.PercentilesAggregation=function(a){var b=z.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)}})},z.RangeAggregation=function(a){var b=z.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)}})},z.SignificantTermsAggregation=function(a){var b=z.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)}})},z.StatsAggregation=function(a){{var b=z.MetricsAggregationMixin(a,"stats");b.toJSON()}return b},z.SumAggregation=function(a){{var b=z.MetricsAggregationMixin(a,"sum");b.toJSON()}return b},z.TermsAggregation=function(a){var b=z.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)}})},z.ValueCountAggregation=function(a){var b=z.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)}})},z.AndFilter=function(a){var b,d,f=z.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}})},z.BoolFilter=function(){var a=z.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}})},z.ExistsFilter=function(a){var b=z.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)}})},z.GeoBboxFilter=function(a){var b=z.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)}})},z.GeoDistanceFilter=function(a){var b=z.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)}})},z.GeoDistanceRangeFilter=function(a){var b=z.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)}})},z.GeoPolygonFilter=function(a){var b=z.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)}})},z.GeoShapeFilter=function(a){var b=z.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)}})},z.HasChildFilter=function(a,b){if(!l(a))throw new TypeError("No Query object found");var d=z.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}})},z.HasParentFilter=function(a,b){if(!l(a))throw new TypeError("No Query object found");var d=z.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}})},z.IdsFilter=function(a){var b=z.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}})},z.IndicesFilter=function(a,b){if(!n(a))throw new TypeError("Argument must be a Filter");var d=z.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}})},z.LimitFilter=function(a){var b=z.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}})},z.MatchAllFilter=function(){return z.FilterMixin("match_all")},z.MissingFilter=function(a){var b=z.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)}})},z.NestedFilter=function(a){var b=z.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}})},z.NotFilter=function(a){if(!n(a))throw new TypeError("Argument must be a Filter");var b=z.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}})},z.NumericRangeFilter=function(a){var b=z.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}})},z.OrFilter=function(a){var b,d,f=z.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}})},z.PrefixFilter=function(a,b){var d=z.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)}})},z.QueryFilter=function(a){if(!l(a))throw new TypeError("Argument must be a Query");var b=z.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}})},z.RangeFilter=function(a){var b=z.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)}})},z.RegexpFilter=function(a,b){var d=z.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)}})},z.ScriptFilter=function(a){var b=z.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)}})},z.TermFilter=function(a,b){var d=z.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)}})},z.TermsFilter=function(a,b){var d=z.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)}})},z.TypeFilter=function(a){var b=z.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)}})},z.BoolQuery=function(){var a=z.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)}})},z.BoostingQuery=function(a,b,d){if(!l(a)||!l(b))throw new TypeError("Arguments must be Queries");var e=z.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)}})},z.CommonTermsQuery=function(a,b){var d=z.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)}})},z.ConstantScoreQuery=function(){var a=z.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)}})},z.DisMaxQuery=function(){var a=z.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)}})},z.FieldMaskingSpanQuery=function(a,b){if(!l(a))throw new TypeError("Argument must be a SpanQuery");var d=z.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)}})},z.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=z.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)}})},z.FunctionScoreQuery=function(){var a=z.QueryMixin("function_score"),b=a.toJSON();return c(a,{query:function(a){if(null==a)return b.function_score.query;if(!l(a))throw new TypeError("Argument must be a Query");return b.function_score.query=a.toJSON(),this},filter:function(a){if(null==a)return b.function_score.filter;if(!n(a))throw new TypeError("Argument must be a Filter");return b.function_score.filter=a.toJSON(),this},scoreMode:function(a){return null==a?b.function_score.score_mode:(a=a.toLowerCase(),("avg"===a||"max"===a||"min"===a||"sum"===a||"multiply"===a||"first"===a)&&(b.function_score.score_mode=a),this)},boostMode:function(a){return null==a?b.function_score.boost_mode:(a=a.toLowerCase(),("multiply"===a||"replace"===a||"sum"===a||"avg"===a||"max"===a||"min"===a)&&(b.function_score.boost_mode=a),this)},boost:function(a){return null==a?b.function_score.boost:(b.function_score.boost=a,this)},"function":function(a){if(null==b.function_score.functions&&(b.function_score.functions=[]),null==a)return b.function_score.functions;if(!y(a))throw new TypeError("Argument must be a ScoreFunction");return b.function_score.functions.push(a.toJSON()),this},functions:function(a){var c,d;if(null==a)return b.function_score.functions;if(!e(a))throw new TypeError("Argument must be an array of ScoreFunctions");for(b.function_score.functions=[],c=0,d=a.length;d>c;c++){if(!y(a[c]))throw new TypeError("Argument must be an array of ScoreFunctions");b.function_score.functions.push(a[c].toJSON())}return this}})},z.FuzzyLikeThisFieldQuery=function(a,b){var d=z.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)}})},z.FuzzyLikeThisQuery=function(a){var b=z.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)}})},z.FuzzyQuery=function(a,b){var d=z.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)}})},z.GeoShapeQuery=function(a){var b=z.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)}})},z.HasChildQuery=function(a,b){if(!l(a))throw new TypeError("Argument must be a valid Query");var d=z.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)}})},z.HasParentQuery=function(a,b){if(!l(a))throw new TypeError("Argument must be a Query");var d=z.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)}})},z.IdsQuery=function(a){var b=z.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}})},z.IndicesQuery=function(a,b){if(!l(a))throw new TypeError("Argument must be a Query");var d=z.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}})},z.MatchAllQuery=function(){return z.QueryMixin("match_all")},z.MatchQuery=function(a,b){var d=z.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)}})},z.MoreLikeThisFieldQuery=function(a,b){var d=z.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)}})},z.MoreLikeThisQuery=function(a,b){var d=z.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)}})},z.MultiMatchQuery=function(a,b){var d=z.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)}})},z.NestedQuery=function(a){var b=z.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}})},z.PrefixQuery=function(a,b){var d=z.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)}})},z.QueryStringQuery=function(a){var b=z.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)}})},z.RangeQuery=function(a){var b=z.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)}})},z.RegexpQuery=function(a,b){var d=z.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)}})},z.SpanFirstQuery=function(a,b){if(!l(a))throw new TypeError("Argument must be a SpanQuery");var d=z.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)}})},z.SpanMultiTermQuery=function(a){if(null!=a&&!l(a))throw new TypeError("Argument must be a MultiTermQuery");var b=z.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}})},z.SpanNearQuery=function(a,b){var d,f,g=z.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)}})},z.SpanNotQuery=function(a,b){if(!l(a)||!l(b))throw new TypeError("Argument must be a SpanQuery");var d=z.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}})},z.SpanOrQuery=function(a){var b,d,f=z.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}})},z.SpanTermQuery=function(a,b){var d=z.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)}})},z.TermQuery=function(a,b){var d=z.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)}})},z.TermsQuery=function(a,b){var d=z.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)}})},z.TopChildrenQuery=function(a,b){if(!l(a))throw new TypeError("Argument must be a Query");var d=z.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)}})},z.WildcardQuery=function(a,b){var d=z.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)}})},z.BoostFactorScoreFunction=function(a){var b=z.ScoreFunctionMixin("boost_factor"),d=b.toJSON();return d.boost_factor=a,c(b,{boost:function(a){return null==a?d.boost_factor:(d.boost_factor=a,this)}})},z.DecayScoreFunction=function(a){var b="gauss",d=z.ScoreFunctionMixin(b),e=d.toJSON(),f=function(a){var c;b!==a&&(c=e[b],delete e[b],b=a,e[b]=c)};return e[b][a]={},c(d,{linear:function(){f("linear")},exp:function(){f("exp")},gauss:function(){f("gauss")},field:function(c){var d=e[b][a];return null==c?a:(delete e[b][a],a=c,e[b][a]=d,this)},scale:function(c){return null==c?e[b][a].scale:(e[b][a].scale=c,this)},origin:function(c){if(null==c)return e[b][a].origin;if(r(c))e[b][a].origin=c.toJSON();else{if(k(c))throw new TypeError("origin must be a GeoPoint or native type");e[b][a].origin=c}return this},decay:function(c){return null==c?e[b][a].decay:(e[b][a].decay=c,this)},offset:function(c){return null==c?e[b][a].offset:(e[b][a].offset=c,this)}})},z.RandomScoreFunction=function(){var a=z.ScoreFunctionMixin("random_score"),b=a.toJSON();return c(a,{seed:function(a){return null==a?b.random_score.seed:(b.random_score.seed=a,this)}})},z.ScriptScoreFunction=function(){var a=z.ScoreFunctionMixin("script_score"),b=a.toJSON();return c(a,{script:function(a){return null==a?b.script_score.script:(b.script_score.script=a,this)},lang:function(a){return null==a?b.script_score.lang:(b.script_score.lang=a,this)},params:function(a){return null==a?b.script_score.params:(b.script_score.params=a,this)}})},z.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}}},z.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||"postings"===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}}},z.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}}},z.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}}},z.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}}},z.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}}},z.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}}},z.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}}},z.CompletionSuggester=function(a){var b,d=z.SuggesterMixin(a),e=d.toJSON();return e[a].completion={},b=z.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)
}})},z.DirectGenerator=function(){var a={},b=z.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}})},z.PhraseSuggester=function(a){var b,d=z.SuggesterMixin(a),f=d.toJSON();return f[a].phrase={},b=z.SuggestContextMixin(f[a].phrase),c(d,b,{realWordErrorLikelihood:function(b){return null==b?f[a].phrase.real_word_error_likelihood:(f[a].phrase.real_word_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}})},z.TermSuggester=function(a){var b,d,e=z.SuggesterMixin(a),f=e.toJSON();return f[a].term={},b=z.DirectSettingsMixin(f[a].term),d=z.SuggestContextMixin(f[a].term),c(e,b,d)},z.noConflict=function(){return A.ejs=B,this}}).call(this);