text: /*! elastic.js - v1.2.0 - 2014-10-13
   * https://github.com/fullscale/elastic.js
   * Copyright (c) 2014 FullScale Labs, LLC; Licensed MIT */
  (function(){var aw,av,au,at,ar,aq,ap,ao,an,am,al,ak,aj,ai,ah,ag,af,ae,ad,ac,ab,aa,Z,Y,X,W,V=this,U=V&&V.ejs,T=Array.prototype,S=Object.prototype,R=T.slice,Q=S.toString,P=S.hasOwnProperty,O=T.forEach,N=Array.isArray,M=T.indexOf,L={};W="undefined"!=typeof exports?exports:V.ejs={},aw=function(d,c){return P.call(d,c)},av=function(a,l,k){if(null!=a){if(O&&a.forEach===O){a.forEach(l,k)}else{if(a.length===+a.length){for(var j=0,i=a.length;i>j;j++){if(l.call(k,a[j],j,a)===L){return}}}else{for(var h in a){if(aw(a,h)&&l.call(k,a[h],h,a)===L){return}}}}}},au=function(b){return av(R.call(arguments,1),function(a){for(var d in a){b[d]=a[d]}}),b},at=function(f,e){if(null==f){return -1}var h=0,g=f.length;if(M&&f.indexOf===M){return f.indexOf(e)}for(;g>h;h++){if(f[h]===e){return h}}return -1},ar=N||function(b){return"[object Array]"===Q.call(b)},aq=function(b){return b===Object(b)},ap=function(b){return"[object String]"===Q.call(b)},ao=function(b){return"[object Number]"===Q.call(b)},an=function(b){return b===!0||b===!1||"[object Boolean]"===Q.call(b)},am="function"!=typeof/./?function(b){return"function"==typeof b}:function(b){return"[object Function]"===Q.call(b)},al=function(a){return aq(a)&&aw(a,"_type")&&aw(a,"toJSON")},ak=function(b){return al(b)&&"query"===b._type()},aj=function(b){return al(b)&&"rescore"===b._type()},ai=function(b){return al(b)&&"filter"===b._type()},ah=function(b){return al(b)&&"facet"===b._type()},ag=function(b){return al(b)&&"aggregation"===b._type()},af=function(b){return al(b)&&"script field"===b._type()},ae=function(b){return al(b)&&"geo point"===b._type()},ad=function(b){return al(b)&&"indexed shape"===b._type()},ac=function(b){return al(b)&&"shape"===b._type()},ab=function(b){return al(b)&&"sort"===b._type()},aa=function(b){return al(b)&&"highlight"===b._type()},Z=function(b){return al(b)&&"suggest"===b._type()},Y=function(b){return al(b)&&"generator"===b._type()},X=function(b){return al(b)&&"score function"===b._type()},W.AggregationMixin=function(d){var c={};return c[d]={},{aggregation:function(a){if(null==a){return c[d].aggs}if(null==c[d].aggs&&(c[d].aggs={}),!ag(a)){throw new TypeError("Argument must be an Aggregation")}return au(c[d].aggs,a.toJSON()),this},agg:function(b){return this.aggregation(b)},_type:function(){return"aggregation"},toJSON:function(){return c}}},W.DirectSettingsMixin=function(b){return{accuracy:function(a){return null==a?b.accuracy:(b.accuracy=a,this)},suggestMode:function(a){return null==a?b.suggest_mode:(a=a.toLowerCase(),("missing"===a||"popular"===a||"always"===a)&&(b.suggest_mode=a),this)},sort:function(a){return null==a?b.sort:(a=a.toLowerCase(),("score"===a||"frequency"===a)&&(b.sort=a),this)},stringDistance:function(a){return null==a?b.string_distance:(a=a.toLowerCase(),("internal"===a||"damerau_levenshtein"===a||"levenstein"===a||"jarowinkler"===a||"ngram"===a)&&(b.string_distance=a),this)},maxEdits:function(a){return null==a?b.max_edits:(b.max_edits=a,this)},maxInspections:function(a){return null==a?b.max_inspections:(b.max_inspections=a,this)},maxTermFreq:function(a){return null==a?b.max_term_freq:(b.max_term_freq=a,this)},prefixLen:function(a){return null==a?b.prefix_len:(b.prefix_len=a,this)},minWordLen:function(a){return null==a?b.min_word_len:(b.min_word_len=a,this)},minDocFreq:function(a){return null==a?b.min_doc_freq:(b.min_doc_freq=a,this)}}},W.FacetMixin=function(d){var c={};return c[d]={},{facetFilter:function(a){if(null==a){return c[d].facet_filter}if(!ai(a)){throw new TypeError("Argument must be a Filter")}return c[d].facet_filter=a.toJSON(),this},global:function(a){return null==a?c[d].global:(c[d].global=a,this)},mode:function(a){return null==a?c[d].mode:(a=a.toLowerCase(),("collector"===a||"post"===a)&&(c[d].mode=a),this)},cacheFilter:function(a){return null==a?c[d].cache_filter:(c[d].cache_filter=a,this)},scope:function(){return this},nested:function(a){return null==a?c[d].nested:(c[d].nested=a,this)},_type:function(){return"facet"},toJSON:function(){return c}}},W.FilterMixin=function(d){var c={};return c[d]={},{name:function(a){return null==a?c[d]._name:(c[d]._name=a,this)},cache:function(a){return null==a?c[d]._cache:(c[d]._cache=a,this)},cacheKey:function(a){return null==a?c[d]._cache_key:(c[d]._cache_key=a,this)},_type:function(){return"filter"},toJSON:function(){return c}}},W.MetricsAggregationMixin=function(f,c){var h=W.AggregationMixin(f),g=h.toJSON();return delete h.aggregation,delete h.agg,g[f][c]={},au(h,{field:function(a){return null==a?g[f][c].field:(g[f][c].field=a,this)},script:function(a){return null==a?g[f][c].script:(g[f][c].script=a,this)},lang:function(a){return null==a?g[f][c].lang:(g[f][c].lang=a,this)},scriptValuesSorted:function(a){return null==a?g[f][c].script_values_sorted:(g[f][c].script_values_sorted=a,this)},params:function(a){return null==a?g[f][c].params:(g[f][c].params=a,this)}})},W.QueryMixin=function(d){var c={};return c[d]={},{boost:function(a){return null==a?c[d].boost:(c[d].boost=a,this)},_type:function(){return"query"},toJSON:function(){return c}}},W.ScoreFunctionMixin=function(d){var c={};return c[d]={},{filter:function(b){if(null==b){return c.filter}if(!ai(b)){throw new TypeError("Argument must be a Filter")}return c.filter=b.toJSON(),this},_type:function(){return"score function"},toJSON:function(){return c}}},W.SuggestContextMixin=function(b){return{analyzer:function(a){return null==a?b.analyzer:(b.analyzer=a,this)},field:function(a){return null==a?b.field:(b.field=a,this)},size:function(a){return null==a?b.size:(b.size=a,this)},shardSize:function(a){return null==a?b.shard_size:(b.shard_size=a,this)}}},W.SuggesterMixin=function(d){var c={};return c[d]={},{text:function(a){return null==a?c[d].text:(c[d].text=a,this)},_type:function(){return"suggest"},toJSON:function(){return c}}},W.DateHistogramFacet=function(e){var c=W.FacetMixin(e),f=c.toJSON();return f[e].date_histogram={},au(c,{field:function(a){return null==a?f[e].date_histogram.field:(f[e].date_histogram.field=a,this)},keyField:function(a){return null==a?f[e].date_histogram.key_field:(f[e].date_histogram.key_field=a,this)},valueField:function(a){return null==a?f[e].date_histogram.value_field:(f[e].date_histogram.value_field=a,this)},interval:function(a){return null==a?f[e].date_histogram.interval:(f[e].date_histogram.interval=a,this)},timeZone:function(a){return null==a?f[e].date_histogram.time_zone:(f[e].date_histogram.time_zone=a,this)},preZone:function(a){return null==a?f[e].date_histogram.pre_zone:(f[e].date_histogram.pre_zone=a,this)},preZoneAdjustLargeInterval:function(a){return null==a?f[e].date_histogram.pre_zone_adjust_large_interval:(f[e].date_histogram.pre_zone_adjust_large_interval=a,this)},postZone:function(a){return null==a?f[e].date_histogram.post_zone:(f[e].date_histogram.post_zone=a,this)},preOffset:function(a){return null==a?f[e].date_histogram.pre_offset:(f[e].date_histogram.pre_offset=a,this)},postOffset:function(a){return null==a?f[e].date_histogram.post_offset:(f[e].date_histogram.post_offset=a,this)},factor:function(a){return null==a?f[e].date_histogram.factor:(f[e].date_histogram.factor=a,this)},valueScript:function(a){return null==a?f[e].date_histogram.value_script:(f[e].date_histogram.value_script=a,this)},order:function(a){return null==a?f[e].date_histogram.order:(a=a.toLowerCase(),("time"===a||"count"===a||"total"===a)&&(f[e].date_histogram.order=a),this)},lang:function(a){return null==a?f[e].date_histogram.lang:(f[e].date_histogram.lang=a,this)},params:function(a){return null==a?f[e].date_histogram.params:(f[e].date_histogram.params=a,this)}})},W.FilterFacet=function(e){var c=W.FacetMixin(e),f=c.toJSON();return au(c,{filter:function(a){if(null==a){return f[e].filter}if(!ai(a)){throw new TypeError("Argument must be a Filter")}return f[e].filter=a.toJSON(),this}})},W.GeoDistanceFacet=function(g){var c=W.FacetMixin(g),j=c.toJSON(),i=W.GeoPoint([0,0]),h="location";return j[g].geo_distance={location:i.toJSON(),ranges:[]},au(c,{field:function(a){var d=j[g].geo_distance[h];return null==a?h:(delete j[g].geo_distance[h],h=a,j[g].geo_distance[a]=d,this)},point:function(a){if(null==a){return i}if(!ae(a)){throw new TypeError("Argument must be a GeoPoint")}return i=a,j[g].geo_distance[h]=a.toJSON(),this},addRange:function(a,d){return 0===arguments.length?j[g].geo_distance.ranges:(j[g].geo_distance.ranges.push({from:a,to:d}),this)},addUnboundedFrom:function(a){return null==a?j[g].geo_distance.ranges:(j[g].geo_distance.ranges.push({from:a}),this)},addUnboundedTo:function(a){return null==a?j[g].geo_distance.ranges:(j[g].geo_distance.ranges.push({to:a}),this)},unit:function(a){return null==a?j[g].geo_distance.unit:(a=a.toLowerCase(),("mi"===a||"km"===a)&&(j[g].geo_distance.unit=a),this)},distanceType:function(a){return null==a?j[g].geo_distance.distance_type:(a=a.toLowerCase(),("arc"===a||"plane"===a)&&(j[g].geo_distance.distance_type=a),this)},normalize:function(a){return null==a?j[g].geo_distance.normalize:(j[g].geo_distance.normalize=a,this)},valueField:function(a){return null==a?j[g].geo_distance.value_field:(j[g].geo_distance.value_field=a,this)},valueScript:function(a){return null==a?j[g].geo_distance.value_script:(j[g].geo_distance.value_script=a,this)},lang:function(a){return null==a?j[g].geo_distance.lang:(j[g].geo_distance.lang=a,this)},params:function(a){return null==a?j[g].geo_distance.params:(j[g].geo_distance.params=a,this)}})},W.HistogramFacet=function(e){var c=W.FacetMixin(e),f=c.toJSON();return f[e].histogram={},au(c,{field:function(a){return null==a?f[e].histogram.field:(f[e].histogram.field=a,this)},interval:function(a){return null==a?f[e].histogram.interval:(f[e].histogram.interval=a,this)},timeInterval:function(a){return null==a?f[e].histogram.time_interval:(f[e].histogram.time_interval=a,this)},from:function(a){return null==a?f[e].histogram.from:(f[e].histogram.from=a,this)},to:function(a){return null==a?f[e].histogram.to:(f[e].histogram.to=a,this)},valueField:function(a){return null==a?f[e].histogram.value_field:(f[e].histogram.value_field=a,this)},keyField:function(a){return null==a?f[e].histogram.key_field:(f[e].histogram.key_field=a,this)},valueScript:function(a){return null==a?f[e].histogram.value_script:(f[e].histogram.value_script=a,this)},keyScript:function(a){return null==a?f[e].histogram.key_script:(f[e].histogram.key_script=a,this)},lang:function(a){return null==a?f[e].histogram.lang:(f[e].histogram.lang=a,this)},params:function(a){return null==a?f[e].histogram.params:(f[e].histogram.params=a,this)},order:function(a){return null==a?f[e].histogram.order:(a=a.toLowerCase(),("key"===a||"count"===a||"total"===a)&&(f[e].histogram.order=a),this)}})},W.QueryFacet=function(e){var c=W.FacetMixin(e),f=c.toJSON();return au(c,{query:function(a){if(null==a){return f[e].query}if(!ak(a)){throw new TypeError("Argument must be a Query")}return f[e].query=a.toJSON(),this}})},W.RangeFacet=function(e){var c=W.FacetMixin(e),f=c.toJSON();return f[e].range={ranges:[]},au(c,{field:function(a){return null==a?f[e].range.field:(f[e].range.field=a,this)},keyField:function(a){return null==a?f[e].range.key_field:(f[e].range.key_field=a,this)},valueField:function(a){return null==a?f[e].range.value_field:(f[e].range.value_field=a,this)},valueScript:function(a){return null==a?f[e].range.value_script:(f[e].range.value_script=a,this)},keyScript:function(a){return null==a?f[e].range.key_script:(f[e].range.key_script=a,this)},lang:function(a){return null==a?f[e].range.lang:(f[e].range.lang=a,this)},params:function(a){return null==a?f[e].range.params:(f[e].range.params=a,this)},addRange:function(a,d){return 0===arguments.length?f[e].range.ranges:(f[e].range.ranges.push({from:a,to:d}),this)},addUnboundedFrom:function(a){return null==a?f[e].range.ranges:(f[e].range.ranges.push({from:a}),this)},addUnboundedTo:function(a){return null==a?f[e].range.ranges:(f[e].range.ranges.push({to:a}),this)}})},W.StatisticalFacet=function(e){var c=W.FacetMixin(e),f=c.toJSON();return f[e].statistical={},au(c,{field:function(a){return null==a?f[e].statistical.field:(f[e].statistical.field=a,this)},fields:function(a){if(null==a){return f[e].statistical.fields}if(!ar(a)){throw new TypeError("Argument must be an array")}return f[e].statistical.fields=a,this},script:function(a){return null==a?f[e].statistical.script:(f[e].statistical.script=a,this)},lang:function(a){return null==a?f[e].statistical.lang:(f[e].statistical.lang=a,this)},params:function(a){return null==a?f[e].statistical.params:(f[e].statistical.params=a,this)}})},W.TermStatsFacet=function(e){var c=W.FacetMixin(e),f=c.toJSON();return f[e].terms_stats={},au(c,{valueField:function(a){return null==a?f[e].terms_stats.value_field:(f[e].terms_stats.value_field=a,this)},keyField:function(a){return null==a?f[e].terms_stats.key_field:(f[e].terms_stats.key_field=a,this)},scriptField:function(a){return null==a?f[e].terms_stats.script_field:(f[e].terms_stats.script_field=a,this)},valueScript:function(a){return null==a?f[e].terms_stats.value_script:(f[e].terms_stats.value_script=a,this)},allTerms:function(a){return null==a?f[e].terms_stats.all_terms:(f[e].terms_stats.all_terms=a,this)},lang:function(a){return null==a?f[e].terms_stats.lang:(f[e].terms_stats.lang=a,this)},params:function(a){return null==a?f[e].terms_stats.params:(f[e].terms_stats.params=a,this)},size:function(a){return null==a?f[e].terms_stats.size:(f[e].terms_stats.size=a,this)},order:function(a){return null==a?f[e].terms_stats.order:(a=a.toLowerCase(),("count"===a||"term"===a||"reverse_count"===a||"reverse_term"===a||"total"===a||"reverse_total"===a||"min"===a||"reverse_min"===a||"max"===a||"reverse_max"===a||"mean"===a||"reverse_mean"===a)&&(f[e].terms_stats.order=a),this)}})},W.TermsFacet=function(e){var c=W.FacetMixin(e),f=c.toJSON();return f[e].terms={},au(c,{field:function(a){return null==a?f[e].terms.field:(f[e].terms.field=a,this)},fields:function(a){if(null==a){return f[e].terms.fields}if(!ar(a)){throw new TypeError("Argument must be an array")}return f[e].terms.fields=a,this},scriptField:function(a){return null==a?f[e].terms.script_field:(f[e].terms.script_field=a,this)},size:function(a){return null==a?f[e].terms.size:(f[e].terms.size=a,this)},shardSize:function(a){return null==a?f[e].terms.shard_size:(f[e].terms.shard_size=a,this)},order:function(a){return null==a?f[e].terms.order:(a=a.toLowerCase(),("count"===a||"term"===a||"reverse_count"===a||"reverse_term"===a)&&(f[e].terms.order=a),this)},allTerms:function(a){return null==a?f[e].terms.all_terms:(f[e].terms.all_terms=a,this)},exclude:function(a){if(null==f[e].terms.exclude&&(f[e].terms.exclude=[]),null==a){return f[e].terms.exclude}if(ap(a)){f[e].terms.exclude.push(a)}else{if(!ar(a)){throw new TypeError("Argument must be string or array")}f[e].terms.exclude=a}return this},regex:function(a){return null==a?f[e].terms.regex:(f[e].terms.regex=a,this)},regexFlags:function(a){return null==a?f[e].terms.regex_flags:(f[e].terms.regex_flags=a,this)},script:function(a){return null==a?f[e].terms.script:(f[e].terms.script=a,this)},lang:function(a){return null==a?f[e].terms.lang:(f[e].terms.lang=a,this)},params:function(a){return null==a?f[e].terms.params:(f[e].terms.params=a,this)},executionHint:function(a){return null==a?f[e].terms.execution_hint:(f[e].terms.execution_hint=a,this)}})},W.AvgAggregation=function(d){var c=W.MetricsAggregationMixin(d,"avg");c.toJSON();return c},W.CardinalityAggregation=function(e){var c=W.MetricsAggregationMixin(e,"cardinality"),f=c.toJSON();return delete c.scriptValuesSorted,au(c,{rehash:function(a){return null==a?f[e].cardinality.rehash:(f[e].cardinality.rehash=a,this)},precisionThreshold:function(a){return null==a?f[e].cardinality.precision_threshold:(f[e].cardinality.precision_threshold=a,this)}})},W.DateHistogramAggregation=function(e){var c=W.AggregationMixin(e),f=c.toJSON();return f[e].date_histogram={},au(c,{field:function(a){return null==a?f[e].date_histogram.field:(f[e].date_histogram.field=a,this)},script:function(a){return null==a?f[e].date_histogram.script:(f[e].date_histogram.script=a,this)},lang:function(a){return null==a?f[e].date_histogram.lang:(f[e].date_histogram.lang=a,this)},timeZone:function(a){return null==a?f[e].date_histogram.time_zone:(f[e].date_histogram.time_zone=a,this)},preZone:function(a){return null==a?f[e].date_histogram.pre_zone:(f[e].date_histogram.pre_zone=a,this)},postZone:function(a){return null==a?f[e].date_histogram.post_zone:(f[e].date_histogram.post_zone=a,this)},preOffset:function(a){return null==a?f[e].date_histogram.pre_offset:(f[e].date_histogram.pre_offset=a,this)},postOffset:function(a){return null==a?f[e].date_histogram.post_offset:(f[e].date_histogram.post_offset=a,this)},extendedBounds:function(a,g){var d;return null==a&&null==g?f[e].date_histogram.extended_bounds:(d={},null!=a&&(d.min=a),null!=g&&(d.max=g),f[e].date_histogram.extended_bounds=d,this)},interval:function(a){return null==a?f[e].date_histogram.interval:(f[e].date_histogram.interval=a,this)},format:function(a){return null==a?f[e].date_histogram.format:(f[e].date_histogram.format=a,this)},keyed:function(a){return null==a?f[e].date_histogram.keyed:(f[e].date_histogram.keyed=a,this)},scriptValuesSorted:function(a){return null==a?f[e].date_histogram.script_values_sorted:(f[e].date_histogram.script_values_sorted=a,this)},preZoneAdjustLargeInterval:function(a){return null==a?f[e].date_histogram.pre_zone_adjust_large_interval:(f[e].date_histogram.pre_zone_adjust_large_interval=a,this)},minDocCount:function(a){return null==a?f[e].date_histogram.min_doc_count:(f[e].date_histogram.min_doc_count=a,this)},params:function(a){return null==a?f[e].date_histogram.params:(f[e].date_histogram.params=a,this)},order:function(a,d){return null==a?f[e].date_histogram.order:(null==d&&(d="desc"),d=d.toLowerCase(),"asc"!==d&&"desc"!==d&&(d="desc"),f[e].date_histogram.order={},f[e].date_histogram.order[a]=d,this)}})},W.DateRangeAggregation=function(e){var c=W.AggregationMixin(e),f=c.toJSON();return f[e].date_range={},au(c,{field:function(a){return null==a?f[e].date_range.field:(f[e].date_range.field=a,this)},script:function(a){return null==a?f[e].date_range.script:(f[e].date_range.script=a,this)},lang:function(a){return null==a?f[e].date_range.lang:(f[e].date_range.lang=a,this)},format:function(a){return null==a?f[e].date_range.format:(f[e].date_range.format=a,this)},range:function(a,h,g){var d={};return null==f[e].date_range.ranges&&(f[e].date_range.ranges=[]),null==a&&null==h?f[e].date_range.ranges:(null!=a&&(d.from=a),null!=h&&(d.to=h),null!=g&&(d.key=g),f[e].date_range.ranges.push(d),this)},keyed:function(a){return null==a?f[e].date_range.keyed:(f[e].date_range.keyed=a,this)},scriptValuesSorted:function(a){return null==a?f[e].date_range.script_values_sorted:(f[e].date_range.script_values_sorted=a,this)},params:function(a){return null==a?f[e].date_range.params:(f[e].date_range.params=a,this)}})},W.ExtendedStatsAggregation=function(d){var c=W.MetricsAggregationMixin(d,"extended_stats");c.toJSON();return c},W.FilterAggregation=function(e){var c=W.AggregationMixin(e),f=c.toJSON();return au(c,{filter:function(a){if(null==a){return f[e].filter}if(!ai(a)){throw new TypeError("Argument must be a Filter")}return f[e].filter=a.toJSON(),this}})},W.GeoDistanceAggregation=function(f){var c=W.AggregationMixin(f),h=W.GeoPoint([0,0]),g=c.toJSON();return g[f].geo_distance={},au(c,{field:function(a){return null==a?g[f].geo_distance.field:(g[f].geo_distance.field=a,this)},unit:function(a){return null==a?g[f].geo_distance.unit:(("in"===a||"yd"===a||"ft"===a||"km"===a||"NM"===a||"mm"===a||"cm"===a||"mi"===a||"m"===a)&&(g[f].geo_distance.unit=a),this)},distanceType:function(a){return null==a?g[f].geo_distance.distance_type:(a=a.toLowerCase(),("plane"===a||"arc"===a||"sloppy_arc"===a||"factor"===a)&&(g[f].geo_distance.distance_type=a),this)},origin:function(a){if(null==a){return h}if(!ae(a)){throw new TypeError("Argument must be a GeoPoint")}return h=a,g[f].geo_distance.origin=a.toJSON(),this},point:function(a){if(null==a){return h}if(!ae(a)){throw new TypeError("Argument must be a GeoPoint")}return h=a,g[f].geo_distance.point=a.toJSON(),this},center:function(a){if(null==a){return h}if(!ae(a)){throw new TypeError("Argument must be a GeoPoint")}return h=a,g[f].geo_distance.center=a.toJSON(),this},range:function(a,j,i){var e={};return null==g[f].geo_distance.ranges&&(g[f].geo_distance.ranges=[]),null==a&&null==j?g[f].geo_distance.ranges:(null!=a&&(e.from=a),null!=j&&(e.to=j),null!=i&&(e.key=i),g[f].geo_distance.ranges.push(e),this)},keyed:function(a){return null==a?g[f].geo_distance.keyed:(g[f].geo_distance.keyed=a,this)}})},W.GeoHashGridAggregation=function(e){var c=W.AggregationMixin(e),f=c.toJSON();return f[e].geohash_grid={},au(c,{field:function(a){return null==a?f[e].geohash_grid.field:(f[e].geohash_grid.field=a,this)},precision:function(a){return null==a?f[e].geohash_grid.precision:(f[e].geohash_grid.precision=a,this)},size:function(a){return null==a?f[e].geohash_grid.size:(f[e].geohash_grid.size=a,this)},shardSize:function(a){return null==a?f[e].geohash_grid.shard_size:(f[e].geohash_grid.shard_size=a,this)}})},W.GlobalAggregation=function(e){var d=W.AggregationMixin(e),f=d.toJSON();return f[e].global={},d},W.HistogramAggregation=function(e){var c=W.AggregationMixin(e),f=c.toJSON();return f[e].histogram={},au(c,{field:function(a){return null==a?f[e].histogram.field:(f[e].histogram.field=a,this)},script:function(a){return null==a?f[e].histogram.script:(f[e].histogram.script=a,this)},lang:function(a){return null==a?f[e].histogram.lang:(f[e].histogram.lang=a,this)},format:function(a){return null==a?f[e].histogram.format:(f[e].histogram.format=a,this)},extendedBounds:function(a,g){var d;return null==a&&null==g?f[e].histogram.extended_bounds:(d={},null!=a&&(d.min=a),null!=g&&(d.max=g),f[e].histogram.extended_bounds=d,this)},interval:function(a){return null==a?f[e].histogram.interval:(f[e].histogram.interval=a,this)},minDocCount:function(a){return null==a?f[e].histogram.min_doc_count:(f[e].histogram.min_doc_count=a,this)},keyed:function(a){return null==a?f[e].histogram.keyed:(f[e].histogram.keyed=a,this)},scriptValuesSorted:function(a){return null==a?f[e].histogram.script_values_sorted:(f[e].histogram.script_values_sorted=a,this)},params:function(a){return null==a?f[e].histogram.params:(f[e].histogram.params=a,this)},order:function(a,d){return null==a?f[e].histogram.order:(null==d&&(d="desc"),d=d.toLowerCase(),"asc"!==d&&"desc"!==d&&(d="desc"),f[e].histogram.order={},f[e].histogram.order[a]=d,this)}})},W.IPv4RangeAggregation=function(e){var c=W.AggregationMixin(e),f=c.toJSON();return f[e].ip_range={},au(c,{field:function(a){return null==a?f[e].ip_range.field:(f[e].ip_range.field=a,this)},script:function(a){return null==a?f[e].ip_range.script:(f[e].ip_range.script=a,this)},lang:function(a){return null==a?f[e].ip_range.lang:(f[e].ip_range.lang=a,this)},range:function(a,j,i,h){var d={};return null==f[e].ip_range.ranges&&(f[e].ip_range.ranges=[]),null==a&&null==j&&null==i?f[e].ip_range.ranges:(null!=a&&(d.from=a),null!=j&&(d.to=j),null!=i&&(d.mask=i),null!=h&&(d.key=h),f[e].ip_range.ranges.push(d),this)},keyed:function(a){return null==a?f[e].ip_range.keyed:(f[e].ip_range.keyed=a,this)},scriptValuesSorted:function(a){return null==a?f[e].ip_range.script_values_sorted:(f[e].ip_range.script_values_sorted=a,this)},params:function(a){return null==a?f[e].ip_range.params:(f[e].ip_range.params=a,this)}})},W.MaxAggregation=function(d){var c=W.MetricsAggregationMixin(d,"max");c.toJSON();return c},W.MinAggregation=function(d){var c=W.MetricsAggregationMixin(d,"min");c.toJSON();return c},W.MissingAggregation=function(e){var c=W.AggregationMixin(e),f=c.toJSON();return f[e].missing={},au(c,{field:function(a){return null==a?f[e].missing.field:(f[e].missing.field=a,this)}})},W.NestedAggregation=function(e){var c=W.AggregationMixin(e),f=c.toJSON();return f[e].nested={},au(c,{path:function(a){return null==a?f[e].nested.path:(f[e].nested.path=a,this)}})},W.PercentilesAggregation=function(e){var c=W.MetricsAggregationMixin(e,"percentiles"),f=c.toJSON();return au(c,{keyed:function(a){return null==a?f[e].percentiles.keyed:(f[e].percentiles.keyed=a,this)},percents:function(a){if(null==a){return f[e].percentiles.percents}if(!ar(a)){throw new TypeError("Percents must be an array of doubles")}return f[e].percentiles.percents=a,this},percent:function(a){return null==f[e].percentiles.percents&&(f[e].percentiles.percents=[]),null==a?f[e].percentiles.percents:(f[e].percentiles.percents.push(a),this)},compression:function(a){return null==a?f[e].percentiles.compression:(f[e].percentiles.compression=a,this)}})},W.RangeAggregation=function(e){var c=W.AggregationMixin(e),f=c.toJSON();return f[e].range={},au(c,{field:function(a){return null==a?f[e].range.field:(f[e].range.field=a,this)},script:function(a){return null==a?f[e].range.script:(f[e].range.script=a,this)},lang:function(a){return null==a?f[e].range.lang:(f[e].range.lang=a,this)},range:function(a,h,g){var d={};return null==f[e].range.ranges&&(f[e].range.ranges=[]),null==a&&null==h?f[e].range.ranges:(null!=a&&(d.from=a),null!=h&&(d.to=h),null!=g&&(d.key=g),f[e].range.ranges.push(d),this)},keyed:function(a){return null==a?f[e].range.keyed:(f[e].range.keyed=a,this)},scriptValuesSorted:function(a){return null==a?f[e].range.script_values_sorted:(f[e].range.script_values_sorted=a,this)},params:function(a){return null==a?f[e].range.params:(f[e].range.params=a,this)}})},W.SignificantTermsAggregation=function(e){var c=W.AggregationMixin(e),f=c.toJSON();return f[e].significant_terms={},au(c,{field:function(a){return null==a?f[e].significant_terms.field:(f[e].significant_terms.field=a,this)},format:function(a){return null==a?f[e].significant_terms.format:(f[e].significant_terms.format=a,this)},include:function(a,d){return null==f[e].significant_terms.include&&(f[e].significant_terms.include={}),null==a?f[e].significant_terms.include:(f[e].significant_terms.include.pattern=a,null!=d&&(f[e].significant_terms.include.flags=d),this)},exclude:function(a,d){return null==f[e].significant_terms.exclude&&(f[e].significant_terms.exclude={}),null==a?f[e].significant_terms.exclude:(f[e].significant_terms.exclude.pattern=a,null!=d&&(f[e].significant_terms.exclude.flags=d),this)},executionHint:function(a){return null==a?f[e].significant_terms.execution_hint:(a=a.toLowerCase(),("map"===a||"ordinals"===a)&&(f[e].significant_terms.execution_hint=a),this)},size:function(a){return null==a?f[e].significant_terms.size:(f[e].significant_terms.size=a,this)},shardSize:function(a){return null==a?f[e].significant_terms.shard_size:(f[e].significant_terms.shard_size=a,this)},minDocCount:function(a){return null==a?f[e].significant_terms.min_doc_count:(f[e].significant_terms.min_doc_count=a,this)}})},W.StatsAggregation=function(d){var c=W.MetricsAggregationMixin(d,"stats");c.toJSON();return c},W.SumAggregation=function(d){var c=W.MetricsAggregationMixin(d,"sum");c.toJSON();return c},W.TermsAggregation=function(e){var c=W.AggregationMixin(e),f=c.toJSON();return f[e].terms={},au(c,{field:function(a){return null==a?f[e].terms.field:(f[e].terms.field=a,this)},script:function(a){return null==a?f[e].terms.script:(f[e].terms.script=a,this)},lang:function(a){return null==a?f[e].terms.lang:(f[e].terms.lang=a,this)},valueType:function(a){return null==a?f[e].terms.value_type:(a=a.toLowerCase(),("string"===a||"double"===a||"float"===a||"long"===a||"integer"===a||"short"===a||"byte"===a)&&(f[e].terms.value_type=a),this)},format:function(a){return null==a?f[e].terms.format:(f[e].terms.format=a,this)},include:function(a,d){return null==f[e].terms.include&&(f[e].terms.include={}),null==a?f[e].terms.include:(f[e].terms.include.pattern=a,null!=d&&(f[e].terms.include.flags=d),this)},exclude:function(a,d){return null==f[e].terms.exclude&&(f[e].terms.exclude={}),null==a?f[e].terms.exclude:(f[e].terms.exclude.pattern=a,null!=d&&(f[e].terms.exclude.flags=d),this)},executionHint:function(a){return null==a?f[e].terms.execution_hint:(a=a.toLowerCase(),("map"===a||"ordinals"===a)&&(f[e].terms.execution_hint=a),this)},scriptValuesUnique:function(a){return null==a?f[e].terms.script_values_unique:(f[e].terms.script_values_unique=a,this)},size:function(a){return null==a?f[e].terms.size:(f[e].terms.size=a,this)},shardSize:function(a){return null==a?f[e].terms.shard_size:(f[e].terms.shard_size=a,this)},minDocCount:function(a){return null==a?f[e].terms.min_doc_count:(f[e].terms.min_doc_count=a,this)},params:function(a){return null==a?f[e].terms.params:(f[e].terms.params=a,this)},order:function(a,d){return null==a?f[e].terms.order:(null==d&&(d="desc"),d=d.toLowerCase(),"asc"!==d&&"desc"!==d&&(d="desc"),f[e].terms.order={},f[e].terms.order[a]=d,this)}})},W.TopHitsAggregation=function(e){var c=W.MetricsAggregationMixin(e,"top_hits"),f=c.toJSON();return au(c,{from:function(a){return null===a?f[e].top_hits.from:(f[e].top_hits.from=a,this)},size:function(a){return null===a?f[e].top_hits.size:(f[e].top_hits.size=a,this)},sort:function(a){return null===a?f[e].top_hits.sort:(f[e].top_hits.sort=a,this)},trackScores:function(a){return null===a?f[e].top_hits.track_scores:(f[e].top_hits.track_scores=a,this)},version:function(a){return null===a?f[e].top_hits.version:(f[e].top_hits.version=a,this)},explain:function(a){return null===a?f[e].top_hits.explain:(f[e].top_hits.explain=a,this)},highlight:function(a){if(null===a){return f[e].top_hits.highlight}if(!aa(a)){throw new TypeError("Argument must be a Highlight object")}return f[e].top_hits.highlight=a.toJSON(),this},scriptField:function(a){if(null===a){return f[e].top_hits.script_fields}if(void 0===f[e].top_hits.script_fields&&(f[e].top_hits.script_fields={}),!af(a)){throw new TypeError("Argument must be a ScriptField")}return au(f[e].top_hits.script_fields,a.toJSON()),this},fieldDataFields:function(a){return null===a?f[e].top_hits.fielddata_fields:(f[e].top_hits.fielddata_fields=a,this)},source:function(a,d){if(void 0===a&&void 0===d){return f[e].top_hits._source}if(!ar(a)&&!ap(a)&&!an(a)){throw new TypeError("Argument includes must be a string, an array, or a boolean")}if(void 0!==d&&!ar(d)&&!ap(d)){throw new TypeError("Argument excludes must be a string or an array")}return an(a)?f[e].top_hits._source=a:(f[e].top_hits._source={includes:a},void 0!==d&&(f[e].top_hits._source=d)),this}})},W.ValueCountAggregation=function(e){var c=W.MetricsAggregationMixin(e,"value_count"),f=c.toJSON();return delete c.scriptValuesSorted,au(c,{scriptValuesUnique:function(a){return null==a?f[e].value_count.script_values_unique:(f[e].value_count.script_values_unique=a,this)}})},W.AndFilter=function(e){var c,j,i=W.FilterMixin("and"),h=i.toJSON();if(h.and.filters=[],ai(e)){h.and.filters.push(e.toJSON())}else{if(!ar(e)){throw new TypeError("Argument must be a Filter or Array of Filters")}for(c=0,j=e.length;j>c;c++){if(!ai(e[c])){throw new TypeError("Array must contain only Filter objects")}h.and.filters.push(e[c].toJSON())}}return au(i,{filters:function(f){var d,g;if(null==f){return h.and.filters}if(ai(f)){h.and.filters.push(f.toJSON())}else{if(!ar(f)){throw new TypeError("Argument must be a Filter or an Array of Filters")}for(h.and.filters=[],d=0,g=f.length;g>d;d++){if(!ai(f[d])){throw new TypeError("Array must contain only Filter objects")}h.and.filters.push(f[d].toJSON())}}return this}})},W.BoolFilter=function(){var d=W.FilterMixin("bool"),c=d.toJSON();return au(d,{must:function(b){var f,e;if(null==c.bool.must&&(c.bool.must=[]),null==b){return c.bool.must}if(ai(b)){c.bool.must.push(b.toJSON())}else{if(!ar(b)){throw new TypeError("Argument must be a Filter or array of Filters")}for(c.bool.must=[],f=0,e=b.length;e>f;f++){if(!ai(b[f])){throw new TypeError("Argument must be an array of Filters")}c.bool.must.push(b[f].toJSON())}}return this},mustNot:function(b){var f,e;if(null==c.bool.must_not&&(c.bool.must_not=[]),null==b){return c.bool.must_not}if(ai(b)){c.bool.must_not.push(b.toJSON())}else{if(!ar(b)){throw new TypeError("Argument must be a Filter or array of Filters")}for(c.bool.must_not=[],f=0,e=b.length;e>f;f++){if(!ai(b[f])){throw new TypeError("Argument must be an array of Filters")}c.bool.must_not.push(b[f].toJSON())}}return this},should:function(b){var f,e;if(null==c.bool.should&&(c.bool.should=[]),null==b){return c.bool.should}if(ai(b)){c.bool.should.push(b.toJSON())}else{if(!ar(b)){throw new TypeError("Argument must be a Filter or array of Filters")}for(c.bool.should=[],f=0,e=b.length;e>f;f++){if(!ai(b[f])){throw new TypeError("Argument must be an array of Filters")}c.bool.should.push(b[f].toJSON())}}return this}})},W.ExistsFilter=function(e){var c=W.FilterMixin("exists"),f=c.toJSON();return f.exists.field=e,au(c,{field:function(b){return null==b?f.exists.field:(f.exists.field=b,this)}})},W.GeoBboxFilter=function(e){var c=W.FilterMixin("geo_bounding_box"),f=c.toJSON();return f.geo_bounding_box[e]={},au(c,{field:function(a){var d=f.geo_bounding_box[e];return null==a?e:(delete f.geo_bounding_box[e],e=a,f.geo_bounding_box[a]=d,this)},topLeft:function(a){if(null==a){return f.geo_bounding_box[e].top_left}if(!ae(a)){throw new TypeError("Argument must be a GeoPoint")}return f.geo_bounding_box[e].top_left=a.toJSON(),this},bottomRight:function(a){if(null==a){return f.geo_bounding_box[e].bottom_right}if(!ae(a)){throw new TypeError("Argument must be a GeoPoint")}return f.geo_bounding_box[e].bottom_right=a.toJSON(),this},type:function(b){return null==b?f.geo_bounding_box.type:(b=b.toLowerCase(),("memory"===b||"indexed"===b)&&(f.geo_bounding_box.type=b),this)},normalize:function(b){return null==b?f.geo_bounding_box.normalize:(f.geo_bounding_box.normalize=b,this)}})},W.GeoDistanceFilter=function(e){var c=W.FilterMixin("geo_distance"),f=c.toJSON();return f.geo_distance[e]=[0,0],au(c,{field:function(a){var d=f.geo_distance[e];return null==a?e:(delete f.geo_distance[e],e=a,f.geo_distance[a]=d,this)},distance:function(b){if(null==b){return f.geo_distance.distance}if(!ao(b)){throw new TypeError("Argument must be a numeric value")}return f.geo_distance.distance=b,this},unit:function(b){return null==b?f.geo_distance.unit:(b=b.toLowerCase(),("mi"===b||"km"===b)&&(f.geo_distance.unit=b),this)},point:function(a){if(null==a){return f.geo_distance[e]}if(!ae(a)){throw new TypeError("Argument must be a GeoPoint")}return f.geo_distance[e]=a.toJSON(),this},distanceType:function(b){return null==b?f.geo_distance.distance_type:(b=b.toLowerCase(),("arc"===b||"plane"===b)&&(f.geo_distance.distance_type=b),this)},normalize:function(b){return null==b?f.geo_distance.normalize:(f.geo_distance.normalize=b,this)},optimizeBbox:function(b){return null==b?f.geo_distance.optimize_bbox:(b=b.toLowerCase(),("memory"===b||"indexed"===b||"none"===b)&&(f.geo_distance.optimize_bbox=b),this)}})},W.GeoDistanceRangeFilter=function(e){var c=W.FilterMixin("geo_distance_range"),f=c.toJSON();return f.geo_distance_range[e]=[0,0],au(c,{field:function(a){var d=f.geo_distance_range[e];return null==a?e:(delete f.geo_distance_range[e],e=a,f.geo_distance_range[a]=d,this)},from:function(b){if(null==b){return f.geo_distance_range.from}if(!ao(b)){throw new TypeError("Argument must be a numeric value")}return f.geo_distance_range.from=b,this},to:function(b){if(null==b){return f.geo_distance_range.to}if(!ao(b)){throw new TypeError("Argument must be a numeric value")}return f.geo_distance_range.to=b,this},includeLower:function(b){return null==b?f.geo_distance_range.include_lower:(f.geo_distance_range.include_lower=b,this)},includeUpper:function(b){return null==b?f.geo_distance_range.include_upper:(f.geo_distance_range.include_upper=b,this)},gt:function(b){if(null==b){return f.geo_distance_range.gt}if(!ao(b)){throw new TypeError("Argument must be a numeric value")}return f.geo_distance_range.gt=b,this},gte:function(b){if(null==b){return f.geo_distance_range.gte}if(!ao(b)){throw new TypeError("Argument must be a numeric value")}return f.geo_distance_range.gte=b,this},lt:function(b){if(null==b){return f.geo_distance_range.lt}if(!ao(b)){throw new TypeError("Argument must be a numeric value")}return f.geo_distance_range.lt=b,this},lte:function(b){if(null==b){return f.geo_distance_range.lte}if(!ao(b)){throw new TypeError("Argument must be a numeric value")}return f.geo_distance_range.lte=b,this},unit:function(b){return null==b?f.geo_distance_range.unit:(b=b.toLowerCase(),("mi"===b||"km"===b)&&(f.geo_distance_range.unit=b),this)},point:function(a){if(null==a){return f.geo_distance_range[e]}if(!ae(a)){throw new TypeError("Argument must be a GeoPoint")}return f.geo_distance_range[e]=a.toJSON(),this},distanceType:function(b){return null==b?f.geo_distance_range.distance_type:(b=b.toLowerCase(),("arc"===b||"plane"===b)&&(f.geo_distance_range.distance_type=b),this)},normalize:function(b){return null==b?f.geo_distance_range.normalize:(f.geo_distance_range.normalize=b,this)},optimizeBbox:function(b){return null==b?f.geo_distance_range.optimize_bbox:(b=b.toLowerCase(),("memory"===b||"indexed"===b||"none"===b)&&(f.geo_distance_range.optimize_bbox=b),this)}})},W.GeoPolygonFilter=function(e){var c=W.FilterMixin("geo_polygon"),f=c.toJSON();return f.geo_polygon[e]={points:[]},au(c,{field:function(a){var d=f.geo_polygon[e];return null==a?e:(delete f.geo_polygon[e],e=a,f.geo_polygon[a]=d,this)},points:function(a){var g,d;if(null==a){return f.geo_polygon[e].points}if(ae(a)){f.geo_polygon[e].points.push(a.toJSON())}else{if(!ar(a)){throw new TypeError("Argument must be a GeoPoint or Array of GeoPoints")}for(f.geo_polygon[e].points=[],g=0,d=a.length;d>g;g++){if(!ae(a[g])){throw new TypeError("Argument must be Array of GeoPoints")}f.geo_polygon[e].points.push(a[g].toJSON())}}return this},normalize:function(b){return null==b?f.geo_polygon.normalize:(f.geo_polygon.normalize=b,this)}})},W.GeoShapeFilter=function(e){var c=W.FilterMixin("geo_shape"),f=c.toJSON();return f.geo_shape[e]={},au(c,{field:function(a){var d=f.geo_shape[e];return null==a?e:(delete f.geo_shape[e],e=a,f.geo_shape[a]=d,this)},shape:function(a){return null==a?f.geo_shape[e].shape:(null!=f.geo_shape[e].indexed_shape&&delete f.geo_shape[e].indexed_shape,f.geo_shape[e].shape=a.toJSON(),this)},indexedShape:function(a){return null==a?f.geo_shape[e].indexed_shape:(null!=f.geo_shape[e].shape&&delete f.geo_shape[e].shape,f.geo_shape[e].indexed_shape=a.toJSON(),this)},relation:function(a){return null==a?f.geo_shape[e].relation:(a=a.toLowerCase(),("intersects"===a||"disjoint"===a||"within"===a)&&(f.geo_shape[e].relation=a),this)},strategy:function(a){return null==a?f.geo_shape[e].strategy:(a=a.toLowerCase(),("recursive"===a||"term"===a)&&(f.geo_shape[e].strategy=a),this)}})},W.HasChildFilter=function(f,c){var h=W.FilterMixin("has_child"),g=h.toJSON();if(ak(f)){g.has_child.query=f.toJSON()}else{if(ai(f)){g.has_child.filter=f.toJSON()}else{if(null!=f){throw new TypeError("Argument must be query or filter")}}}return g.has_child.type=c,au(h,{query:function(b){if(null==b){return g.has_child.query}if(!ak(b)){throw new TypeError("Argument must be a Query object")}return g.has_child.query=b.toJSON(),this},filter:function(b){if(null==b){return g.has_child.filter}if(!ai(b)){throw new TypeError("Argument must be a Filter object")}return g.has_child.filter=b.toJSON(),this},type:function(b){return null==b?g.has_child.type:(g.has_child.type=b,this)},shortCircuitCutoff:function(b){return null==b?g.has_child.short_circuit_cutoff:(g.has_child.short_circuit_cutoff=b,this)},scope:function(){return this}})},W.HasParentFilter=function(f,c){var h=W.FilterMixin("has_parent"),g=h.toJSON();if(ak(f)){g.has_parent.query=f.toJSON()}else{if(ai(f)){g.has_parent.filter=f.toJSON()}else{if(null!=f){throw new TypeError("Argument must be query or filter")}}}return g.has_parent.parent_type=c,au(h,{query:function(b){if(null==b){return g.has_parent.query}if(!ak(b)){throw new TypeError("Argument must be a Query object")}return g.has_parent.query=b.toJSON(),this},filter:function(b){if(null==b){return g.has_parent.filter}if(!ai(b)){throw new TypeError("Argument must be a Filter object")}return g.has_parent.filter=b.toJSON(),this},parentType:function(b){return null==b?g.has_parent.parent_type:(g.has_parent.parent_type=b,this)},scope:function(){return this}})},W.IdsFilter=function(e){var c=W.FilterMixin("ids"),f=c.toJSON();if(ap(e)){f.ids.values=[e]}else{if(!ar(e)){throw new TypeError("Argument must be a string or an array")}f.ids.values=e}return au(c,{values:function(b){if(null==b){return f.ids.values}if(ap(b)){f.ids.values.push(b)}else{if(!ar(b)){throw new TypeError("Argument must be a string or an array")}f.ids.values=b}return this},type:function(b){if(null==f.ids.type&&(f.ids.type=[]),null==b){return f.ids.type}if(ap(b)){f.ids.type.push(b)}else{if(!ar(b)){throw new TypeError("Argument must be a string or an array")}f.ids.type=b}return this}})},W.IndicesFilter=function(e,c){if(!ai(e)){throw new TypeError("Argument must be a Filter")}var h=W.FilterMixin("indices"),g=h.toJSON();if(g.indices.filter=e.toJSON(),ap(c)){g.indices.indices=[c]}else{if(!ar(c)){throw new TypeError("Argument must be a string or array")}g.indices.indices=c}return au(h,{indices:function(b){if(null==b){return g.indices.indices}if(ap(b)){g.indices.indices.push(b)}else{if(!ar(b)){throw new TypeError("Argument must be a string or array")}g.indices.indices=b}return this},filter:function(b){if(null==b){return g.indices.filter}if(!ai(b)){throw new TypeError("Argument must be a Filter")}return g.indices.filter=b.toJSON(),this},noMatchFilter:function(b){if(null==b){return g.indices.no_match_filter}if(ap(b)){b=b.toLowerCase(),("none"===b||"all"===b)&&(g.indices.no_match_filter=b)}else{if(!ai(b)){throw new TypeError("Argument must be string or Filter")}g.indices.no_match_filter=b.toJSON()}return this}})},W.LimitFilter=function(e){var c=W.FilterMixin("limit"),f=c.toJSON();return f.limit.value=e,au(c,{value:function(b){if(null==b){return f.limit.value}if(!ao(b)){throw new TypeError("Argument must be a numeric value")}return f.limit.value=b,this}})},W.MatchAllFilter=function(){return W.FilterMixin("match_all")},W.MissingFilter=function(e){var c=W.FilterMixin("missing"),f=c.toJSON();return f.missing.field=e,au(c,{field:function(b){return null==b?f.missing.field:(f.missing.field=b,this)},existence:function(b){return null==b?f.missing.existence:(f.missing.existence=b,this)},nullValue:function(b){return null==b?f.missing.null_value:(f.missing.null_value=b,this)}})},W.NestedFilter=function(e){var c=W.FilterMixin("nested"),f=c.toJSON();return f.nested.path=e,au(c,{path:function(b){return null==b?f.nested.path:(f.nested.path=b,this)},query:function(b){if(null==b){return f.nested.query}if(!ak(b)){throw new TypeError("Argument must be a Query object")}return f.nested.query=b.toJSON(),this},filter:function(b){if(null==b){return f.nested.filter}if(!ai(b)){throw new TypeError("Argument must be a Filter object")}return f.nested.filter=b.toJSON(),this},boost:function(b){return null==b?f.nested.boost:(f.nested.boost=b,this)},join:function(b){return null==b?f.nested.join:(f.nested.join=b,this)},scope:function(){return this}})},W.NotFilter=function(e){if(!ai(e)){throw new TypeError("Argument must be a Filter")}var c=W.FilterMixin("not"),f=c.toJSON();return f.not=e.toJSON(),au(c,{filter:function(b){if(null==b){return f.not}if(!ai(b)){throw new TypeError("Argument must be a Filter")}return f.not=b.toJSON(),this}})},W.NumericRangeFilter=function(e){var c=W.FilterMixin("numeric_range"),f=c.toJSON();return f.numeric_range[e]={},au(c,{field:function(a){var d=f.numeric_range[e];return null==a?e:(delete f.numeric_range[e],e=a,f.numeric_range[e]=d,this)},from:function(a){if(null==a){return f.numeric_range[e].from}if(!ao(a)){throw new TypeError("Argument must be a numeric value")}return f.numeric_range[e].from=a,this},to:function(a){if(null==a){return f.numeric_range[e].to}if(!ao(a)){throw new TypeError("Argument must be a numeric value")}return f.numeric_range[e].to=a,this},includeLower:function(a){return null==a?f.numeric_range[e].include_lower:(f.numeric_range[e].include_lower=a,this)},includeUpper:function(a){return null==a?f.numeric_range[e].include_upper:(f.numeric_range[e].include_upper=a,this)},gt:function(a){if(null==a){return f.numeric_range[e].gt}if(!ao(a)){throw new TypeError("Argument must be a numeric value")}return f.numeric_range[e].gt=a,this},gte:function(a){if(null==a){return f.numeric_range[e].gte}if(!ao(a)){throw new TypeError("Argument must be a numeric value")}return f.numeric_range[e].gte=a,this},lt:function(a){if(null==a){return f.numeric_range[e].lt}if(!ao(a)){throw new TypeError("Argument must be a numeric value")}return f.numeric_range[e].lt=a,this},lte:function(a){if(null==a){return f.numeric_range[e].lte}if(!ao(a)){throw new TypeError("Argument must be a numeric value")}return f.numeric_range[e].lte=a,this}})},W.OrFilter=function(e){var c,j,i=W.FilterMixin("or"),h=i.toJSON();if(h.or.filters=[],ai(e)){h.or.filters.push(e.toJSON())}else{if(!ar(e)){throw new TypeError("Argument must be a Filter or array of Filters")}for(c=0,j=e.length;j>c;c++){if(!ai(e[c])){throw new TypeError("Argument must be array of Filters")}h.or.filters.push(e[c].toJSON())}}return au(i,{filters:function(f){var d,g;if(null==f){return h.or.filters}if(ai(f)){h.or.filters.push(f.toJSON())}else{if(!ar(f)){throw new TypeError("Argument must be a Filter or array of Filters")}for(h.or.filters=[],d=0,g=f.length;g>d;d++){if(!ai(f[d])){throw new TypeError("Argument must be an array of Filters")}h.or.filters.push(f[d].toJSON())}}return this}})},W.PrefixFilter=function(f,c){var h=W.FilterMixin("prefix"),g=h.toJSON();return g.prefix[f]=c,au(h,{field:function(a){var d=g.prefix[f];return null==a?f:(delete g.prefix[f],f=a,g.prefix[f]=d,this)},prefix:function(a){return null==a?g.prefix[f]:(g.prefix[f]=a,this)}})},W.QueryFilter=function(e){if(!ak(e)){throw new TypeError("Argument must be a Query")}var c=W.FilterMixin("fquery"),f=c.toJSON();return f.fquery.query=e.toJSON(),au(c,{query:function(b){if(null==b){return f.fquery.query}if(!ak(b)){throw new TypeError("Argument must be a Query")}return f.fquery.query=b.toJSON(),this}})},W.RangeFilter=function(e){var c=W.FilterMixin("range"),f=c.toJSON();return f.range[e]={},au(c,{field:function(a){var d=f.range[e];return null==a?e:(delete f.range[e],e=a,f.range[a]=d,this)},from:function(a){return null==a?f.range[e].from:(f.range[e].from=a,this)},to:function(a){return null==a?f.range[e].to:(f.range[e].to=a,this)},includeLower:function(a){return null==a?f.range[e].include_lower:(f.range[e].include_lower=a,this)},includeUpper:function(a){return null==a?f.range[e].include_upper:(f.range[e].include_upper=a,this)},gt:function(a){return null==a?f.range[e].gt:(f.range[e].gt=a,this)},gte:function(a){return null==a?f.range[e].gte:(f.range[e].gte=a,this)},lt:function(a){return null==a?f.range[e].lt:(f.range[e].lt=a,this)},lte:function(a){return null==a?f.range[e].lte:(f.range[e].lte=a,this)}})},W.RegexpFilter=function(f,c){var h=W.FilterMixin("regexp"),g=h.toJSON();return g.regexp[f]={value:c},au(h,{field:function(a){var d=g.regexp[f];return null==a?f:(delete g.regexp[f],f=a,g.regexp[a]=d,this)},value:function(a){return null==a?g.regexp[f].value:(g.regexp[f].value=a,this)},flags:function(a){return null==a?g.regexp[f].flags:(g.regexp[f].flags=a,this)},flagsValue:function(a){return null==a?g.regexp[f].flags_value:(g.regexp[f].flags_value=a,this)}})},W.ScriptFilter=function(e){var c=W.FilterMixin("script"),f=c.toJSON();return f.script.script=e,au(c,{script:function(b){return null==b?f.script.script:(f.script.script=b,this)},params:function(b){return null==b?f.script.params:(f.script.params=b,this)},lang:function(b){return null==b?f.script.lang:(f.script.lang=b,this)}})},W.TermFilter=function(f,c){var h=W.FilterMixin("term"),g=h.toJSON();return g.term[f]=c,au(h,{field:function(a){var d=g.term[f];return null==a?f:(delete g.term[f],f=a,g.term[f]=d,this)},term:function(a){return null==a?g.term[f]:(g.term[f]=a,this)}})},W.TermsFilter=function(e,c){var l=W.FilterMixin("terms"),k=l.toJSON(),j=function(){ar(k.terms[e])||(k.terms[e]=[])},i=function(){ar(k.terms[e])&&(k.terms[e]={})};return k.terms[e]=ar(c)?c:[c],au(l,{field:function(a){var d=k.terms[e];return null==a?e:(delete k.terms[e],e=a,k.terms[a]=d,this)},terms:function(a){return j(),null==a?k.terms[e]:(ar(a)?k.terms[e]=a:k.terms[e].push(a),this)},index:function(a){return i(),null==a?k.terms[e].index:(k.terms[e].index=a,this)},type:function(a){return i(),null==a?k.terms[e].type:(k.terms[e].type=a,this)},id:function(a){return i(),null==a?k.terms[e].id:(k.terms[e].id=a,this)},path:function(a){return i(),null==a?k.terms[e].path:(k.terms[e].path=a,this)},routing:function(a){return i(),null==a?k.terms[e].routing:(k.terms[e].routing=a,this)},cacheLookup:function(a){return i(),null==a?k.terms[e].cache:(k.terms[e].cache=a,this)},execution:function(b){return null==b?k.terms.execution:(b=b.toLowerCase(),("plain"===b||"bool"===b||"bool_nocache"===b||"and"===b||"and_nocache"===b||"or"===b||"or_nocache"===b)&&(k.terms.execution=b),this)}})},W.TypeFilter=function(e){var c=W.FilterMixin("type"),f=c.toJSON();return f.type.value=e,au(c,{type:function(b){return null==b?f.type.value:(f.type.value=b,this)}})},W.BoolQuery=function(){var d=W.QueryMixin("bool"),c=d.toJSON();return au(d,{must:function(b){var f,e;if(null==c.bool.must&&(c.bool.must=[]),null==b){return c.bool.must}if(ak(b)){c.bool.must.push(b.toJSON())}else{if(!ar(b)){throw new TypeError("Argument must be a Query or array of Queries")}for(c.bool.must=[],f=0,e=b.length;e>f;f++){if(!ak(b[f])){throw new TypeError("Argument must be an array of Queries")}c.bool.must.push(b[f].toJSON())}}return this},mustNot:function(b){var f,e;if(null==c.bool.must_not&&(c.bool.must_not=[]),null==b){return c.bool.must_not}if(ak(b)){c.bool.must_not.push(b.toJSON())}else{if(!ar(b)){throw new TypeError("Argument must be a Query or array of Queries")}for(c.bool.must_not=[],f=0,e=b.length;e>f;f++){if(!ak(b[f])){throw new TypeError("Argument must be an array of Queries")}c.bool.must_not.push(b[f].toJSON())}}return this},should:function(b){var f,e;if(null==c.bool.should&&(c.bool.should=[]),null==b){return c.bool.should}if(ak(b)){c.bool.should.push(b.toJSON())}else{if(!ar(b)){throw new TypeError("Argument must be a Query or array of Queries")}for(c.bool.should=[],f=0,e=b.length;e>f;f++){if(!ak(b[f])){throw new TypeError("Argument must be an array of Queries")}c.bool.should.push(b[f].toJSON())}}return this},adjustPureNegative:function(b){return null==b?c.bool.adjust_pure_negative:(c.bool.adjust_pure_negative=b,this)},disableCoord:function(b){return null==b?c.bool.disable_coord:(c.bool.disable_coord=b,this)},minimumNumberShouldMatch:function(b){return null==b?c.bool.minimum_number_should_match:(c.bool.minimum_number_should_match=b,this)}})},W.BoostingQuery=function(g,c,j){if(!ak(g)||!ak(c)){throw new TypeError("Arguments must be Queries")}var i=W.QueryMixin("boosting"),h=i.toJSON();return h.boosting.positive=g.toJSON(),h.boosting.negative=c.toJSON(),h.boosting.negative_boost=j,au(i,{positive:function(b){if(null==b){return h.boosting.positive}if(!ak(b)){throw new TypeError("Argument must be a Query")}return h.boosting.positive=b.toJSON(),this},negative:function(b){if(null==b){return h.boosting.negative}if(!ak(b)){throw new TypeError("Argument must be a Query")}return h.boosting.negative=b.toJSON(),this},negativeBoost:function(b){return null==b?h.boosting.negative_boost:(h.boosting.negative_boost=b,this)}})},W.CommonTermsQuery=function(f,c){var h=W.QueryMixin("common"),g=h.toJSON();return null==f&&(f="no_field_set"),g.common[f]={},null!=c&&(g.common[f].query=c),au(h,{field:function(a){var d=g.common[f];return null==a?f:(delete g.common[f],f=a,g.common[a]=d,this)},query:function(a){return null==a?g.common[f].query:(g.common[f].query=a,this)},analyzer:function(a){return null==a?g.common[f].analyzer:(g.common[f].analyzer=a,this)},disableCoord:function(a){return null==a?g.common[f].disable_coord:(g.common[f].disable_coord=a,this)},cutoffFrequency:function(a){return null==a?g.common[f].cutoff_frequency:(g.common[f].cutoff_frequency=a,this)},highFreqOperator:function(a){return null==a?g.common[f].high_freq_operator:(a=a.toLowerCase(),("and"===a||"or"===a)&&(g.common[f].high_freq_operator=a),this)},lowFreqOperator:function(a){return null==a?g.common[f].low_freq_operator:(a=a.toLowerCase(),("and"===a||"or"===a)&&(g.common[f].low_freq_operator=a),this)},minimumShouldMatch:function(a){return null==a?g.common[f].minimum_should_match.low_freq:(null==g.common[f].minimum_should_match&&(g.common[f].minimum_should_match={}),g.common[f].minimum_should_match.low_freq=a,this)},minimumShouldMatchLowFreq:function(b){return this.minimumShouldMatch(b)},minimumShouldMatchHighFreq:function(a){return null==a?g.common[f].minimum_should_match.high_freq:(null==g.common[f].minimum_should_match&&(g.common[f].minimum_should_match={}),g.common[f].minimum_should_match.high_freq=a,this)},boost:function(a){return null==a?g.common[f].boost:(g.common[f].boost=a,this)}})},W.ConstantScoreQuery=function(){var d=W.QueryMixin("constant_score"),c=d.toJSON();return au(d,{query:function(b){if(null==b){return c.constant_score.query}if(!ak(b)){throw new TypeError("Argument must be a Query")}return c.constant_score.query=b.toJSON(),this},filter:function(b){if(null==b){return c.constant_score.filter}if(!ai(b)){throw new TypeError("Argument must be a Filter")}return c.constant_score.filter=b.toJSON(),this},cache:function(b){return null==b?c.constant_score._cache:(c.constant_score._cache=b,this)},cacheKey:function(b){return null==b?c.constant_score._cache_key:(c.constant_score._cache_key=b,this)}})},W.DisMaxQuery=function(){var d=W.QueryMixin("dis_max"),c=d.toJSON();return au(d,{queries:function(b){var f,e;if(null==b){return c.dis_max.queries}if(null==c.dis_max.queries&&(c.dis_max.queries=[]),ak(b)){c.dis_max.queries.push(b.toJSON())}else{if(!ar(b)){throw new TypeError("Argument must be a Query or array of Queries")}for(c.dis_max.queries=[],f=0,e=b.length;e>f;f++){if(!ak(b[f])){throw new TypeError("Argument must be array of Queries")}c.dis_max.queries.push(b[f].toJSON())}}return this},tieBreaker:function(b){return null==b?c.dis_max.tie_breaker:(c.dis_max.tie_breaker=b,this)}})},W.FieldMaskingSpanQuery=function(f,c){if(!ak(f)){throw new TypeError("Argument must be a SpanQuery")}var h=W.QueryMixin("field_masking_span"),g=h.toJSON();return g.field_masking_span.query=f.toJSON(),g.field_masking_span.field=c,au(h,{query:function(b){if(null==b){return g.field_masking_span.query}if(!ak(b)){throw new TypeError("Argument must be a SpanQuery")}return g.field_masking_span.query=b.toJSON(),this},field:function(b){return null==b?g.field_masking_span.field:(g.field_masking_span.field=b,this)}})},W.FilteredQuery=function(f,c){if(!ak(f)){throw new TypeError("Argument must be a Query")}if(null!=c&&!ai(c)){throw new TypeError("Argument must be a Filter")}var h=W.QueryMixin("filtered"),g=h.toJSON();return g.filtered.query=f.toJSON(),null!=c&&(g.filtered.filter=c.toJSON()),au(h,{query:function(b){if(null==b){return g.filtered.query}if(!ak(b)){throw new TypeError("Argument must be a Query")}return g.filtered.query=b.toJSON(),this},filter:function(b){if(null==b){return g.filtered.filter}if(!ai(b)){throw new TypeError("Argument must be a Filter")}return g.filtered.filter=b.toJSON(),this},strategy:function(b){return null==b?g.filtered.strategy:(b=b.toLowerCase(),("query_first"===b||"random_access_always"===b||"leap_frog"===b||"leap_frog_filter_first"===b||0===b.indexOf("random_access_"))&&(g.filtered.strategy=b),this)},cache:function(b){return null==b?g.filtered._cache:(g.filtered._cache=b,this)},cacheKey:function(b){return null==b?g.filtered._cache_key:(g.filtered._cache_key=b,this)}})},W.FunctionScoreQuery=function(){var d=W.QueryMixin("function_score"),c=d.toJSON();return au(d,{query:function(b){if(null==b){return c.function_score.query}if(!ak(b)){throw new TypeError("Argument must be a Query")}return c.function_score.query=b.toJSON(),this},filter:function(b){if(null==b){return c.function_score.filter}if(!ai(b)){throw new TypeError("Argument must be a Filter")}return c.function_score.filter=b.toJSON(),this},scoreMode:function(b){return null==b?c.function_score.score_mode:(b=b.toLowerCase(),("avg"===b||"max"===b||"min"===b||"sum"===b||"multiply"===b||"first"===b)&&(c.function_score.score_mode=b),this)},boostMode:function(b){return null==b?c.function_score.boost_mode:(b=b.toLowerCase(),("multiply"===b||"replace"===b||"sum"===b||"avg"===b||"max"===b||"min"===b)&&(c.function_score.boost_mode=b),this)},boost:function(b){return null==b?c.function_score.boost:(c.function_score.boost=b,this)},"function":function(b){if(null==c.function_score.functions&&(c.function_score.functions=[]),null==b){return c.function_score.functions}if(!X(b)){throw new TypeError("Argument must be a ScoreFunction")}return c.function_score.functions.push(b.toJSON()),this},functions:function(b){var f,e;if(null==b){return c.function_score.functions}if(!ar(b)){throw new TypeError("Argument must be an array of ScoreFunctions")}for(c.function_score.functions=[],f=0,e=b.length;e>f;f++){if(!X(b[f])){throw new TypeError("Argument must be an array of ScoreFunctions")}c.function_score.functions.push(b[f].toJSON())}return this}})},W.FuzzyLikeThisFieldQuery=function(f,c){var h=W.QueryMixin("flt_field"),g=h.toJSON();return g.flt_field[f]={like_text:c},au(h,{field:function(a){var d=g.flt_field[f];return null==a?f:(delete g.flt_field[f],f=a,g.flt_field[a]=d,this)},likeText:function(a){return null==a?g.flt_field[f].like_text:(g.flt_field[f].like_text=a,this)},ignoreTf:function(a){return null==a?g.flt_field[f].ignore_tf:(g.flt_field[f].ignore_tf=a,this)},maxQueryTerms:function(a){return null==a?g.flt_field[f].max_query_terms:(g.flt_field[f].max_query_terms=a,this)},minSimilarity:function(a){return null==a?g.flt_field[f].min_similarity:(g.flt_field[f].min_similarity=a,this)},prefixLength:function(a){return null==a?g.flt_field[f].prefix_length:(g.flt_field[f].prefix_length=a,this)},analyzer:function(a){return null==a?g.flt_field[f].analyzer:(g.flt_field[f].analyzer=a,this)},failOnUnsupportedField:function(a){return null==a?g.flt_field[f].fail_on_unsupported_field:(g.flt_field[f].fail_on_unsupported_field=a,this)},boost:function(a){return null==a?g.flt_field[f].boost:(g.flt_field[f].boost=a,this)}})},W.FuzzyLikeThisQuery=function(e){var c=W.QueryMixin("flt"),f=c.toJSON();return f.flt.like_text=e,au(c,{fields:function(b){if(null==f.flt.fields&&(f.flt.fields=[]),null==b){return f.flt.fields}if(ap(b)){f.flt.fields.push(b)}else{if(!ar(b)){throw new TypeError("Argument must be a string or array")}f.flt.fields=b}return this},likeText:function(b){return null==b?f.flt.like_text:(f.flt.like_text=b,this)},ignoreTf:function(b){return null==b?f.flt.ignore_tf:(f.flt.ignore_tf=b,this)},maxQueryTerms:function(b){return null==b?f.flt.max_query_terms:(f.flt.max_query_terms=b,this)},minSimilarity:function(b){return null==b?f.flt.min_similarity:(f.flt.min_similarity=b,this)},prefixLength:function(b){return null==b?f.flt.prefix_length:(f.flt.prefix_length=b,this)},analyzer:function(b){return null==b?f.flt.analyzer:(f.flt.analyzer=b,this)},failOnUnsupportedField:function(b){return null==b?f.flt.fail_on_unsupported_field:(f.flt.fail_on_unsupported_field=b,this)}})},W.FuzzyQuery=function(f,c){var h=W.QueryMixin("fuzzy"),g=h.toJSON();return g.fuzzy[f]={value:c},au(h,{field:function(a){var d=g.fuzzy[f];return null==a?f:(delete g.fuzzy[f],f=a,g.fuzzy[a]=d,this)},value:function(a){return null==a?g.fuzzy[f].value:(g.fuzzy[f].value=a,this)},transpositions:function(a){return null==a?g.fuzzy[f].transpositions:(g.fuzzy[f].transpositions=a,this)},maxExpansions:function(a){return null==a?g.fuzzy[f].max_expansions:(g.fuzzy[f].max_expansions=a,this)},minSimilarity:function(a){return null==a?g.fuzzy[f].min_similarity:(g.fuzzy[f].min_similarity=a,this)},prefixLength:function(a){return null==a?g.fuzzy[f].prefix_length:(g.fuzzy[f].prefix_length=a,this)},rewrite:function(a){return null==a?g.fuzzy[f].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_"))&&(g.fuzzy[f].rewrite=a),this)},boost:function(a){return null==a?g.fuzzy[f].boost:(g.fuzzy[f].boost=a,this)}})},W.GeoShapeQuery=function(e){var c=W.QueryMixin("geo_shape"),f=c.toJSON();return f.geo_shape[e]={},au(c,{field:function(a){var d=f.geo_shape[e];return null==a?e:(delete f.geo_shape[e],e=a,f.geo_shape[a]=d,this)},shape:function(a){return null==a?f.geo_shape[e].shape:(null!=f.geo_shape[e].indexed_shape&&delete f.geo_shape[e].indexed_shape,f.geo_shape[e].shape=a.toJSON(),this)},indexedShape:function(a){return null==a?f.geo_shape[e].indexed_shape:(null!=f.geo_shape[e].shape&&delete f.geo_shape[e].shape,f.geo_shape[e].indexed_shape=a.toJSON(),this)},relation:function(a){return null==a?f.geo_shape[e].relation:(a=a.toLowerCase(),("intersects"===a||"disjoint"===a||"within"===a)&&(f.geo_shape[e].relation=a),this)},strategy:function(a){return null==a?f.geo_shape[e].strategy:(a=a.toLowerCase(),("recursive"===a||"term"===a)&&(f.geo_shape[e].strategy=a),this)},boost:function(a){return null==a?f.geo_shape[e].boost:(f.geo_shape[e].boost=a,this)}})},W.HasChildQuery=function(f,c){if(!ak(f)){throw new TypeError("Argument must be a valid Query")}var h=W.QueryMixin("has_child"),g=h.toJSON();return g.has_child.query=f.toJSON(),g.has_child.type=c,au(h,{query:function(b){if(null==b){return g.has_child.query}if(!ak(b)){throw new TypeError("Argument must be a valid Query")}return g.has_child.query=b.toJSON(),this},type:function(b){return null==b?g.has_child.type:(g.has_child.type=b,this)},scope:function(){return this},scoreType:function(b){return null==b?g.has_child.score_type:(b=b.toLowerCase(),("none"===b||"max"===b||"sum"===b||"avg"===b)&&(g.has_child.score_type=b),this)},scoreMode:function(b){return null==b?g.has_child.score_mode:(b=b.toLowerCase(),("none"===b||"max"===b||"sum"===b||"avg"===b)&&(g.has_child.score_mode=b),this)},shortCircuitCutoff:function(b){return null==b?g.has_child.short_circuit_cutoff:(g.has_child.short_circuit_cutoff=b,this)}})},W.HasParentQuery=function(f,c){if(!ak(f)){throw new TypeError("Argument must be a Query")}var h=W.QueryMixin("has_parent"),g=h.toJSON();return g.has_parent.query=f.toJSON(),g.has_parent.parent_type=c,au(h,{query:function(b){if(null==b){return g.has_parent.query}if(!ak(b)){throw new TypeError("Argument must be a Query")}return g.has_parent.query=b.toJSON(),this},parentType:function(b){return null==b?g.has_parent.parent_type:(g.has_parent.parent_type=b,this)},scope:function(){return this},scoreType:function(b){return null==b?g.has_parent.score_type:(b=b.toLowerCase(),("none"===b||"score"===b)&&(g.has_parent.score_type=b),this)},scoreMode:function(b){return null==b?g.has_parent.score_mode:(b=b.toLowerCase(),("none"===b||"score"===b)&&(g.has_parent.score_mode=b),this)}})},W.IdsQuery=function(e){var c=W.QueryMixin("ids"),f=c.toJSON();if(ap(e)){f.ids.values=[e]}else{if(!ar(e)){throw new TypeError("Argument must be string or array")}f.ids.values=e}return au(c,{values:function(b){if(null==b){return f.ids.values}if(ap(b)){f.ids.values.push(b)}else{if(!ar(b)){throw new TypeError("Argument must be string or array")}f.ids.values=b}return this},type:function(b){if(null==f.ids.type&&(f.ids.type=[]),null==b){return f.ids.type}if(ap(b)){f.ids.type.push(b)}else{if(!ar(b)){throw new TypeError("Argument must be string or array")}f.ids.type=b}return this}})},W.IndicesQuery=function(e,c){if(!ak(e)){throw new TypeError("Argument must be a Query")}var h=W.QueryMixin("indices"),g=h.toJSON();if(g.indices.query=e.toJSON(),ap(c)){g.indices.indices=[c]}else{if(!ar(c)){throw new TypeError("Argument must be a string or array")}g.indices.indices=c}return au(h,{indices:function(b){if(null==b){return g.indices.indices}if(ap(b)){g.indices.indices.push(b)}else{if(!ar(b)){throw new TypeError("Argument must be a string or array")}g.indices.indices=b}return this},query:function(b){if(null==b){return g.indices.query}if(!ak(b)){throw new TypeError("Argument must be a Query")}return g.indices.query=b.toJSON(),this},noMatchQuery:function(b){if(null==b){return g.indices.no_match_query}if(ap(b)){b=b.toLowerCase(),("none"===b||"all"===b)&&(g.indices.no_match_query=b)}else{if(!ak(b)){throw new TypeError("Argument must be string or Query")}g.indices.no_match_query=b.toJSON()}return this}})},W.MatchAllQuery=function(){return W.QueryMixin("match_all")},W.MatchQuery=function(f,c){var h=W.QueryMixin("match"),g=h.toJSON();return g.match[f]={query:c},au(h,{query:function(a){return null==a?g.match[f].query:(g.match[f].query=a,this)},type:function(a){return null==a?g.match[f].type:(a=a.toLowerCase(),("boolean"===a||"phrase"===a||"phrase_prefix"===a)&&(g.match[f].type=a),this)},fuzziness:function(a){return null==a?g.match[f].fuzziness:(g.match[f].fuzziness=a,this)},cutoffFrequency:function(a){return null==a?g.match[f].cutoff_frequency:(g.match[f].cutoff_frequency=a,this)},prefixLength:function(a){return null==a?g.match[f].prefix_length:(g.match[f].prefix_length=a,this)},maxExpansions:function(a){return null==a?g.match[f].max_expansions:(g.match[f].max_expansions=a,this)},operator:function(a){return null==a?g.match[f].operator:(a=a.toLowerCase(),("and"===a||"or"===a)&&(g.match[f].operator=a),this)},slop:function(a){return null==a?g.match[f].slop:(g.match[f].slop=a,this)},analyzer:function(a){return null==a?g.match[f].analyzer:(g.match[f].analyzer=a,this)},minimumShouldMatch:function(a){return null==a?g.match[f].minimum_should_match:(g.match[f].minimum_should_match=a,this)},rewrite:function(a){return null==a?g.match[f].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_"))&&(g.match[f].rewrite=a),this)},fuzzyRewrite:function(a){return null==a?g.match[f].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_"))&&(g.match[f].fuzzy_rewrite=a),this)},fuzzyTranspositions:function(a){return null==a?g.match[f].fuzzy_transpositions:(g.match[f].fuzzy_transpositions=a,this)},lenient:function(a){return null==a?g.match[f].lenient:(g.match[f].lenient=a,this)},zeroTermsQuery:function(a){return null==a?g.match[f].zero_terms_query:(a=a.toLowerCase(),("all"===a||"none"===a)&&(g.match[f].zero_terms_query=a),this)},boost:function(a){return null==a?g.match[f].boost:(g.match[f].boost=a,this)}})},W.MoreLikeThisFieldQuery=function(f,c){var h=W.QueryMixin("mlt_field"),g=h.toJSON();return g.mlt_field[f]={like_text:c},au(h,{field:function(a){var d=g.mlt_field[f];return null==a?f:(delete g.mlt_field[f],f=a,g.mlt_field[a]=d,this)},likeText:function(a){return null==a?g.mlt_field[f].like_text:(g.mlt_field[f].like_text=a,this)},percentTermsToMatch:function(a){return null==a?g.mlt_field[f].percent_terms_to_match:(g.mlt_field[f].percent_terms_to_match=a,this)},minTermFreq:function(a){return null==a?g.mlt_field[f].min_term_freq:(g.mlt_field[f].min_term_freq=a,this)},maxQueryTerms:function(a){return null==a?g.mlt_field[f].max_query_terms:(g.mlt_field[f].max_query_terms=a,this)},stopWords:function(a){return null==a?g.mlt_field[f].stop_words:(g.mlt_field[f].stop_words=a,this)},minDocFreq:function(a){return null==a?g.mlt_field[f].min_doc_freq:(g.mlt_field[f].min_doc_freq=a,this)},maxDocFreq:function(a){return null==a?g.mlt_field[f].max_doc_freq:(g.mlt_field[f].max_doc_freq=a,this)},minWordLen:function(a){return null==a?g.mlt_field[f].min_word_len:(g.mlt_field[f].min_word_len=a,this)},maxWordLen:function(a){return null==a?g.mlt_field[f].max_word_len:(g.mlt_field[f].max_word_len=a,this)},analyzer:function(a){return null==a?g.mlt_field[f].analyzer:(g.mlt_field[f].analyzer=a,this)},boostTerms:function(a){return null==a?g.mlt_field[f].boost_terms:(g.mlt_field[f].boost_terms=a,this)},failOnUnsupportedField:function(a){return null==a?g.mlt_field[f].fail_on_unsupported_field:(g.mlt_field[f].fail_on_unsupported_field=a,this)},boost:function(a){return null==a?g.mlt_field[f].boost:(g.mlt_field[f].boost=a,this)}})},W.MoreLikeThisQuery=function(e,c){var h=W.QueryMixin("mlt"),g=h.toJSON();if(g.mlt.like_text=c,g.mlt.fields=[],ap(e)){g.mlt.fields.push(e)}else{if(!ar(e)){throw new TypeError("Argument must be string or array")}g.mlt.fields=e}return au(h,{fields:function(b){if(null==b){return g.mlt.fields}if(ap(b)){g.mlt.fields.push(b)}else{if(!ar(b)){throw new TypeError("Argument must be a string or array")}g.mlt.fields=b}return this},likeText:function(b){return null==b?g.mlt.like_text:(g.mlt.like_text=b,this)},percentTermsToMatch:function(b){return null==b?g.mlt.percent_terms_to_match:(g.mlt.percent_terms_to_match=b,this)},minTermFreq:function(b){return null==b?g.mlt.min_term_freq:(g.mlt.min_term_freq=b,this)},maxQueryTerms:function(b){return null==b?g.mlt.max_query_terms:(g.mlt.max_query_terms=b,this)},stopWords:function(b){return null==b?g.mlt.stop_words:(g.mlt.stop_words=b,this)},minDocFreq:function(b){return null==b?g.mlt.min_doc_freq:(g.mlt.min_doc_freq=b,this)},maxDocFreq:function(b){return null==b?g.mlt.max_doc_freq:(g.mlt.max_doc_freq=b,this)},minWordLen:function(b){return null==b?g.mlt.min_word_len:(g.mlt.min_word_len=b,this)},maxWordLen:function(b){return null==b?g.mlt.max_word_len:(g.mlt.max_word_len=b,this)},analyzer:function(b){return null==b?g.mlt.analyzer:(g.mlt.analyzer=b,this)},boostTerms:function(b){return null==b?g.mlt.boost_terms:(g.mlt.boost_terms=b,this)},failOnUnsupportedField:function(b){return null==b?g.mlt.fail_on_unsupported_field:(g.mlt.fail_on_unsupported_field=b,this)}})},W.MultiMatchQuery=function(e,c){var h=W.QueryMixin("multi_match"),g=h.toJSON();if(g.multi_match.query=c,g.multi_match.fields=[],ap(e)){g.multi_match.fields.push(e)}else{if(!ar(e)){throw new TypeError("Argument must be string or array")}g.multi_match.fields=e}return au(h,{fields:function(b){if(null==b){return g.multi_match.fields}if(ap(b)){g.multi_match.fields.push(b)}else{if(!ar(b)){throw new TypeError("Argument must be string or array")}g.multi_match.fields=b}return this},useDisMax:function(b){return null==b?g.multi_match.use_dis_max:(g.multi_match.use_dis_max=b,this)},tieBreaker:function(b){return null==b?g.multi_match.tie_breaker:(g.multi_match.tie_breaker=b,this)},cutoffFrequency:function(b){return null==b?g.multi_match.cutoff_frequency:(g.multi_match.cutoff_frequency=b,this)},minimumShouldMatch:function(b){return null==b?g.multi_match.minimum_should_match:(g.multi_match.minimum_should_match=b,this)},rewrite:function(b){return null==b?g.multi_match.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_"))&&(g.multi_match.rewrite=b),this)},fuzzyRewrite:function(b){return null==b?g.multi_match.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_"))&&(g.multi_match.fuzzy_rewrite=b),this)},lenient:function(b){return null==b?g.multi_match.lenient:(g.multi_match.lenient=b,this)},query:function(b){return null==b?g.multi_match.query:(g.multi_match.query=b,this)},type:function(b){return null==b?g.multi_match.type:(b=b.toLowerCase(),("boolean"===b||"phrase"===b||"phrase_prefix"===b)&&(g.multi_match.type=b),this)},fuzziness:function(b){return null==b?g.multi_match.fuzziness:(g.multi_match.fuzziness=b,this)},prefixLength:function(b){return null==b?g.multi_match.prefix_length:(g.multi_match.prefix_length=b,this)},maxExpansions:function(b){return null==b?g.multi_match.max_expansions:(g.multi_match.max_expansions=b,this)},operator:function(b){return null==b?g.multi_match.operator:(b=b.toLowerCase(),("and"===b||"or"===b)&&(g.multi_match.operator=b),this)},slop:function(b){return null==b?g.multi_match.slop:(g.multi_match.slop=b,this)},analyzer:function(b){return null==b?g.multi_match.analyzer:(g.multi_match.analyzer=b,this)},zeroTermsQuery:function(b){return null==b?g.multi_match.zero_terms_query:(b=b.toLowerCase(),("all"===b||"none"===b)&&(g.multi_match.zero_terms_query=b),this)}})},W.NestedQuery=function(e){var c=W.QueryMixin("nested"),f=c.toJSON();return f.nested.path=e,au(c,{path:function(b){return null==b?f.nested.path:(f.nested.path=b,this)},query:function(b){if(null==b){return f.nested.query}if(!ak(b)){throw new TypeError("Argument must be a Query")}return f.nested.query=b.toJSON(),this},filter:function(b){if(null==b){return f.nested.filter}if(!ai(b)){throw new TypeError("Argument must be a Filter")}return f.nested.filter=b.toJSON(),this},scoreMode:function(b){return null==b?f.nested.score_mode:(b=b.toLowerCase(),("avg"===b||"total"===b||"max"===b||"none"===b||"sum"===b)&&(f.nested.score_mode=b),this)},scope:function(){return this}})},W.PrefixQuery=function(f,c){var h=W.QueryMixin("prefix"),g=h.toJSON();return g.prefix[f]={value:c},au(h,{field:function(a){var d=g.prefix[f];return null==a?f:(delete g.prefix[f],f=a,g.prefix[a]=d,this)},value:function(a){return null==a?g.prefix[f].value:(g.prefix[f].value=a,this)},rewrite:function(a){return null==a?g.prefix[f].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_"))&&(g.prefix[f].rewrite=a),this)},boost:function(a){return null==a?g.prefix[f].boost:(g.prefix[f].boost=a,this)}})},W.QueryStringQuery=function(e){var c=W.QueryMixin("query_string"),f=c.toJSON();return f.query_string.query=e,au(c,{query:function(b){return null==b?f.query_string.query:(f.query_string.query=b,this)},defaultField:function(b){return null==b?f.query_string.default_field:(f.query_string.default_field=b,this)},fields:function(b){if(null==f.query_string.fields&&(f.query_string.fields=[]),null==b){return f.query_string.fields}if(ap(b)){f.query_string.fields.push(b)}else{if(!ar(b)){throw new TypeError("Argument must be a string or array")}f.query_string.fields=b}return this},useDisMax:function(b){return null==b?f.query_string.use_dis_max:(f.query_string.use_dis_max=b,this)},defaultOperator:function(b){return null==b?f.query_string.default_operator:(b=b.toUpperCase(),("AND"===b||"OR"===b)&&(f.query_string.default_operator=b),this)},analyzer:function(b){return null==b?f.query_string.analyzer:(f.query_string.analyzer=b,this)},quoteAnalyzer:function(b){return null==b?f.query_string.quote_analyzer:(f.query_string.quote_analyzer=b,this)},allowLeadingWildcard:function(b){return null==b?f.query_string.allow_leading_wildcard:(f.query_string.allow_leading_wildcard=b,this)},lowercaseExpandedTerms:function(b){return null==b?f.query_string.lowercase_expanded_terms:(f.query_string.lowercase_expanded_terms=b,this)},enablePositionIncrements:function(b){return null==b?f.query_string.enable_position_increments:(f.query_string.enable_position_increments=b,this)},fuzzyPrefixLength:function(b){return null==b?f.query_string.fuzzy_prefix_length:(f.query_string.fuzzy_prefix_length=b,this)},fuzzyMinSim:function(b){return null==b?f.query_string.fuzzy_min_sim:(f.query_string.fuzzy_min_sim=b,this)},phraseSlop:function(b){return null==b?f.query_string.phrase_slop:(f.query_string.phrase_slop=b,this)},analyzeWildcard:function(b){return null==b?f.query_string.analyze_wildcard:(f.query_string.analyze_wildcard=b,this)},autoGeneratePhraseQueries:function(b){return null==b?f.query_string.auto_generate_phrase_queries:(f.query_string.auto_generate_phrase_queries=b,this)},minimumShouldMatch:function(b){return null==b?f.query_string.minimum_should_match:(f.query_string.minimum_should_match=b,this)},tieBreaker:function(b){return null==b?f.query_string.tie_breaker:(f.query_string.tie_breaker=b,this)},escape:function(b){return null==b?f.query_string.escape:(f.query_string.escape=b,this)},fuzzyMaxExpansions:function(b){return null==b?f.query_string.fuzzy_max_expansions:(f.query_string.fuzzy_max_expansions=b,this)},fuzzyRewrite:function(b){return null==b?f.query_string.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_"))&&(f.query_string.fuzzy_rewrite=b),this)},rewrite:function(b){return null==b?f.query_string.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_"))&&(f.query_string.rewrite=b),this)},quoteFieldSuffix:function(b){return null==b?f.query_string.quote_field_suffix:(f.query_string.quote_field_suffix=b,this)},lenient:function(b){return null==b?f.query_string.lenient:(f.query_string.lenient=b,this)}})},W.RangeQuery=function(e){var c=W.QueryMixin("range"),f=c.toJSON();return f.range[e]={},au(c,{field:function(a){var d=f.range[e];return null==a?e:(delete f.range[e],e=a,f.range[a]=d,this)},from:function(a){return null==a?f.range[e].from:(f.range[e].from=a,this)},to:function(a){return null==a?f.range[e].to:(f.range[e].to=a,this)},includeLower:function(a){return null==a?f.range[e].include_lower:(f.range[e].include_lower=a,this)},includeUpper:function(a){return null==a?f.range[e].include_upper:(f.range[e].include_upper=a,this)},gt:function(a){return null==a?f.range[e].gt:(f.range[e].gt=a,this)},gte:function(a){return null==a?f.range[e].gte:(f.range[e].gte=a,this)},lt:function(a){return null==a?f.range[e].lt:(f.range[e].lt=a,this)},lte:function(a){return null==a?f.range[e].lte:(f.range[e].lte=a,this)},boost:function(a){return null==a?f.range[e].boost:(f.range[e].boost=a,this)}})},W.RegexpQuery=function(f,c){var h=W.QueryMixin("regexp"),g=h.toJSON();return g.regexp[f]={value:c},au(h,{field:function(a){var d=g.regexp[f];return null==a?f:(delete g.regexp[f],f=a,g.regexp[a]=d,this)},value:function(a){return null==a?g.regexp[f].value:(g.regexp[f].value=a,this)},flags:function(a){return null==a?g.regexp[f].flags:(g.regexp[f].flags=a,this)},flagsValue:function(a){return null==a?g.regexp[f].flags_value:(g.regexp[f].flags_value=a,this)},rewrite:function(a){return null==a?g.regexp[f].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_"))&&(g.regexp[f].rewrite=a),this)},boost:function(a){return null==a?g.regexp[f].boost:(g.regexp[f].boost=a,this)}})},W.SpanFirstQuery=function(f,c){if(!ak(f)){throw new TypeError("Argument must be a SpanQuery")}var h=W.QueryMixin("span_first"),g=h.toJSON();return g.span_first.match=f.toJSON(),g.span_first.end=c,au(h,{match:function(b){if(null==b){return g.span_first.match}if(!ak(b)){throw new TypeError("Argument must be a SpanQuery")}return g.span_first.match=b.toJSON(),this},end:function(b){return null==b?g.span_first.end:(g.span_first.end=b,this)}})},W.SpanMultiTermQuery=function(e){if(null!=e&&!ak(e)){throw new TypeError("Argument must be a MultiTermQuery")}var c=W.QueryMixin("span_multi"),f=c.toJSON();return f.span_multi.match={},null!=e&&(f.span_multi.match=e.toJSON()),au(c,{match:function(b){if(null==b){return f.span_multi.match}if(!ak(b)){throw new TypeError("Argument must be a MultiTermQuery")}return f.span_multi.match=b.toJSON(),this}})},W.SpanNearQuery=function(e,c){var l,k,j=W.QueryMixin("span_near"),i=j.toJSON();if(i.span_near.clauses=[],i.span_near.slop=c,ak(e)){i.span_near.clauses.push(e.toJSON())}else{if(!ar(e)){throw new TypeError("Argument must be SpanQuery or array of SpanQueries")}for(l=0,k=e.length;k>l;l++){if(!ak(e[l])){throw new TypeError("Argument must be array of SpanQueries")}i.span_near.clauses.push(e[l].toJSON())}}return au(j,{clauses:function(f){var d,g;if(null==f){return i.span_near.clauses}if(ak(f)){i.span_near.clauses.push(f.toJSON())}else{if(!ar(f)){throw new TypeError("Argument must be SpanQuery or array of SpanQueries")}for(i.span_near.clauses=[],d=0,g=f.length;g>d;d++){if(!ak(f[d])){throw new TypeError("Argument must be array of SpanQueries")}i.span_near.clauses.push(f[d].toJSON())}}return this},slop:function(b){return null==b?i.span_near.slop:(i.span_near.slop=b,this)},inOrder:function(b){return null==b?i.span_near.in_order:(i.span_near.in_order=b,this)},collectPayloads:function(b){return null==b?i.span_near.collect_payloads:(i.span_near.collect_payloads=b,this)}})},W.SpanNotQuery=function(f,c){if(!ak(f)||!ak(c)){throw new TypeError("Argument must be a SpanQuery")}var h=W.QueryMixin("span_not"),g=h.toJSON();return g.span_not.include=f.toJSON(),g.span_not.exclude=c.toJSON(),au(h,{include:function(b){if(null==b){return g.span_not.include}if(!ak(b)){throw new TypeError("Argument must be a SpanQuery")}return g.span_not.include=b.toJSON(),this},exclude:function(b){if(null==b){return g.span_not.exclude}if(!ak(b)){throw new TypeError("Argument must be a SpanQuery")}return g.span_not.exclude=b.toJSON(),this}})},W.SpanOrQuery=function(e){var c,j,i=W.QueryMixin("span_or"),h=i.toJSON();if(h.span_or.clauses=[],ak(e)){h.span_or.clauses.push(e.toJSON())}else{if(!ar(e)){throw new TypeError("Argument must be SpanQuery or array of SpanQueries")}for(c=0,j=e.length;j>c;c++){if(!ak(e[c])){throw new TypeError("Argument must be array of SpanQueries")}h.span_or.clauses.push(e[c].toJSON())}}return au(i,{clauses:function(f){var d,g;if(null==f){return h.span_or.clauses}if(ak(f)){h.span_or.clauses.push(f.toJSON())}else{if(!ar(f)){throw new TypeError("Argument must be SpanQuery or array of SpanQueries")}for(h.span_or.clauses=[],d=0,g=f.length;g>d;d++){if(!ak(f[d])){throw new TypeError("Argument must be array of SpanQueries")}h.span_or.clauses.push(f[d].toJSON())}}return this}})},W.SpanTermQuery=function(f,c){var h=W.QueryMixin("span_term"),g=h.toJSON();return g.span_term[f]={term:c},au(h,{field:function(a){var d=g.span_term[f];return null==a?f:(delete g.span_term[f],f=a,g.span_term[a]=d,this)},term:function(a){return null==a?g.span_term[f].term:(g.span_term[f].term=a,this)},boost:function(a){return null==a?g.span_term[f].boost:(g.span_term[f].boost=a,this)}})},W.TermQuery=function(f,c){var h=W.QueryMixin("term"),g=h.toJSON();return g.term[f]={term:c},au(h,{field:function(a){var d=g.term[f];return null==a?f:(delete g.term[f],f=a,g.term[a]=d,this)},term:function(a){return null==a?g.term[f].term:(g.term[f].term=a,this)},boost:function(a){return null==a?g.term[f].boost:(g.term[f].boost=a,this)}})},W.TermsQuery=function(e,c){var h=W.QueryMixin("terms"),g=h.toJSON();if(ap(c)){g.terms[e]=[c]}else{if(!ar(c)){throw new TypeError("Argument must be string or array")}g.terms[e]=c}return au(h,{field:function(a){var d=g.terms[e];return null==a?e:(delete g.terms[e],e=a,g.terms[a]=d,this)},terms:function(a){if(null==a){return g.terms[e]}if(ap(a)){g.terms[e].push(a)}else{if(!ar(a)){throw new TypeError("Argument must be string or array")}g.terms[e]=a}return this},minimumShouldMatch:function(b){return null==b?g.terms.minimum_should_match:(g.terms.minimum_should_match=b,this)},disableCoord:function(b){return null==b?g.terms.disable_coord:(g.terms.disable_coord=b,this)}})},W.TopChildrenQuery=function(f,c){if(!ak(f)){throw new TypeError("Argument must be a Query")}var h=W.QueryMixin("top_children"),g=h.toJSON();return g.top_children.query=f.toJSON(),g.top_children.type=c,au(h,{query:function(b){if(null==b){return g.top_children.query}if(!ak(b)){throw new TypeError("Argument must be a Query")}return g.top_children.query=b.toJSON(),this},type:function(b){return null==b?g.top_children.type:(g.top_children.type=b,this)},scope:function(){return this},score:function(b){return null==b?g.top_children.score:(b=b.toLowerCase(),("max"===b||"sum"===b||"avg"===b||"total"===b)&&(g.top_children.score=b),this)},scoreMode:function(b){return null==b?g.top_children.score_mode:(b=b.toLowerCase(),("max"===b||"sum"===b||"avg"===b||"total"===b)&&(g.top_children.score_mode=b),this)},factor:function(b){return null==b?g.top_children.factor:(g.top_children.factor=b,this)},incrementalFactor:function(b){return null==b?g.top_children.incremental_factor:(g.top_children.incremental_factor=b,this)}})},W.WildcardQuery=function(f,c){var h=W.QueryMixin("wildcard"),g=h.toJSON();return g.wildcard[f]={value:c},au(h,{field:function(a){var d=g.wildcard[f];return null==a?f:(delete g.wildcard[f],f=a,g.wildcard[a]=d,this)},value:function(a){return null==a?g.wildcard[f].value:(g.wildcard[f].value=a,this)},rewrite:function(a){return null==a?g.wildcard[f].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_"))&&(g.wildcard[f].rewrite=a),this)},boost:function(a){return null==a?g.wildcard[f].boost:(g.wildcard[f].boost=a,this)}})},W.BoostFactorScoreFunction=function(e){var c=W.ScoreFunctionMixin("boost_factor"),f=c.toJSON();return f.boost_factor=e,au(c,{boost:function(b){return null==b?f.boost_factor:(f.boost_factor=b,this)}})},W.DecayScoreFunction=function(g){var c="gauss",j=W.ScoreFunctionMixin(c),i=j.toJSON(),h=function(b){var d;c!==b&&(d=i[c],delete i[c],c=b,i[c]=d)};return i[c][g]={},au(j,{linear:function(){h("linear")},exp:function(){h("exp")},gauss:function(){h("gauss")},field:function(b){var a=i[c][g];return null==b?g:(delete i[c][g],g=b,i[c][g]=a,this)},scale:function(a){return null==a?i[c][g].scale:(i[c][g].scale=a,this)},origin:function(a){if(null==a){return i[c][g].origin}if(ae(a)){i[c][g].origin=a.toJSON()}else{if(al(a)){throw new TypeError("origin must be a GeoPoint or native type")}i[c][g].origin=a}return this},decay:function(a){return null==a?i[c][g].decay:(i[c][g].decay=a,this)},offset:function(a){return null==a?i[c][g].offset:(i[c][g].offset=a,this)}})},W.RandomScoreFunction=function(){var d=W.ScoreFunctionMixin("random_score"),c=d.toJSON();return au(d,{seed:function(b){return null==b?c.random_score.seed:(c.random_score.seed=b,this)}})},W.ScriptScoreFunction=function(){var d=W.ScoreFunctionMixin("script_score"),c=d.toJSON();return au(d,{script:function(b){return null==b?c.script_score.script:(c.script_score.script=b,this)},lang:function(b){return null==b?c.script_score.lang:(c.script_score.lang=b,this)},params:function(b){return null==b?c.script_score.params:(c.script_score.params=b,this)}})},W.GeoPoint=function(a){var d=[0,0];return null!=a&&ar(a)&&2===a.length&&(d=[a[1],a[0]]),{properties:function(c){return null==c?d:(aq(c)&&aw(c,"lat")&&aw(c,"lon")?d={lat:c.lat,lon:c.lon}:aq(c)&&aw(c,"geohash")&&(d={geohash:c.geohash}),this)},string:function(b){return null==b?d:(ap(b)&&-1!==b.indexOf(",")&&(d=b),this)},geohash:function(e,c){return c=null!=c&&ao(c)?c:12,null==e?d:(ap(e)&&e.length===c&&(d=e),this)},array:function(b){return null==b?d:(ar(b)&&2===b.length&&(d=[b[1],b[0]]),this)},_type:function(){return"geo point"},toJSON:function(){return d}}},W.Highlight=function(e){var b={fields:{}},a=function(d,g,f){null==d?b[g]=f:(aw(b.fields,d)||(b.fields[d]={}),b.fields[d][g]=f)};return null!=e&&(ap(e)?b.fields[e]={}:ar(e)&&av(e,function(c){b.fields[c]={}})),{fields:function(d){return null==d?b.fields:void (ap(d)?aw(b.fields,d)||(b.fields[d]={}):ar(d)&&av(d,function(c){aw(b.fields,c)||(b.fields[c]={})}))},preTags:function(d,c){return null===d&&null!=c?b.fields[c].pre_tags:null==d?b.pre_tags:(ap(d)?a(c,"pre_tags",[d]):ar(d)&&a(c,"pre_tags",d),this)},postTags:function(d,c){return null===d&&null!=c?b.fields[c].post_tags:null==d?b.post_tags:(ap(d)?a(c,"post_tags",[d]):ar(d)&&a(c,"post_tags",d),this)},order:function(d,c){return null===d&&null!=c?b.fields[c].order:null==d?b.order:(d=d.toLowerCase(),"score"===d&&a(c,"order",d),this)},tagsSchema:function(c){return null==c?b.tags_schema:(c=c.toLowerCase(),"styled"===c&&(b.tags_schema=c),this)},highlightFilter:function(d,c){return null===d&&null!=c?b.fields[c].highlight_filter:null==d?b.highlight_filter:(a(c,"highlight_filter",d),this)},fragmentSize:function(d,c){return null===d&&null!=c?b.fields[c].fragment_size:null==d?b.fragment_size:(a(c,"fragment_size",d),this)},numberOfFragments:function(d,c){return null===d&&null!=c?b.fields[c].number_of_fragments:null==d?b.number_of_fragments:(a(c,"number_of_fragments",d),this)},encoder:function(c){return null==c?b.encoder:(c=c.toLowerCase(),("default"===c||"html"===c)&&(b.encoder=c),this)},requireFieldMatch:function(d,c){return null===d&&null!=c?b.fields[c].require_field_match:null==d?b.require_field_match:(a(c,"require_field_match",d),this)},boundaryMaxScan:function(d,c){return null===d&&null!=c?b.fields[c].boundary_max_scan:null==d?b.boundary_max_scan:(a(c,"boundary_max_scan",d),this)},boundaryChars:function(d,c){return null===d&&null!=c?b.fields[c].boundary_chars:null==d?b.boundary_chars:(a(c,"boundary_chars",d),this)},type:function(d,c){return null===d&&null!=c?b.fields[c].type:null==d?b.type:(d=d.toLowerCase(),("fvh"===d||"plain"===d||"postings"===d)&&a(c,"type",d),this)},fragmenter:function(d,c){return null===d&&null!=c?b.fields[c].fragmenter:null==d?b.fragmenter:(d=d.toLowerCase(),("simple"===d||"span"===d)&&a(c,"fragmenter",d),this)},options:function(d,c){if(null===d&&null!=c){return b.fields[c].options}if(null==d){return b.options}if(!aq(d)||ar(d)||al(d)){throw new TypeError("Parameter must be an object")}return a(c,"options",d),this},_type:function(){return"highlight"},toJSON:function(){return b}}},W.IndexedShape=function(e,d){var f={type:e,id:d};return{type:function(b){return null==b?f.type:(f.type=b,this)},id:function(b){return null==b?f.id:(f.id=b,this)},index:function(b){return null==b?f.index:(f.index=b,this)},shapeFieldName:function(b){return null==b?f.shape_field_name:(f.shape_field_name=b,this)},_type:function(){return"indexed shape"},toJSON:function(){return f}}},W.Request=function(){var a={};return{sort:function(){var m,l;if(aw(a,"sort")||(a.sort=[]),0===arguments.length){return a.sort}if(1===arguments.length){var k=arguments[0];if(ap(k)){a.sort.push(k)}else{if(ab(k)){a.sort.push(k.toJSON())}else{if(!ar(k)){throw new TypeError("Argument must be string, Sort, or array")}for(a.sort=[],m=0,l=k.length;l>m;m++){if(ap(k[m])){a.sort.push(k[m])}else{if(!ab(k[m])){throw new TypeError("Invalid object in array")}a.sort.push(k[m].toJSON())}}}}}else{if(2===arguments.length){var g=arguments[0],e=arguments[1];if(ap(g)&&ap(e)&&(e=e.toLowerCase(),"asc"===e||"desc"===e)){var b={};b[g]={order:e},a.sort.push(b)}}}return this},trackScores:function(b){return null==b?a.track_scores:(a.track_scores=b,this)},from:function(b){return null==b?a.from:(a.from=b,this)},size:function(b){return null==b?a.size:(a.size=b,this)},timeout:function(b){return null==b?a.timeout:(a.timeout=b,this)},fields:function(b){if(null==b){return a.fields}if(null==a.fields&&(a.fields=[]),ap(b)){a.fields.push(b)}else{if(!ar(b)){throw new TypeError("Argument must be a string or an array")}a.fields=b}return this},source:function(b,d){if(null==b&&null==d){return a._source}if(!ar(b)&&!ap(b)&&!an(b)){throw new TypeError("Argument includes must be a string, an array, or a boolean")}if(null!=d&&!ar(d)&&!ap(d)){throw new TypeError("Argument excludes must be a string or an array")}return an(b)?a._source=b:(a._source={includes:b},null!=d&&(a._source.excludes=d)),this},rescore:function(b){if(null==b){return a.rescore}if(!aj(b)){throw new TypeError("Argument must be a Rescore")}return a.rescore=b.toJSON(),this},query:function(b){if(null==b){return a.query}if(!ak(b)){throw new TypeError("Argument must be a Query")}return a.query=b.toJSON(),this},facet:function(b){if(null==b){return a.facets}if(null==a.facets&&(a.facets={}),!ah(b)){throw new TypeError("Argument must be a Facet")}return au(a.facets,b.toJSON()),this},aggregation:function(b){if(null==b){return a.aggs}if(null==a.aggs&&(a.aggs={}),!ag(b)){throw new TypeError("Argument must be an Aggregation")}return au(a.aggs,b.toJSON()),this},agg:function(b){return this.aggregation(b)},filter:function(b){if(null==b){return a.filter}if(!ai(b)){throw new TypeError("Argument must be a Filter")}return a.filter=b.toJSON(),this},highlight:function(b){if(null==b){return a.highlight}if(!aa(b)){throw new TypeError("Argument must be a Highlight object")}return a.highlight=b.toJSON(),this},suggest:function(b){if(null==b){return a.suggest}if(null==a.suggest&&(a.suggest={}),ap(b)){a.suggest.text=b}else{if(!Z(b)){throw new TypeError("Argument must be a string or Suggest object")}au(a.suggest,b.toJSON())}return this},scriptField:function(b){if(null==b){return a.script_fields}if(null==a.script_fields&&(a.script_fields={}),!af(b)){throw new TypeError("Argument must be a ScriptField")}return au(a.script_fields,b.toJSON()),this},indexBoost:function(b,d){return null==a.indices_boost&&(a.indices_boost={}),0===arguments.length?a.indices_boost:(a.indices_boost[b]=d,this)},explain:function(b){return null==b?a.explain:(a.explain=b,this)},version:function(b){return null==b?a.version:(a.version=b,this)},minScore:function(b){return null==b?a.min_score:(a.min_score=b,this)},_type:function(){return"request"},toJSON:function(){return a}}},W.Rescore=function(e,d){if(null!=e&&!ao(e)){throw new TypeError("Argument must be a Number")}if(null!=d&&!ak(d)){throw new TypeError("Argument must be a Query")}var f={query:{}};return null!=e&&(f.window_size=e),null!=d&&(f.query.rescore_query=d.toJSON()),{rescoreQuery:function(b){if(null==b){return f.query.rescore_query}if(!ak(b)){throw new TypeError("Argument must be a Query")}return f.query.rescore_query=b.toJSON(),this},queryWeight:function(b){if(null==b){return f.query.query_weight}if(!ao(b)){throw new TypeError("Argument must be a Number")}return f.query.query_weight=b,this},rescoreQueryWeight:function(b){if(null==b){return f.query.rescore_query_weight}if(!ao(b)){throw new TypeError("Argument must be a Number")}return f.query.rescore_query_weight=b,this},windowSize:function(b){if(null==b){return f.window_size}if(!ao(b)){throw new TypeError("Argument must be a Number")}return f.window_size=b,this},scoreMode:function(b){return null==b?f.query.score_mode:(b=b.toLowerCase(),("total"===b||"min"===b||"max"===b||"multiply"===b||"avg"===b)&&(f.query.score_mode=b),this)},_type:function(){return"rescore"},toJSON:function(){return f}}},W.ScriptField=function(d){var c={};return c[d]={},{lang:function(a){return null==a?c[d].lang:(c[d].lang=a,this)},script:function(a){return null==a?c[d].script:(c[d].script=a,this)},params:function(a){return null==a?c[d].params:(c[d].params=a,this)},ignoreFailure:function(a){return null==a?c[d].ignore_failure:(c[d].ignore_failure=a,this)},_type:function(){return"script field"},toJSON:function(){return c}}},W.Shape=function(f,e){var h={},g=function(d){var c=!1;return("point"===d||"linestring"===d||"polygon"===d||"multipoint"===d||"envelope"===d||"multipolygon"===d||"circle"===d||"multilinestring"===d)&&(c=!0),c};return f=f.toLowerCase(),g(f)&&(h.type=f,h.coordinates=e),{type:function(b){return null==b?h.type:(b=b.toLowerCase(),g(b)&&(h.type=b),this)},coordinates:function(b){return null==b?h.coordinates:(h.coordinates=b,this)},radius:function(b){return null==b?h.radius:(h.radius=b,this)},_type:function(){return"shape"},toJSON:function(){return h}}},W.Sort=function(g){null==g&&(g="_score");var f={},j=g,i="_geo_distance",h="_script";return f[j]={},{field:function(b){var a=f[j];return null==b?g:(delete f[j],g=b,j=b,f[j]=a,this)},geoDistance:function(b){var a=f[j];if(null==b){return f[j][g]}if(!ae(b)){throw new TypeError("Argument must be a GeoPoint")}return delete f[j],j=i,f[j]=a,f[j][g]=b.toJSON(),this},script:function(b){var c=f[j];return null==b?f[j].script:(delete f[j],j=h,f[j]=c,f[j].script=b,this)},order:function(b){return null==b?f[j].order:(b=b.toLowerCase(),("asc"===b||"desc"===b)&&(f[j].order=b),this)},asc:function(){return f[j].order="asc",this},desc:function(){return f[j].order="desc",this},reverse:function(b){return null==b?f[j].reverse:(f[j].reverse=b,this)},missing:function(b){return null==b?f[j].missing:(f[j].missing=b,this)},ignoreUnmapped:function(b){return null==b?f[j].ignore_unmapped:(f[j].ignore_unmapped=b,this)},unit:function(b){return null==b?f[j].unit:(b=b.toLowerCase(),("mi"===b||"km"===b)&&(f[j].unit=b),this)},normalize:function(b){return null==b?f[j].normalize:(f[j].normalize=b,this)},distanceType:function(b){return null==b?f[j].distance_type:(b=b.toLowerCase(),("arc"===b||"plane"===b)&&(f[j].distance_type=b),this)},params:function(b){return null==b?f[j].params:(f[j].params=b,this)},lang:function(b){return null==b?f[j].lang:(f[j].lang=b,this)},type:function(b){return null==b?f[j].type:(b=b.toLowerCase(),("string"===b||"number"===b)&&(f[j].type=b),this)},mode:function(b){return null==b?f[j].mode:(b=b.toLowerCase(),("min"===b||"max"===b||"sum"===b||"avg"===b)&&(f[j].mode=b),this)},nestedPath:function(b){return null==b?f[j].nested_path:(f[j].nested_path=b,this)},nestedFilter:function(b){if(null==b){return f[j].nested_filter}if(!ai(b)){throw new TypeError("Argument must be a Filter")}return f[j].nested_filter=b.toJSON(),this},_type:function(){return"sort"},toJSON:function(){return f}}},W.CompletionSuggester=function(f){var c,h=W.SuggesterMixin(f),g=h.toJSON();return g[f].completion={},c=W.SuggestContextMixin(g[f].completion),au(h,c,{fuzzy:function(a){return null==a?g[f].completion.fuzzy:(a&&null==g[f].completion.fuzzy?g[f].completion.fuzzy={}:a||null==g[f].completion.fuzzy||delete g[f].completion.fuzzy,this)},transpositions:function(a){return null==g[f].completion.fuzzy&&(g[f].completion.fuzzy={}),null==a?g[f].completion.fuzzy.transpositions:(g[f].completion.fuzzy.transpositions=a,this)},unicodeAware:function(a){return null==g[f].completion.fuzzy&&(g[f].completion.fuzzy={}),null==a?g[f].completion.fuzzy.unicode_aware:(g[f].completion.fuzzy.unicode_aware=a,this)},editDistance:function(a){return null==g[f].completion.fuzzy&&(g[f].completion.fuzzy={}),null==a?g[f].completion.fuzzy.edit_distance:(g[f].completion.fuzzy.edit_distance=a,this)},minLength:function(a){return null==g[f].completion.fuzzy&&(g[f].completion.fuzzy={}),null==a?g[f].completion.fuzzy.min_length:(g[f].completion.fuzzy.min_length=a,this)},prefixLength:function(a){return null==g[f].completion.fuzzy&&(g[f].completion.fuzzy={}),null==a?g[f].completion.fuzzy.prefix_length:(g[f].completion.fuzzy.prefix_length=a,this)}})},W.DirectGenerator=function(){var d={},c=W.DirectSettingsMixin(d);return au(c,{preFilter:function(a){return null==a?d.pre_filter:(d.pre_filter=a,this)},postFilter:function(a){return null==a?d.post_filter:(d.post_filter=a,this)},field:function(a){return null==a?d.field:(d.field=a,this)},size:function(a){return null==a?d.size:(d.size=a,this)},_type:function(){return"generator"},toJSON:function(){return d}})},W.PhraseSuggester=function(e){var c,h=W.SuggesterMixin(e),g=h.toJSON();return g[e].phrase={},c=W.SuggestContextMixin(g[e].phrase),au(h,c,{realWordErrorLikelihood:function(a){return null==a?g[e].phrase.real_word_error_likelihood:(g[e].phrase.real_word_error_likelihood=a,this)},confidence:function(a){return null==a?g[e].phrase.confidence:(g[e].phrase.confidence=a,this)},separator:function(a){return null==a?g[e].phrase.separator:(g[e].phrase.separator=a,this)},maxErrors:function(a){return null==a?g[e].phrase.max_errors:(g[e].phrase.max_errors=a,this)},gramSize:function(a){return null==a?g[e].phrase.gram_size:(g[e].phrase.gram_size=a,this)},forceUnigrams:function(a){return null==a?g[e].phrase.force_unigrams:(g[e].phrase.force_unigrams=a,this)},tokenLimit:function(a){return null==a?g[e].phrase.token_limit:(g[e].phrase.token_limit=a,this)},linearSmoothing:function(a,i,f){return 0===arguments.length?g[e].phrase.smoothing:(g[e].phrase.smoothing={linear:{trigram_lambda:a,bigram_lambda:i,unigram_lambda:f}},this)},laplaceSmoothing:function(a){return null==a?g[e].phrase.smoothing:(g[e].phrase.smoothing={laplace:{alpha:a}},this)},stupidBackoffSmoothing:function(a){return null==a?g[e].phrase.smoothing:(g[e].phrase.smoothing={stupid_backoff:{discount:a}},this)},highlight:function(a,d){return 0===arguments.length?g[e].phrase.highlight:(g[e].phrase.highlight={pre_tag:a,post_tag:d},this)},directGenerator:function(a){var i,f;if(null==g[e].phrase.direct_generator&&(g[e].phrase.direct_generator=[]),null==a){return g[e].phrase.direct_generator}if(Y(a)){g[e].phrase.direct_generator.push(a.toJSON())}else{if(!ar(a)){throw new TypeError("Argument must be a Generator or array of Generators")}for(g[e].phrase.direct_generator=[],i=0,f=a.length;f>i;i++){if(!Y(a[i])){throw new TypeError("Argument must be an array of Generators")}g[e].phrase.direct_generator.push(a[i].toJSON())}}return this}})},W.TermSuggester=function(g){var c,j,i=W.SuggesterMixin(g),h=i.toJSON();return h[g].term={},c=W.DirectSettingsMixin(h[g].term),j=W.SuggestContextMixin(h[g].term),au(i,c,j)},W.noConflict=function(){return V.ejs=U,this}}).call(this);