The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/common/lib/elastic.min.js

4 lines
100 KiB

/*! elastic.js - v1.0.0 - 2013-04-04
* https://github.com/fullscale/elastic.js
* Copyright (c) 2013 FullScale Labs, LLC; Licensed MIT */
(function(){"use strict";var e=this,t=e&&e.ejs,n=Array.prototype,r=Object.prototype,i=n.slice,s=r.toString,o=r.hasOwnProperty,u=n.forEach,a=Array.isArray,f={},l,c,h,p,d,v,m,g,y,b,w,E,S,x,T,N,C,k,L,A,O;typeof exports!="undefined"?O=exports:O=e.ejs={},l=function(e,t){return o.call(e,t)},c=function(e,t,n){if(e==null)return;if(u&&e.forEach===u)e.forEach(t,n);else if(e.length===+e.length){for(var r=0,i=e.length;r<i;r++)if(t.call(n,e[r],r,e)===f)return}else for(var s in e)if(l(e,s)&&t.call(n,e[s],s,e)===f)return},h=function(e){return c(i.call(arguments,1),function(t){for(var n in t)e[n]=t[n]}),e},p=a||function(e){return s.call(e)==="[object Array]"},d=function(e){return e===Object(e)},v=function(e){return s.call(e)==="[object String]"},m=function(e){return s.call(e)==="[object Number]"},typeof /./!="function"?g=function(e){return typeof e=="function"}:g=function(e){return s.call(e)==="[object Function]"},y=function(e){return d(e)&&l(e,"_type")&&l(e,"_self")&&l(e,"toString")},b=function(e){return y(e)&&e._type()==="query"},w=function(e){return y(e)&&e._type()==="filter"},E=function(e){return y(e)&&e._type()==="facet"},S=function(e){return y(e)&&e._type()==="script field"},x=function(e){return y(e)&&e._type()==="geo point"},T=function(e){return y(e)&&e._type()==="indexed shape"},N=function(e){return y(e)&&e._type()==="shape"},C=function(e){return y(e)&&e._type()==="sort"},k=function(e){return y(e)&&e._type()==="highlight"},L=function(e){return y(e)&&e._type()==="suggest"},A=function(e){return y(e)&&e._type()==="generator"},O.DateHistogramFacet=function(e){var t={};return t[e]={date_histogram:{}},{field:function(n){return n==null?t[e].date_histogram.field:(t[e].date_histogram.field=n,this)},keyField:function(n){return n==null?t[e].date_histogram.key_field:(t[e].date_histogram.key_field=n,this)},valueField:function(n){return n==null?t[e].date_histogram.value_field:(t[e].date_histogram.value_field=n,this)},interval:function(n){return n==null?t[e].date_histogram.interval:(t[e].date_histogram.interval=n,this)},timeZone:function(n){return n==null?t[e].date_histogram.time_zone:(t[e].date_histogram.time_zone=n,this)},preZone:function(n){return n==null?t[e].date_histogram.pre_zone:(t[e].date_histogram.pre_zone=n,this)},preZoneAdjustLargeInterval:function(n){return n==null?t[e].date_histogram.pre_zone_adjust_large_interval:(t[e].date_histogram.pre_zone_adjust_large_interval=n,this)},postZone:function(n){return n==null?t[e].date_histogram.post_zone:(t[e].date_histogram.post_zone=n,this)},preOffset:function(n){return n==null?t[e].date_histogram.pre_offset:(t[e].date_histogram.pre_offset=n,this)},postOffset:function(n){return n==null?t[e].date_histogram.post_offset:(t[e].date_histogram.post_offset=n,this)},factor:function(n){return n==null?t[e].date_histogram.factor:(t[e].date_histogram.factor=n,this)},valueScript:function(n){return n==null?t[e].date_histogram.value_script:(t[e].date_histogram.value_script=n,this)},order:function(n){if(n==null)return t[e].date_histogram.order;n=n.toLowerCase();if(n==="time"||n==="count"||n==="total")t[e].date_histogram.order=n;return this},lang:function(n){return n==null?t[e].date_histogram.lang:(t[e].date_histogram.lang=n,this)},params:function(n){return n==null?t[e].date_histogram.params:(t[e].date_histogram.params=n,this)},facetFilter:function(n){if(n==null)return t[e].facet_filter;if(!w(n))throw new TypeError("Argument must be a Filter");return t[e].facet_filter=n._self(),this},global:function(n){return n==null?t[e].global:(t[e].global=n,this)},mode:function(n){if(n==null)return t[e].mode;n=n.toLowerCase();if(n==="collector"||n==="post")t[e].mode=n;return this},scope:function(e){return this},cacheFilter:function(n){return n==null?t[e].cache_filter:(t[e].cache_filter=n,this)},nested:function(n){return n==null?t[e].nested:(t[e].nested=n,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"facet"},_self:function(){return t}}},O.FilterFacet=function(e){var t={};return t[e]={},{filter:function(n){if(n==null)return t[e].filter;if(!w(n))throw new TypeError("Argument must be a Filter");return t[e].filter=n._self(),this},facetFilter:function(n){if(n==null)return t[e].facet_filter;if(!w(n))throw new TypeError("Argument must be a Filter");return t[e].facet_filter=n._self(),this},global:function(n){return n==null?t[e].global:(t[e].global=n,this)},mode:function(n){if(n==null)return t[e].mode;n=n.toLowerCase();if(n==="collector"||n==="post")t[e].mode=n;return this},scope:function(e){return this},cacheFilter:function(n){return n==null?t[e].cache_filter:(t[e].cache_filter=n,this)},nested:function(n){return n==null?t[e].nested:(t[e].nested=n,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"facet"},_self:function(){return t}}},O.GeoDistanceFacet=function(e){var t={},n=O.GeoPoint([0,0]),r="location";return t[e]={geo_distance:{location:n._self(),ranges:[]}},{field:function(n){var i=t[e].geo_distance[r];return n==null?r:(delete t[e].geo_distance[r],r=n,t[e].geo_distance[n]=i,this)},point:function(i){if(i==null)return n;if(!x(i))throw new TypeError("Argument must be a GeoPoint");return n=i,t[e].geo_distance[r]=i._self(),this},addRange:function(n,r){return arguments.length===0?t[e].geo_distance.ranges:(t[e].geo_distance.ranges.push({from:n,to:r}),this)},addUnboundedFrom:function(n){return n==null?t[e].geo_distance.ranges:(t[e].geo_distance.ranges.push({from:n}),this)},addUnboundedTo:function(n){return n==null?t[e].geo_distance.ranges:(t[e].geo_distance.ranges.push({to:n}),this)},unit:function(n){if(n==null)return t[e].geo_distance.unit;n=n.toLowerCase();if(n==="mi"||n==="km")t[e].geo_distance.unit=n;return this},distanceType:function(n){if(n==null)return t[e].geo_distance.distance_type;n=n.toLowerCase();if(n==="arc"||n==="plane")t[e].geo_distance.distance_type=n;return this},normalize:function(n){return n==null?t[e].geo_distance.normalize:(t[e].geo_distance.normalize=n,this)},valueField:function(n){return n==null?t[e].geo_distance.value_field:(t[e].geo_distance.value_field=n,this)},valueScript:function(n){return n==null?t[e].geo_distance.value_script:(t[e].geo_distance.value_script=n,this)},lang:function(n){return n==null?t[e].geo_distance.lang:(t[e].geo_distance.lang=n,this)},params:function(n){return n==null?t[e].geo_distance.params:(t[e].geo_distance.params=n,this)},facetFilter:function(n){if(n==null)return t[e].facet_filter;if(!w(n))throw new TypeError("Argument must be a Filter");return t[e].facet_filter=n._self(),this},global:function(n){return n==null?t[e].global:(t[e].global=n,this)},mode:function(n){if(n==null)return t[e].mode;n=n.toLowerCase();if(n==="collector"||n==="post")t[e].mode=n;return this},scope:function(e){return this},cacheFilter:function(n){return n==null?t[e].cache_filter:(t[e].cache_filter=n,this)},nested:function(n){return n==null?t[e].nested:(t[e].nested=n,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"facet"},_self:function(){return t}}},O.HistogramFacet=function(e){var t={};return t[e]={histogram:{}},{field:function(n){return n==null?t[e].histogram.field:(t[e].histogram.field=n,this)},interval:function(n){return n==null?t[e].histogram.interval:(t[e].histogram.interval=n,this)},timeInterval:function(n){return n==null?t[e].histogram.time_interval:(t[e].histogram.time_interval=n,this)},from:function(n){return n==null?t[e].histogram.from:(t[e].histogram.from=n,this)},to:function(n){return n==null?t[e].histogram.to:(t[e].histogram.to=n,this)},valueField:function(n){return n==null?t[e].histogram.value_field:(t[e].histogram.value_field=n,this)},keyField:function(n){return n==null?t[e].histogram.key_field:(t[e].histogram.key_field=n,this)},valueScript:function(n){return n==null?t[e].histogram.value_script:(t[e].histogram.value_script=n,this)},keyScript:function(n){return n==null?t[e].histogram.key_script:(t[e].histogram.key_script=n,this)},lang:function(n){return n==null?t[e].histogram.lang:(t[e].histogram.lang=n,this)},params:function(n){return n==null?t[e].histogram.params:(t[e].histogram.params=n,this)},order:function(n){if(n==null)return t[e].histogram.order;n=n.toLowerCase();if(n==="key"||n==="count"||n==="total")t[e].histogram.order=n;return this},facetFilter:function(n){if(n==null)return t[e].facet_filter;if(!w(n))throw new TypeError("Argument must be a Filter");return t[e].facet_filter=n._self(),this},global:function(n){return n==null?t[e].global:(t[e].global=n,this)},mode:function(n){if(n==null)return t[e].mode;n=n.toLowerCase();if(n==="collector"||n==="post")t[e].mode=n;return this},scope:function(e){return this},cacheFilter:function(n){return n==null?t[e].cache_filter:(t[e].cache_filter=n,this)},nested:function(n){return n==null?t[e].nested:(t[e].nested=n,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"facet"},_self:function(){return t}}},O.QueryFacet=function(e){var t={};return t[e]={},{query:function(n){if(n==null)return t[e].query;if(!b(n))throw new TypeError("Argument must be a Query");return t[e].query=n._self(),this},facetFilter:function(n){if(n==null)return t[e].facet_filter;if(!w(n))throw new TypeError("Argumnet must be a Filter");return t[e].facet_filter=n._self(),this},global:function(n){return n==null?t[e].global:(t[e].global=n,this)},mode:function(n){if(n==null)return t[e].mode;n=n.toLowerCase();if(n==="collector"||n==="post")t[e].mode=n;return this},scope:function(e){return this},cacheFilter:function(n){return n==null?t[e].cache_filter:(t[e].cache_filter=n,this)},nested:function(n){return n==null?t[e].nested:(t[e].nested=n,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"facet"},_self:function(){return t}}},O.RangeFacet=function(e){var t={};return t[e]={range:{ranges:[]}},{field:function(n){return n==null?t[e].range.field:(t[e].range.field=n,this)},keyField:function(n){return n==null?t[e].range.key_field:(t[e].range.key_field=n,this)},valueField:function(n){return n==null?t[e].range.value_field:(t[e].range.value_field=n,this)},valueScript:function(n){return n==null?t[e].range.value_script:(t[e].range.value_script=n,this)},keyScript:function(n){return n==null?t[e].range.key_script:(t[e].range.key_script=n,this)},lang:function(n){return n==null?t[e].range.lang:(t[e].range.lang=n,this)},params:function(n){return n==null?t[e].range.params:(t[e].range.params=n,this)},addRange:function(n,r){return arguments.length===0?t[e].range.ranges:(t[e].range.ranges.push({from:n,to:r}),this)},addUnboundedFrom:function(n){return n==null?t[e].range.ranges:(t[e].range.ranges.push({from:n}),this)},addUnboundedTo:function(n){return n==null?t[e].range.ranges:(t[e].range.ranges.push({to:n}),this)},facetFilter:function(n){if(n==null)return t[e].facet_filter;if(!w(n))throw new TypeError("Argument must be a Filter");return t[e].facet_filter=n._self(),this},global:function(n){return n==null?t[e].global:(t[e].global=n,this)},mode:function(n){if(n==null)return t[e].mode;n=n.toLowerCase();if(n==="collector"||n==="post")t[e].mode=n;return this},scope:function(e){return this},cacheFilter:function(n){return n==null?t[e].cache_filter:(t[e].cache_filter=n,this)},nested:function(n){return n==null?t[e].nested:(t[e].nested=n,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"facet"},_self:function(){return t}}},O.StatisticalFacet=function(e){var t={};return t[e]={statistical:{}},{field:function(n){return n==null?t[e].statistical.field:(t[e].statistical.field=n,this)},fields:function(n){if(n==null)return t[e].statistical.fields;if(!p(n))throw new TypeError("Argument must be an array");return t[e].statistical.fields=n,this},script:function(n){return n==null?t[e].statistical.script:(t[e].statistical.script=n,this)},lang:function(n){return n==null?t[e].statistical.lang:(t[e].statistical.lang=n,this)},params:function(n){return n==null?t[e].statistical.params:(t[e].statistical.params=n,this)},facetFilter:function(n){if(n==null)return t[e].facet_filter;if(!w(n))throw new TypeError("Argument must be a Filter");return t[e].facet_filter=n._self(),this},global:function(n){return n==null?t[e].global:(t[e].global=n,this)},mode:function(n){if(n==null)return t[e].mode;n=n.toLowerCase();if(n==="collector"||n==="post")t[e].mode=n;return this},scope:function(e){return this},cacheFilter:function(n){return n==null?t[e].cache_filter:(t[e].cache_filter=n,this)},nested:function(n){return n==null?t[e].nested:(t[e].nested=n,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"facet"},_self:function(){return t}}},O.TermStatsFacet=function(e){var t={};return t[e]={terms_stats:{}},{valueField:function(n){return n==null?t[e].terms_stats.value_field:(t[e].terms_stats.value_field=n,this)},keyField:function(n){return n==null?t[e].terms_stats.key_field:(t[e].terms_stats.key_field=n,this)},scriptField:function(n){return n==null?t[e].terms_stats.script_field:(t[e].terms_stats.script_field=n,this)},valueScript:function(n){return n==null?t[e].terms_stats.value_script:(t[e].terms_stats.value_script=n,this)},allTerms:function(n){return n==null?t[e].terms_stats.all_terms:(t[e].terms_stats.all_terms=n,this)},lang:function(n){return n==null?t[e].terms_stats.lang:(t[e].terms_stats.lang=n,this)},params:function(n){return n==null?t[e].terms_stats.params:(t[e].terms_stats.params=n,this)},size:function(n){return n==null?t[e].terms_stats.size:(t[e].terms_stats.size=n,this)},order:function(n){if(n==null)return t[e].terms_stats.order;n=n.toLowerCase();if(n==="count"||n==="term"||n==="reverse_count"||n==="reverse_term"||n==="total"||n==="reverse_total"||n==="min"||n==="reverse_min"||n==="max"||n==="reverse_max"||n==="mean"||n==="reverse_mean")t[e].terms_stats.order=n;return this},facetFilter:function(n){if(n==null)return t[e].facet_filter;if(!w(n))throw new TypeError("Argument must be a Filter");return t[e].facet_filter=n._self(),this},global:function(n){return n==null?t[e].global:(t[e].global=n,this)},mode:function(n){if(n==null)return t[e].mode;n=n.toLowerCase();if(n==="collector"||n==="post")t[e].mode=n;return this},scope:function(e){return this},cacheFilter:function(n){return n==null?t[e].cache_filter:(t[e].cache_filter=n,this)},nested:function(n){return n==null?t[e].nested:(t[e].nested=n,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"facet"},_self:function(){return t}}},O.TermsFacet=function(e){var t={};return t[e]={terms:{}},{field:function(n){return n==null?t[e].terms.field:(t[e].terms.field=n,this)},fields:function(n){if(n==null)return t[e].terms.fields;if(!p(n))throw new TypeError("Argument must be an array");return t[e].terms.fields=n,this},scriptField:function(n){return n==null?t[e].terms.script_field:(t[e].terms.script_field=n,this)},size:function(n){return n==null?t[e].terms.size:(t[e].terms.size=n,this)},order:function(n){if(n==null)return t[e].terms.order;n=n.toLowerCase();if(n==="count"||n==="term"||n==="reverse_count"||n==="reverse_term")t[e].terms.order=n;return this},allTerms:function(n){return n==null?t[e].terms.all_terms:(t[e].terms.all_terms=n,this)},exclude:function(n){t[e].terms.exclude==null&&(t[e].terms.exclude=[]);if(n==null)return t[e].terms.exclude;if(v(n))t[e].terms.exclude.push(n);else{if(!p(n))throw new TypeError("Argument must be string or array");t[e].terms.exclude=n}return this},regex:function(n){return n==null?t[e].terms.regex:(t[e].terms.regex=n,this)},regexFlags:function(n){return n==null?t[e].terms.regex_flags:(t[e].terms.regex_flags=n,this)},script:function(n){return n==null?t[e].terms.script:(t[e].terms.script=n,this)},lang:function(n){return n==null?t[e].terms.lang:(t[e].terms.lang=n,this)},params:function(n){return n==null?t[e].terms.params:(t[e].terms.params=n,this)},executionHint:function(n){return n==null?t[e].terms.execution_hint:(t[e].terms.execution_hint=n,this)},facetFilter:function(n){if(n==null)return t[e].facet_filter;if(!w(n))throw new TypeError("Argument must be a Filter");return t[e].facet_filter=n._self(),this},global:function(n){return n==null?t[e].global:(t[e].global=n,this)},mode:function(n){if(n==null)return t[e].mode;n=n.toLowerCase();if(n==="collector"||n==="post")t[e].mode=n;return this},scope:function(e){return this},cacheFilter:function(n){return n==null?t[e].cache_filter:(t[e].cache_filter=n,this)},nested:function(n){return n==null?t[e].nested:(t[e].nested=n,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"facet"},_self:function(){return t}}},O.AndFilter=function(e){var t,n,r={and:{filters:[]}};if(w(e))r.and.filters.push(e._self());else{if(!p(e))throw new TypeError("Argument must be a Filter or Array of Filters");for(t=0,n=e.length;t<n;t++){if(!w(e[t]))throw new TypeError("Array must contain only Filter objects");r.and.filters.push(e[t]._self())}}return{filters:function(e){var t,n;if(e==null)return r.and.filters;if(w(e))r.and.filters.push(e._self());else{if(!p(e))throw new TypeError("Argument must be a Filter or an Array of Filters");r.and.filters=[];for(t=0,n=e.length;t<n;t++){if(!w(e[t]))throw new TypeError("Array must contain only Filter objects");r.and.filters.push(e[t]._self())}}return this},name:function(e){return e==null?r.and._name:(r.and._name=e,this)},cache:function(e){return e==null?r.and._cache:(r.and._cache=e,this)},cacheKey:function(e){return e==null?r.and._cache_key:(r.and._cache_key=e,this)},toString:function(){return JSON.stringify(r)},_type:function(){return"filter"},_self:function(){return r}}},O.BoolFilter=function(){var e={bool:{}};return{must:function(t){var n,r;e.bool.must==null&&(e.bool.must=[]);if(t==null)return e.bool.must;if(w(t))e.bool.must.push(t._self());else{if(!p(t))throw new TypeError("Argument must be a Filter or array of Filters");e.bool.must=[];for(n=0,r=t.length;n<r;n++){if(!w(t[n]))throw new TypeError("Argument must be an array of Filters");e.bool.must.push(t[n]._self())}}return this},mustNot:function(t){var n,r;e.bool.must_not==null&&(e.bool.must_not=[]);if(t==null)return e.bool.must_not;if(w(t))e.bool.must_not.push(t._self());else{if(!p(t))throw new TypeError("Argument must be a Filter or array of Filters");e.bool.must_not=[];for(n=0,r=t.length;n<r;n++){if(!w(t[n]))throw new TypeError("Argument must be an array of Filters");e.bool.must_not.push(t[n]._self())}}return this},should:function(t){var n,r;e.bool.should==null&&(e.bool.should=[]);if(t==null)return e.bool.should;if(w(t))e.bool.should.push(t._self());else{if(!p(t))throw new TypeError("Argument must be a Filter or array of Filters");e.bool.should=[];for(n=0,r=t.length;n<r;n++){if(!w(t[n]))throw new TypeError("Argument must be an array of Filters");e.bool.should.push(t[n]._self())}}return this},name:function(t){return t==null?e.bool._name:(e.bool._name=t,this)},cache:function(t){return t==null?e.bool._cache:(e.bool._cache=t,this)},cacheKey:function(t){return t==null?e.bool._cache_key:(e.bool._cache_key=t,this)},toString:function(){return JSON.stringify(e)},_type:function(){return"filter"},_self:function(){return e}}},O.ExistsFilter=function(e){var t={exists:{field:e}};return{field:function(e){return e==null?t.exists.field:(t.exists.field=e,this)},name:function(e){return e==null?t.exists._name:(t.exists._name=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"filter"},_self:function(){return t}}},O.GeoBboxFilter=function(e){var t={geo_bounding_box:{}};return t.geo_bounding_box[e]={},{field:function(n){var r=t.geo_bounding_box[e];return n==null?e:(delete t.geo_bounding_box[e],e=n,t.geo_bounding_box[n]=r,this)},topLeft:function(n){if(n==null)return t.geo_bounding_box[e].top_left;if(!x(n))throw new TypeError("Argument must be a GeoPoint");return t.geo_bounding_box[e].top_left=n._self(),this},bottomRight:function(n){if(n==null)return t.geo_bounding_box[e].bottom_right;if(!x(n))throw new TypeError("Argument must be a GeoPoint");return t.geo_bounding_box[e].bottom_right=n._self(),this},type:function(e){if(e==null)return t.geo_bounding_box.type;e=e.toLowerCase();if(e==="memory"||e==="indexed")t.geo_bounding_box.type=e;return this},normalize:function(e){return e==null?t.geo_bounding_box.normalize:(t.geo_bounding_box.normalize=e,this)},name:function(e){return e==null?t.geo_bounding_box._name:(t.geo_bounding_box._name=e,this)},cache:function(e){return e==null?t.geo_bounding_box._cache:(t.geo_bounding_box._cache=e,this)},cacheKey:function(e){return e==null?t.geo_bounding_box._cache_key:(t.geo_bounding_box._cache_key=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"filter"},_self:function(){return t}}},O.GeoDistanceFilter=function(e){var t={geo_distance:{}};return t.geo_distance[e]=[0,0],{field:function(n){var r=t.geo_distance[e];return n==null?e:(delete t.geo_distance[e],e=n,t.geo_distance[n]=r,this)},distance:function(e){if(e==null)return t.geo_distance.distance;if(!m(e))throw new TypeError("Argument must be a numeric value");return t.geo_distance.distance=e,this},unit:function(e){if(e==null)return t.geo_distance.unit;e=e.toLowerCase();if(e==="mi"||e==="km")t.geo_distance.unit=e;return this},point:function(n){if(n==null)return t.geo_distance[e];if(!x(n))throw new TypeError("Argument must be a GeoPoint");return t.geo_distance[e]=n._self(),this},distanceType:function(e){if(e==null)return t.geo_distance.distance_type;e=e.toLowerCase();if(e==="arc"||e==="plane")t.geo_distance.distance_type=e;return this},normalize:function(e){return e==null?t.geo_distance.normalize:(t.geo_distance.normalize=e,this)},optimizeBbox:function(e){if(e==null)return t.geo_distance.optimize_bbox;e=e.toLowerCase();if(e==="memory"||e==="indexed"||e==="none")t.geo_distance.optimize_bbox=e;return this},name:function(e){return e==null?t.geo_distance._name:(t.geo_distance._name=e,this)},cache:function(e){return e==null?t.geo_distance._cache:(t.geo_distance._cache=e,this)},cacheKey:function(e){return e==null?t.geo_distance._cache_key:(t.geo_distance._cache_key=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"filter"},_self:function(){return t}}},O.GeoDistanceRangeFilter=function(e){var t={geo_distance_range:{}};return t.geo_distance_range[e]=[0,0],{field:function(n){var r=t.geo_distance_range[e];return n==null?e:(delete t.geo_distance_range[e],e=n,t.geo_distance_range[n]=r,this)},from:function(e){if(e==null)return t.geo_distance_range.from;if(!m(e))throw new TypeError("Argument must be a numeric value");return t.geo_distance_range.from=e,this},to:function(e){if(e==null)return t.geo_distance_range.to;if(!m(e))throw new TypeError("Argument must be a numeric value");return t.geo_distance_range.to=e,this},includeLower:function(e){return e==null?t.geo_distance_range.include_lower:(t.geo_distance_range.include_lower=e,this)},includeUpper:function(e){return e==null?t.geo_distance_range.include_upper:(t.geo_distance_range.include_upper=e,this)},gt:function(e){if(e==null)return t.geo_distance_range.gt;if(!m(e))throw new TypeError("Argument must be a numeric value");return t.geo_distance_range.gt=e,this},gte:function(e){if(e==null)return t.geo_distance_range.gte;if(!m(e))throw new TypeError("Argument must be a numeric value");return t.geo_distance_range.gte=e,this},lt:function(e){if(e==null)return t.geo_distance_range.lt;if(!m(e))throw new TypeError("Argument must be a numeric value");return t.geo_distance_range.lt=e,this},lte:function(e){if(e==null)return t.geo_distance_range.lte;if(!m(e))throw new TypeError("Argument must be a numeric value");return t.geo_distance_range.lte=e,this},unit:function(e){if(e==null)return t.geo_distance_range.unit;e=e.toLowerCase();if(e==="mi"||e==="km")t.geo_distance_range.unit=e;return this},point:function(n){if(n==null)return t.geo_distance_range[e];if(!x(n))throw new TypeError("Argument must be a GeoPoint");return t.geo_distance_range[e]=n._self(),this},distanceType:function(e){if(e==null)return t.geo_distance_range.distance_type;e=e.toLowerCase();if(e==="arc"||e==="plane")t.geo_distance_range.distance_type=e;return this},normalize:function(e){return e==null?t.geo_distance_range.normalize:(t.geo_distance_range.normalize=e,this)},optimizeBbox:function(e){if(e==null)return t.geo_distance_range.optimize_bbox;e=e.toLowerCase();if(e==="memory"||e==="indexed"||e==="none")t.geo_distance_range.optimize_bbox=e;return this},name:function(e){return e==null?t.geo_distance_range._name:(t.geo_distance_range._name=e,this)},cache:function(e){return e==null?t.geo_distance_range._cache:(t.geo_distance_range._cache=e,this)},cacheKey:function(e){return e==null?t.geo_distance_range._cache_key:(t.geo_distance_range._cache_key=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"filter"},_self:function(){return t}}},O.GeoPolygonFilter=function(e){var t={geo_polygon:{}};return t.geo_polygon[e]={points:[]},{field:function(n){var r=t.geo_polygon[e];return n==null?e:(delete t.geo_polygon[e],e=n,t.geo_polygon[n]=r,this)},points:function(n){var r,i;if(n==null)return t.geo_polygon[e].points;if(x(n))t.geo_polygon[e].points.push(n._self());else{if(!p(n))throw new TypeError("Argument must be a GeoPoint or Array of GeoPoints");t.geo_polygon[e].points=[];for(r=0,i=n.length;r<i;r++){if(!x(n[r]))throw new TypeError("Argument must be Array of GeoPoints");t.geo_polygon[e].points.push(n[r]._self())}}return this},normalize:function(e){return e==null?t.geo_polygon.normalize:(t.geo_polygon.normalize=e,this)},name:function(e){return e==null?t.geo_polygon._name:(t.geo_polygon._name=e,this)},cache:function(e){return e==null?t.geo_polygon._cache:(t.geo_polygon._cache=e,this)},cacheKey:function(e){return e==null?t.geo_polygon._cache_key:(t.geo_polygon._cache_key=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"filter"},_self:function(){return t}}},O.GeoShapeFilter=function(e){var t={geo_shape:{}};return t.geo_shape[e]={},{field:function(n){var r=t.geo_shape[e];return n==null?e:(delete t.geo_shape[e],e=n,t.geo_shape[n]=r,this)},shape:function(n){return n==null?t.geo_shape[e].shape:(t.geo_shape[e].indexed_shape!=null&&delete t.geo_shape[e].indexed_shape,t.geo_shape[e].shape=n._self(),this)},indexedShape:function(n){return n==null?t.geo_shape[e].indexed_shape:(t.geo_shape[e].shape!=null&&delete t.geo_shape[e].shape,t.geo_shape[e].indexed_shape=n._self(),this)},relation:function(n){if(n==null)return t.geo_shape[e].relation;n=n.toLowerCase();if(n==="intersects"||n==="disjoint"||n==="within")t.geo_shape[e].relation=n;return this},strategy:function(n){if(n==null)return t.geo_shape[e].strategy;n=n.toLowerCase();if(n==="recursive"||n==="term")t.geo_shape[e].strategy=n;return this},name:function(e){return e==null?t.geo_shape._name:(t.geo_shape._name=e,this)},cache:function(e){return e==null?t.geo_shape._cache:(t.geo_shape._cache=e,this)},cacheKey:function(e){return e==null?t.geo_shape._cache_key:(t.geo_shape._cache_key=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"filter"},_self:function(){return t}}},O.HasChildFilter=function(e,t){if(!b(e))throw new TypeError("No Query object found");var n={has_child:{query:e._self(),type:t}};return{query:function(e){if(e==null)return n.has_child.query;if(!b(e))throw new TypeError("Argument must be a Query object");return n.has_child.query=e._self(),this},filter:function(e){if(e==null)return n.has_child.filter;if(!w(e))throw new TypeError("Argument must be a Filter object");return n.has_child.filter=e._self(),this},type:function(e){return e==null?n.has_child.type:(n.has_child.type=e,this)},scope:function(e){return this},name:function(e){return e==null?n.has_child._name:(n.has_child._name=e,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"filter"},_self:function(){return n}}},O.HasParentFilter=function(e,t){if(!b(e))throw new TypeError("No Query object found");var n={has_parent:{query:e._self(),parent_type:t}};return{query:function(e){if(e==null)return n.has_parent.query;if(!b(e))throw new TypeError("Argument must be a Query object");return n.has_parent.query=e._self(),this},filter:function(e){if(e==null)return n.has_parent.filter;if(!w(e))throw new TypeError("Argument must be a Filter object");return n.has_parent.filter=e._self(),this},parentType:function(e){return e==null?n.has_parent.parent_type:(n.has_parent.parent_type=e,this)},scope:function(e){return this},name:function(e){return e==null?n.has_parent._name:(n.has_parent._name=e,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"filter"},_self:function(){return n}}},O.IdsFilter=function(e){var t={ids:{}};if(v(e))t.ids.values=[e];else{if(!p(e))throw new TypeError("Argument must be a string or an array");t.ids.values=e}return{values:function(e){if(e==null)return t.ids.values;if(v(e))t.ids.values.push(e);else{if(!p(e))throw new TypeError("Argument must be a string or an array");t.ids.values=e}return this},type:function(e){t.ids.type==null&&(t.ids.type=[]);if(e==null)return t.ids.type;if(v(e))t.ids.type.push(e);else{if(!p(e))throw new TypeError("Argument must be a string or an array");t.ids.type=e}return this},name:function(e){return e==null?t.ids._name:(t.ids._name=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"filter"},_self:function(){return t}}},O.IndicesFilter=function(e,t){if(!w(e))throw new TypeError("Argument must be a Filter");var n={indices:{filter:e._self()}};if(v(t))n.indices.indices=[t];else{if(!p(t))throw new TypeError("Argument must be a string or array");n.indices.indices=t}return{indices:function(e){if(e==null)return n.indices.indices;if(v(e))n.indices.indices.push(e);else{if(!p(e))throw new TypeError("Argument must be a string or array");n.indices.indices=e}return this},filter:function(e){if(e==null)return n.indices.filter;if(!w(e))throw new TypeError("Argument must be a Filter");return n.indices.filter=e._self(),this},noMatchFilter:function(e){if(e==null)return n.indices.no_match_filter;if(v(e)){e=e.toLowerCase();if(e==="none"||e==="all")n.indices.no_match_filter=e}else{if(!w(e))throw new TypeError("Argument must be string or Filter");n.indices.no_match_filter=e._self()}return this},toString:function(){return JSON.stringify(n)},_type:function(){return"filter"},_self:function(){return n}}},O.LimitFilter=function(e){var t={limit:{value:e}};return{value:function(e){if(e==null)return t.limit.value;if(!m(e))throw new TypeError("Argument must be a numeric value");return t.limit.value=e,this},toString:function(){return JSON.stringify(t)},_type:function(){return"filter"},_self:function(){return t}}},O.MatchAllFilter=function(){var e={match_all:{}};return{toString:function(){return JSON.stringify(e)},_type:function(){return"filter"},_self:function(){return e}}},O.MissingFilter=function(e){var t={missing:{field:e}};return{field:function(e){return e==null?t.missing.field:(t.missing.field=e,this)},existence:function(e){return e==null?t.missing.existence:(t.missing.existence=e,this)},nullValue:function(e){return e==null?t.missing.null_value:(t.missing.null_value=e,this)},name:function(e){return e==null?t.missing._name:(t.missing._name=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"filter"},_self:function(){return t}}},O.NestedFilter=function(e){var t={nested:{path:e}};return{path:function(e){return e==null?t.nested.path:(t.nested.path=e,this)},query:function(e){if(e==null)return t.nested.query;if(!b(e))throw new TypeError("Argument must be a Query object");return t.nested.query=e._self(),this},filter:function(e){if(e==null)return t.nested.filter;if(!w(e))throw new TypeError("Argument must be a Filter object");return t.nested.filter=e._self(),this},boost:function(e){return e==null?t.nested.boost:(t.nested.boost=e,this)},join:function(e){return e==null?t.nested.join:(t.nested.join=e,this)},scope:function(e){return this},name:function(e){return e==null?t.nested._name:(t.nested._name=e,this)},cache:function(e){return e==null?t.nested._cache:(t.nested._cache=e,this)},cacheKey:function(e){return e==null?t.nested._cache_key:(t.nested._cache_key=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"filter"},_self:function(){return t}}},O.NotFilter=function(e){if(!w(e))throw new TypeError("Argument must be a Filter");var t={not:e._self()};return{filter:function(e){if(e==null)return t.not;if(!w(e))throw new TypeError("Argument must be a Filter");return t.not=e._self(),this},name:function(e){return e==null?t.not._name:(t.not._name=e,this)},cache:function(e){return e==null?t.not._cache:(t.not._cache=e,this)},cacheKey:function(e){return e==null?t.not._cache_key:(t.not._cache_key=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"filter"},_self:function(){return t}}},O.NumericRangeFilter=function(e){var t={numeric_range:{}};return t.numeric_range[e]={},{field:function(n){var r=t.numeric_range[e];return n==null?e:(delete t.numeric_range[e],e=n,t.numeric_range[e]=r,this)},from:function(n){if(n==null)return t.numeric_range[e].from;if(!m(n))throw new TypeError("Argument must be a numeric value");return t.numeric_range[e].from=n,this},to:function(n){if(n==null)return t.numeric_range[e].to;if(!m(n))throw new TypeError("Argument must be a numeric value");return t.numeric_range[e].to=n,this},includeLower:function(n){return n==null?t.numeric_range[e].include_lower:(t.numeric_range[e].include_lower=n,this)},includeUpper:function(n){return n==null?t.numeric_range[e].include_upper:(t.numeric_range[e].include_upper=n,this)},gt:function(n){if(n==null)return t.numeric_range[e].gt;if(!m(n))throw new TypeError("Argument must be a numeric value");return t.numeric_range[e].gt=n,this},gte:function(n){if(n==null)return t.numeric_range[e].gte;if(!m(n))throw new TypeError("Argument must be a numeric value");return t.numeric_range[e].gte=n,this},lt:function(n){if(n==null)return t.numeric_range[e].lt;if(!m(n))throw new TypeError("Argument must be a numeric value");return t.numeric_range[e].lt=n,this},lte:function(n){if(n==null)return t.numeric_range[e].lte;if(!m(n))throw new TypeError("Argument must be a numeric value");return t.numeric_range[e].lte=n,this},name:function(e){return e==null?t.numeric_range._name:(t.numeric_range._name=e,this)},cache:function(e){return e==null?t.numeric_range._cache:(t.numeric_range._cache=e,this)},cacheKey:function(e){return e==null?t.numeric_range._cache_key:(t.numeric_range._cache_key=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"filter"},_self:function(){return t}}},O.OrFilter=function(e){var t,n,r;t={or:{filters:[]}};if(w(e))t.or.filters.push(e._self());else{if(!p(e))throw new TypeError("Argument must be a Filter or array of Filters");for(n=0,r=e.length;n<r;n++){if(!w(e[n]))throw new TypeError("Argument must be array of Filters");t.or.filters.push(e[n]._self())}}return{filters:function(e){var n,r;if(e==null)return t.or.filters;if(w(e))t.or.filters.push(e._self());else{if(!p(e))throw new TypeError("Argument must be a Filter or array of Filters");t.or.filters=[];for(n=0,r=e.length;n<r;n++){if(!w(e[n]))throw new TypeError("Argument must be an array of Filters");t.or.filters.push(e[n]._self())}}return this},name:function(e){return e==null?t.or._name:(t.or._name=e,this)},cache:function(e){return e==null?t.or._cache:(t.or._cache=e,this)},cacheKey:function(e){return e==null?t.or._cache_key:(t.or._cache_key=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"filter"},_self:function(){return t}}},O.PrefixFilter=function(e,t){var n={prefix:{}};return n.prefix[e]=t,{field:function(t){var r=n.prefix[e];return t==null?e:(delete n.prefix[e],e=t,n.prefix[e]=r,this)},prefix:function(t){return t==null?n.prefix[e]:(n.prefix[e]=t,this)},name:function(e){return e==null?n.prefix._name:(n.prefix._name=e,this)},cache:function(e){return e==null?n.prefix._cache:(n.prefix._cache=e,this)},cacheKey:function(e){return e==null?n.prefix._cache_key:(n.prefix._cache_key=e,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"filter"},_self:function(){return n}}},O.QueryFilter=function(e){if(!b(e))throw new TypeError("Argument must be a Query");var t={fquery:{query:e._self()}};return{query:function(e){if(e==null)return t.fquery.query;if(!b(e))throw new TypeError("Argument must be a Query");return t.fquery.query=e._self(),this},name:function(e){return e==null?t.fquery._name:(t.fquery._name=e,this)},cache:function(e){return e==null?t.fquery._cache:(t.fquery._cache=e,this)},cacheKey:function(e){return e==null?t.fquery._cache_key:(t.fquery._cache_key=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"filter"},_self:function(){return t}}},O.RangeFilter=function(e){var t={range:{}};return t.range[e]={},{field:function(n){var r=t.range[e];return n==null?e:(delete t.range[e],e=n,t.range[n]=r,this)},from:function(n){return n==null?t.range[e].from:(t.range[e].from=n,this)},to:function(n){return n==null?t.range[e].to:(t.range[e].to=n,this)},includeLower:function(n){return n==null?t.range[e].include_lower:(t.range[e].include_lower=n,this)},includeUpper:function(n){return n==null?t.range[e].include_upper:(t.range[e].include_upper=n,this)},gt:function(n){return n==null?t.range[e].gt:(t.range[e].gt=n,this)},gte:function(n){return n==null?t.range[e].gte:(t.range[e].gte=n,this)},lt:function(n){return n==null?t.range[e].lt:(t.range[e].lt=n,this)},lte:function(n){return n==null?t.range[e].lte:(t.range[e].lte=n,this)},name:function(e){return e==null?t.range._name:(t.range._name=e,this)},cache:function(e){return e==null?t.range._cache:(t.range._cache=e,this)},cacheKey:function(e){return e==null?t.range._cache_key:(t.range._cache_key=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"filter"},_self:function(){return t}}},O.RegexpFilter=function(e,t){var n={regexp:{}};return n.regexp[e]={value:t},{field:function(t){var r=n.regexp[e];return t==null?e:(delete n.regexp[e],e=t,n.regexp[t]=r,this)},value:function(t){return t==null?n.regexp[e].value:(n.regexp[e].value=t,this)},flags:function(t){return t==null?n.regexp[e].flags:(n.regexp[e].flags=t,this)},flagsValue:function(t){return t==null?n.regexp[e].flags_value:(n.regexp[e].flags_value=t,this)},name:function(e){return e==null?n.regexp._name:(n.regexp._name=e,this)},cache:function(e){return e==null?n.regexp._cache:(n.regexp._cache=e,this)},cacheKey:function(e){return e==null?n.regexp._cache_key:(n.regexp._cache_key=e,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"filter"},_self:function(){return n}}},O.ScriptFilter=function(e){var t={script:{script:e}};return{script:function(e){return e==null?t.script.script:(t.script.script=e,this)},params:function(e){return e==null?t.script.params:(t.script.params=e,this)},lang:function(e){return e==null?t.script.lang:(t.script.lang=e,this)},name:function(e){return e==null?t.script._name:(t.script._name=e,this)},cache:function(e){return e==null?t.script._cache:(t.script._cache=e,this)},cacheKey:function(e){return e==null?t.script._cache_key:(t.script._cache_key=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"filter"},_self:function(){return t}}},O.TermFilter=function(e,t){var n={term:{}};return n.term[e]=t,{field:function(t){var r=n.term[e];return t==null?e:(delete n.term[e],e=t,n.term[e]=r,this)},term:function(t){return t==null?n.term[e]:(n.term[e]=t,this)},name:function(e){return e==null?n.term._name:(n.term._name=e,this)},cache:function(e){return e==null?n.term._cache:(n.term._cache=e,this)},cacheKey:function(e){return e==null?n.term._cache_key:(n.term._cache_key=e,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"filter"},_self:function(){return n}}},O.TermsFilter=function(e,t){var n={terms:{}},r=function(){p(n.terms[e])||(n.terms[e]=[])},i=function(){p(n.terms[e])&&(n.terms[e]={})};return p(t)?n.terms[e]=t:n.terms[e]=[t],{field:function(t){var r=n.terms[e];return t==null?e:(delete n.terms[e],e=t,n.terms[t]=r,this)},terms:function(t){return r(),t==null?n.terms[e]:(p(t)?n.terms[e]=t:n.terms[e].push(t),this)},index:function(t){return i(),t==null?n.terms[e].index:(n.terms[e].index=t,this)},type:function(t){return i(),t==null?n.terms[e].type:(n.terms[e].type=t,this)},id:function(t){return i(),t==null?n.terms[e].id:(n.terms[e].id=t,this)},path:function(t){return i(),t==null?n.terms[e].path:(n.terms[e].path=t,this)},execution:function(e){if(e==null)return n.terms.execution;e=e.toLowerCase();if(e==="plain"||e==="bool"||e==="bool_nocache"||e==="and"||e==="and_nocache"||e==="or"||e==="or_nocache")n.terms.execution=e;return this},name:function(e){return e==null?n.terms._name:(n.terms._name=e,this)},cache:function(e){return e==null?n.terms._cache:(n.terms._cache=e,this)},cacheKey:function(e){return e==null?n.terms._cache_key:(n.terms._cache_key=e,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"filter"},_self:function(){return n}}},O.TypeFilter=function(e){var t={type:{value:e}};return{type:function(e){return e==null?t.type.value:(t.type.value=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"filter"},_self:function(){return t}}},O.Document=function(e,t,n){var r={},i=function(){var e=s(),t=[];for(var n in e){if(!l(e,n))continue;t.push(n+"="+encodeURIComponent(e[n]))}return t.join("&")},s=function(){var e={};for(var t in r){if(!l(r,t))continue;if(t==="upsert"||t==="source"||t==="script"||t==="lang"||t==="params")continue;var n=r[t];p(n)&&(n=n.join()),e[t]=n}return e};return{index:function(t){return t==null?e:(e=t,this)},type:function(e){return e==null?t:(t=e,this)},id:function(e){return e==null?n:(n=e,this)},routing:function(e){return e==null?r.routing:(r.routing=e,this)},parent:function(e){return e==null?r.parent:(r.parent=e,this)},timestamp:function(e){return e==null?r.timestamp:(r.timestamp=e,this)},ttl:function(e){return e==null?r.ttl:(r.ttl=e,this)},timeout:function(e){return e==null?r.timeout:(r.timeout=e,this)},refresh:function(e){return e==null?r.refresh:(r.refresh=e,this)},version:function(e){return e==null?r.version:(r.version=e,this)},versionType:function(e){if(e==null)return r.version_type;e=e.toLowerCase();if(e==="internal"||e==="external")r.version_type=e;return this},percolate:function(e){return e==null?r.percolate:(r.percolate=e,this)},opType:function(e){if(e==null)return r.op_type;e=e.toLowerCase();if(e==="index"||e==="create")r.op_type=e;return this},replication:function(e){if(e==null)return r.replication;e=e.toLowerCase();if(e==="async"||e==="sync"||e==="default")r.replication=e;return this},consistency:function(e){if(e==null)return r.consistency;e=e.toLowerCase();if(e==="default"||e==="one"||e==="quorum"||e==="all")r.consistency=e;return this},preference:function(e){return e==null?r.preference:(r.preference=e,this)},realtime:function(e){return e==null?r.realtime:(r.realtime=e,this)},fields:function(e){r.fields==null&&(r.fields=[]);if(e==null)return r.fields;if(v(e))r.fields.push(e);else{if(!p(e))throw new TypeError("Argument must be string or array");r.fields=e}return this},script:function(e){return e==null?r.script:(r.script=e,this)},lang:function(e){return e==null?r.lang:(r.lang=e,this)},params:function(e){if(e==null)return r.params;if(!d(e))throw new TypeError("Argument must be an object");return r.params=e,this},retryOnConflict:function(e){return e==null?r.retry_on_conflict:(r.retry_on_conflict=e,this)},upsert:function(e){if(e==null)return r.upsert;if(!d(e))throw new TypeError("Argument must be an object");return r.upsert=e,this},source:function(e){if(e==null)return r.source;if(!d(e))throw new TypeError("Argument must be an object");return r.source=e,this},toString:function(){return JSON.stringify(r)},_type:function(){return"document"},_self:function(){return r},doGet:function(r,i){if(O.client==null)throw new Error("No Client Set");if(e==null||t==null||n==null)throw new Error("Index, Type, and ID must be set");var o="/"+e+"/"+t+"/"+n;return O.client.get(o,s(),r,i)},doIndex:function(s,o){if(O.client==null)throw new Error("No Client Set");if(e==null||t==null)throw new Error("Index and Type must be set");if(r.source==null)throw new Error("No source document found");var u="/"+e+"/"+t,a=JSON.stringify(r.source),f=i(),l;return n!=null&&(u=u+"/"+n),f!==""&&(u=u+"?"+f),n==null?l=O.client.post(u,a,s,o):l=O.client.put(u,a,s,o),l},doUpdate:function(s,o){if(O.client==null)throw new Error("No Client Set");if(e==null||t==null||n==null)throw new Error("Index, Type, and ID must be set");if(r.script==null&&r.source==null)throw new Error("Update script or document required");var u="/"+e+"/"+t+"/"+n+"/_update",a={},f=i();return f!==""&&(u=u+"?"+f),r.script!=null&&(a.script=r.script),r.lang!=null&&(a.lang=r.lang),r.params!=null&&(a.params=r.params),r.upsert!=null&&(a.upsert=r.upsert),r.source!=null&&(a.doc=r.source),O.client.post(u,JSON.stringify(a),s,o)},doDelete:function(r,s){if(O.client==null)throw new Error("No Client Set");if(e==null||t==null||n==null)throw new Error("Index, Type, and ID must be set");var o="/"+e+"/"+t+"/"+n,u="",a=i();return a!==""&&(o=o+"?"+a),O.client.del(o,u,r,s)}}},O.BoolQuery=function(){var e={bool:{}};return{must:function(t){var n,r;e.bool.must==null&&(e.bool.must=[]);if(t==null)return e.bool.must;if(b(t))e.bool.must.push(t._self());else{if(!p(t))throw new TypeError("Argument must be a Query or array of Queries");e.bool.must=[];for(n=0,r=t.length;n<r;n++){if(!b(t[n]))throw new TypeError("Argument must be an array of Queries");e.bool.must.push(t[n]._self())}}return this},mustNot:function(t){var n,r;e.bool.must_not==null&&(e.bool.must_not=[]);if(t==null)return e.bool.must_not;if(b(t))e.bool.must_not.push(t._self());else{if(!p(t))throw new TypeError("Argument must be a Query or array of Queries");e.bool.must_not=[];for(n=0,r=t.length;n<r;n++){if(!b(t[n]))throw new TypeError("Argument must be an array of Queries");e.bool.must_not.push(t[n]._self())}}return this},should:function(t){var n,r;e.bool.should==null&&(e.bool.should=[]);if(t==null)return e.bool.should;if(b(t))e.bool.should.push(t._self());else{if(!p(t))throw new TypeError("Argument must be a Query or array of Queries");e.bool.should=[];for(n=0,r=t.length;n<r;n++){if(!b(t[n]))throw new TypeError("Argument must be an array of Queries");e.bool.should.push(t[n]._self())}}return this},boost:function(t){return t==null?e.bool.boost:(e.bool.boost=t,this)},disableCoord:function(t){return t==null?e.bool.disable_coord:(e.bool.disable_coord=t,this)},minimumNumberShouldMatch:function(t){return t==null?e.bool.minimum_number_should_match:(e.bool.minimum_number_should_match=t,this)},toString:function(){return JSON.stringify(e)},_type:function(){return"query"},_self:function(){return e}}},O.BoostingQuery=function(e,t,n){if(!b(e)||!b(t))throw new TypeError("Arguments must be Queries");var r={boosting:{positive:e._self(),negative:t._self(),negative_boost:n}};return{positive:function(e){if(e==null)return r.boosting.positive;if(!b(e))throw new TypeError("Argument must be a Query");return r.boosting.positive=e._self(),this},negative:function(e){if(e==null)return r.boosting.negative;if(!b(e))throw new TypeError("Argument must be a Query");return r.boosting.negative=e._self(),this},negativeBoost:function(e){return e==null?r.boosting.negative_boost:(r.boosting.negative_boost=e,this)},boost:function(e){return e==null?r.boosting.boost:(r.boosting.boost=e,this)},toString:function(){return JSON.stringify(r)},_type:function(){return"query"},_self:function(){return r}}},O.CommonTermsQuery=function(e,t){var n={common:{}};return e==null&&(e="no_field_set"),n.common[e]={},t!=null&&(n.common[e].query=t),{field:function(t){var r=n.common[e];return t==null?e:(delete n.common[e],e=t,n.common[t]=r,this)},query:function(t){return t==null?n.common[e].query:(n.common[e].query=t,this)},analyzer:function(t){return t==null?n.common[e].analyzer:(n.common[e].analyzer=t,this)},disableCoords:function(t){return t==null?n.common[e].disable_coords:(n.common[e].disable_coords=t,this)},cutoffFrequency:function(t){return t==null?n.common[e].cutoff_frequency:(n.common[e].cutoff_frequency=t,this)},highFreqOperator:function(t){if(t==null)return n.common[e].high_freq_operator;t=t.toLowerCase();if(t==="and"||t==="or")n.common[e].high_freq_operator=t;return this},lowFreqOperator:function(t){if(t==null)return n.common[e].low_freq_operator;t=t.toLowerCase();if(t==="and"||t==="or")n.common[e].low_freq_operator=t;return this},minimumShouldMatch:function(t){return t==null?n.common[e].minimum_should_match:(n.common[e].minimum_should_match=t,this)},boost:function(t){return t==null?n.common[e].boost:(n.common[e].boost=t,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.ConstantScoreQuery=function(){var e={constant_score:{}};return{query:function(t){if(t==null)return e.constant_score.query;if(!b(t))throw new TypeError("Argument must be a Query");return e.constant_score.query=t._self(),this},filter:function(t){if(t==null)return e.constant_score.filter;if(!w(t))throw new TypeError("Argument must be a Filter");return e.constant_score.filter=t._self(),this},cache:function(t){return t==null?e.constant_score._cache:(e.constant_score._cache=t,this)},cacheKey:function(t){return t==null?e.constant_score._cache_key:(e.constant_score._cache_key=t,this)},boost:function(t){return t==null?e.constant_score.boost:(e.constant_score.boost=t,this)},toString:function(){return JSON.stringify(e)},_type:function(){return"query"},_self:function(){return e}}},O.CustomBoostFactorQuery=function(e){if(!b(e))throw new TypeError("Argument must be a Query");var t={custom_boost_factor:{query:e._self()}};return{query:function(e){if(e==null)return t.custom_boost_factor.query;if(!b(e))throw new TypeError("Argument must be a Query");return t.custom_boost_factor.query=e._self(),this},boostFactor:function(e){return e==null?t.custom_boost_factor.boost_factor:(t.custom_boost_factor.boost_factor=e,this)},boost:function(e){return e==null?t.custom_boost_factor.boost:(t.custom_boost_factor.boost=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"query"},_self:function(){return t}}},O.CustomFiltersScoreQuery=function(e,t){if(!b(e))throw new TypeError("Argument must be a Query");var n={custom_filters_score:{query:e._self(),filters:[]}},r=function(e){var t=null;return e.filter&&w(e.filter)&&(t={filter:e.filter._self()},e.boost?t.boost=e.boost:e.script?t.script=e.script:t=null),t};return c(p(t)?t:[t],function(e){var t=r(e);t!==null&&n.custom_filters_score.filters.push(t)}),{query:function(e){if(e==null)return n.custom_filters_score.query;if(!b(e))throw new TypeError("Argument must be a Query");return n.custom_filters_score.query=e._self(),this},filters:function(e){return e==null?n.custom_filters_score.filters:(p(e)&&(n.custom_filters_score.filters=[]),c(p(e)?e:[e],function(e){var t=r(e);t!==null&&n.custom_filters_score.filters.push(t)}),this)},scoreMode:function(e){if(e==null)return n.custom_filters_score.score_mode;e=e.toLowerCase();if(e==="first"||e==="min"||e==="max"||e==="total"||e==="avg"||e==="multiply")n.custom_filters_score.score_mode=e;return this},params:function(e){return e==null?n.custom_filters_score.params:(n.custom_filters_score.params=e,this)},lang:function(e){return e==null?n.custom_filters_score.lang:(n.custom_filters_score.lang=e,this)},maxBoost:function(e){return e==null?n.custom_filters_score.max_boost:(n.custom_filters_score.max_boost=e,this)},boost:function(e){return e==null?n.custom_filters_score.boost:(n.custom_filters_score.boost=e,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.CustomScoreQuery=function(e,t){if(!b(e))throw new TypeError("Argument must be a Query");var n={custom_score:{query:e._self(),script:t}};return{query:function(e){if(e==null)return n.custom_score.query;if(!b(e))throw new TypeError("Argument must be a Query");return n.custom_score.query=e._self(),this},script:function(e){return e==null?n.custom_score.script:(n.custom_score.script=e,this)},params:function(e){return e==null?n.custom_score.params:(n.custom_score.params=e,this)},lang:function(e){return e==null?n.custom_score.lang:(n.custom_score.lang=e,this)},boost:function(e){return e==null?n.custom_score.boost:(n.custom_score.boost=e,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.DisMaxQuery=function(){var e={dis_max:{}};return{queries:function(t){var n,r;if(t==null)return e.dis_max.queries;e.dis_max.queries==null&&(e.dis_max.queries=[]);if(b(t))e.dis_max.queries.push(t._self());else{if(!p(t))throw new TypeError("Argument must be a Query or array of Queries");e.dis_max.queries=[];for(n=0,r=t.length;n<r;n++){if(!b(t[n]))throw new TypeError("Argument must be array of Queries");e.dis_max.queries.push(t[n]._self())}}return this},boost:function(t){return t==null?e.dis_max.boost:(e.dis_max.boost=t,this)},tieBreaker:function(t){return t==null?e.dis_max.tie_breaker:(e.dis_max.tie_breaker=t,this)},toString:function(){return JSON.stringify(e)},_type:function(){return"query"},_self:function(){return e}}},O.FieldMaskingSpanQuery=function(e,t){if(!b(e))throw new TypeError("Argument must be a SpanQuery");var n={field_masking_span:{query:e._self(),field:t}};return{query:function(e){if(e==null)return n.field_masking_span.query;if(!b(e))throw new TypeError("Argument must be a SpanQuery");return n.field_masking_span.query=e._self(),this},field:function(e){return e==null?n.field_masking_span.field:(n.field_masking_span.field=e,this)},boost:function(e){return e==null?n.field_masking_span.boost:(n.field_masking_span.boost=e,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.FieldQuery=function(e,t){var n={field:{}};return n.field[e]={query:t},{field:function(t){var r=n.field[e];return t==null?e:(delete n.field[e],e=t,n.field[t]=r,this)},query:function(t){return t==null?n.field[e].query:(n.field[e].query=t,this)},defaultOperator:function(t){if(t==null)return n.field[e].default_operator;t=t.toUpperCase();if(t==="AND"||t==="OR")n.field[e].default_operator=t;return this},analyzer:function(t){return t==null?n.field[e].analyzer:(n.field[e].analyzer=t,this)},quoteAnalyzer:function(t){return t==null?n.field[e].quote_analyzer:(n.field[e].quote_analyzer=t,this)},autoGeneratePhraseQueries:function(t){return t==null?n.field[e].auto_generate_phrase_queries:(n.field[e].auto_generate_phrase_queries=t,this)},allowLeadingWildcard:function(t){return t==null?n.field[e].allow_leading_wildcard:(n.field[e].allow_leading_wildcard=t,this)},lowercaseExpandedTerms:function(t){return t==null?n.field[e].lowercase_expanded_terms:(n.field[e].lowercase_expanded_terms=t,this)},enablePositionIncrements:function(t){return t==null?n.field[e].enable_position_increments:(n.field[e].enable_position_increments=t,this)},fuzzyMinSim:function(t){return t==null?n.field[e].fuzzy_min_sim:(n.field[e].fuzzy_min_sim=t,this)},boost:function(t){return t==null?n.field[e].boost:(n.field[e].boost=t,this)},fuzzyPrefixLength:function(t){return t==null?n.field[e].fuzzy_prefix_length:(n.field[e].fuzzy_prefix_length=t,this)},fuzzyMaxExpansions:function(t){return t==null?n.field[e].fuzzy_max_expansions:(n.field[e].fuzzy_max_expansions=t,this)},fuzzyRewrite:function(t){if(t==null)return n.field[e].fuzzy_rewrite;t=t.toLowerCase();if(t==="constant_score_auto"||t==="scoring_boolean"||t==="constant_score_boolean"||t==="constant_score_filter"||t.indexOf("top_terms_boost_")===0||t.indexOf("top_terms_")===0)n.field[e].fuzzy_rewrite=t;return this},rewrite:function(t){if(t==null)return n.field[e].rewrite;t=t.toLowerCase();if(t==="constant_score_auto"||t==="scoring_boolean"||t==="constant_score_boolean"||t==="constant_score_filter"||t.indexOf("top_terms_boost_")===0||t.indexOf("top_terms_")===0)n.field[e].rewrite=t;return this},quoteFieldSuffix:function(t){return t==null?n.field[e].quote_field_suffix:(n.field[e].quote_field_suffix=t,this)},phraseSlop:function(t){return t==null?n.field[e].phrase_slop:(n.field[e].phrase_slop=t,this)},analyzeWildcard:function(t){return t==null?n.field[e].analyze_wildcard:(n.field[e].analyze_wildcard=t,this)},escape:function(t){return t==null?n.field[e].escape:(n.field[e].escape=t,this)},minimumShouldMatch:function(t){return t==null?n.field[e].minimum_should_match:(n.field[e].minimum_should_match=t,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.FilteredQuery=function(e,t){if(!b(e))throw new TypeError("Argument must be a Query");if(t!=null&&!w(t))throw new TypeError("Argument must be a Filter");var n={filtered:{query:e._self()}};return t!=null&&(n.filtered.filter=t._self()),{query:function(e){if(e==null)return n.filtered.query;if(!b(e))throw new TypeError("Argument must be a Query");return n.filtered.query=e._self(),this},filter:function(e){if(e==null)return n.filtered.filter;if(!w(e))throw new TypeError("Argument must be a Filter");return n.filtered.filter=e._self(),this},strategy:function(e){if(e==null)return n.filtered.strategy;e=e.toLowerCase();if(e==="query_first"||e==="random_access_always"||e==="leap_frog"||e==="leap_frog_filter_first"||e.indexOf("random_access_")===0)n.filtered.strategy=e;return this},cache:function(e){return e==null?n.filtered._cache:(n.filtered._cache=e,this)},cacheKey:function(e){return e==null?n.filtered._cache_key:(n.filtered._cache_key=e,this)},boost:function(e){return e==null?n.filtered.boost:(n.filtered.boost=e,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.FuzzyLikeThisFieldQuery=function(e,t){var n={flt_field:{}};return n.flt_field[e]={like_text:t},{field:function(t){var r=n.flt_field[e];return t==null?e:(delete n.flt_field[e],e=t,n.flt_field[t]=r,this)},likeText:function(t){return t==null?n.flt_field[e].like_text:(n.flt_field[e].like_text=t,this)},ignoreTf:function(t){return t==null?n.flt_field[e].ignore_tf:(n.flt_field[e].ignore_tf=t,this)},maxQueryTerms:function(t){return t==null?n.flt_field[e].max_query_terms:(n.flt_field[e].max_query_terms=t,this)},minSimilarity:function(t){return t==null?n.flt_field[e].min_similarity:(n.flt_field[e].min_similarity=t,this)},prefixLength:function(t){return t==null?n.flt_field[e].prefix_length:(n.flt_field[e].prefix_length=t,this)},analyzer:function(t){return t==null?n.flt_field[e].analyzer:(n.flt_field[e].analyzer=t,this)},boost:function(t){return t==null?n.flt_field[e].boost:(n.flt_field[e].boost=t,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.FuzzyLikeThisQuery=function(e){var t={flt:{like_text:e}};return{fields:function(e){t.flt.fields==null&&(t.flt.fields=[]);if(e==null)return t.flt.fields;if(v(e))t.flt.fields.push(e);else{if(!p(e))throw new TypeError("Argument must be a string or array");t.flt.fields=e}return this},likeText:function(e){return e==null?t.flt.like_text:(t.flt.like_text=e,this)},ignoreTf:function(e){return e==null?t.flt.ignore_tf:(t.flt.ignore_tf=e,this)},maxQueryTerms:function(e){return e==null?t.flt.max_query_terms:(t.flt.max_query_terms=e,this)},minSimilarity:function(e){return e==null?t.flt.min_similarity:(t.flt.min_similarity=e,this)},prefixLength:function(e){return e==null?t.flt.prefix_length:(t.flt.prefix_length=e,this)},analyzer:function(e){return e==null?t.flt.analyzer:(t.flt.analyzer=e,this)},boost:function(e){return e==null?t.flt.boost:(t.flt.boost=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"query"},_self:function(){return t}}},O.FuzzyQuery=function(e,t){var n={fuzzy:{}};return n.fuzzy[e]={value:t},{field:function(t){var r=n.fuzzy[e];return t==null?e:(delete n.fuzzy[e],e=t,n.fuzzy[t]=r,this)},value:function(t){return t==null?n.fuzzy[e].value:(n.fuzzy[e].value=t,this)},transpositions:function(t){return t==null?n.fuzzy[e].transpositions:(n.fuzzy[e].transpositions=t,this)},maxExpansions:function(t){return t==null?n.fuzzy[e].max_expansions:(n.fuzzy[e].max_expansions=t,this)},minSimilarity:function(t){return t==null?n.fuzzy[e].min_similarity:(n.fuzzy[e].min_similarity=t,this)},prefixLength:function(t){return t==null?n.fuzzy[e].prefix_length:(n.fuzzy[e].prefix_length=t,this)},rewrite:function(t){if(t==null)return n.fuzzy[e].rewrite;t=t.toLowerCase();if(t==="constant_score_auto"||t==="scoring_boolean"||t==="constant_score_boolean"||t==="constant_score_filter"||t.indexOf("top_terms_boost_")===0||t.indexOf("top_terms_")===0)n.fuzzy[e].rewrite=t;return this},boost:function(t){return t==null?n.fuzzy[e].boost:(n.fuzzy[e].boost=t,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.GeoShapeQuery=function(e){var t={geo_shape:{}};return t.geo_shape[e]={},{field:function(n){var r=t.geo_shape[e];return n==null?e:(delete t.geo_shape[e],e=n,t.geo_shape[n]=r,this)},shape:function(n){return n==null?t.geo_shape[e].shape:(t.geo_shape[e].indexed_shape!=null&&delete t.geo_shape[e].indexed_shape,t.geo_shape[e].shape=n._self(),this)},indexedShape:function(n){return n==null?t.geo_shape[e].indexed_shape:(t.geo_shape[e].shape!=null&&delete t.geo_shape[e].shape,t.geo_shape[e].indexed_shape=n._self(),this)},relation:function(n){if(n==null)return t.geo_shape[e].relation;n=n.toLowerCase();if(n==="intersects"||n==="disjoint"||n==="within")t.geo_shape[e].relation=n;return this},strategy:function(n){if(n==null)return t.geo_shape[e].strategy;n=n.toLowerCase();if(n==="recursive"||n==="term")t.geo_shape[e].strategy=n;return this},boost:function(n){return n==null?t.geo_shape[e].boost:(t.geo_shape[e].boost=n,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"query"},_self:function(){return t}}},O.HasChildQuery=function(e,t){if(!b(e))throw new TypeError("Argument must be a valid Query");var n={has_child:{query:e._self(),type:t}};return{query:function(e){if(e==null)return n.has_child.query;if(!b(e))throw new TypeError("Argument must be a valid Query");return n.has_child.query=e._self(),this},type:function(e){return e==null?n.has_child.type:(n.has_child.type=e,this)},scope:function(e){return this},scoreType:function(e){if(e==null)return n.has_child.score_type;e=e.toLowerCase();if(e==="none"||e==="max"||e==="sum"||e==="avg")n.has_child.score_type=e;return this},boost:function(e){return e==null?n.has_child.boost:(n.has_child.boost=e,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.HasParentQuery=function(e,t){if(!b(e))throw new TypeError("Argument must be a Query");var n={has_parent:{query:e._self(),parent_type:t}};return{query:function(e){if(e==null)return n.has_parent.query;if(!b(e))throw new TypeError("Argument must be a Query");return n.has_parent.query=e._self(),this},parentType:function(e){return e==null?n.has_parent.parent_type:(n.has_parent.parent_type=e,this)},scope:function(e){return this},scoreType:function(e){if(e==null)return n.has_parent.score_type;e=e.toLowerCase();if(e==="none"||e==="score")n.has_parent.score_type=e;return this},boost:function(e){return e==null?n.has_parent.boost:(n.has_parent.boost=e,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.IdsQuery=function(e){var t={ids:{}};if(v(e))t.ids.values=[e];else{if(!p(e))throw new TypeError("Argument must be string or array");t.ids.values=e}return{values:function(e){if(e==null)return t.ids.values;if(v(e))t.ids.values.push(e);else{if(!p(e))throw new TypeError("Argument must be string or array");t.ids.values=e}return this},type:function(e){t.ids.type==null&&(t.ids.type=[]);if(e==null)return t.ids.type;if(v(e))t.ids.type.push(e);else{if(!p(e))throw new TypeError("Argument must be string or array");t.ids.type=e}return this},boost:function(e){return e==null?t.ids.boost:(t.ids.boost=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"query"},_self:function(){return t}}},O.IndicesQuery=function(e,t){if(!b(e))throw new TypeError("Argument must be a Query");var n={indices:{query:e._self()}};if(v(t))n.indices.indices=[t];else{if(!p(t))throw new TypeError("Argument must be a string or array");n.indices.indices=t}return{indices:function(e){if(e==null)return n.indices.indices;if(v(e))n.indices.indices.push(e);else{if(!p(e))throw new TypeError("Argument must be a string or array");n.indices.indices=e}return this},query:function(e){if(e==null)return n.indices.query;if(!b(e))throw new TypeError("Argument must be a Query");return n.indices.query=e._self(),this},noMatchQuery:function(e){if(e==null)return n.indices.no_match_query;if(v(e)){e=e.toLowerCase();if(e==="none"||e==="all")n.indices.no_match_query=e}else{if(!b(e))throw new TypeError("Argument must be string or Query");n.indices.no_match_query=e._self()}return this},boost:function(e){return e==null?n.indices.boost:(n.indices.boost=e,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.MatchAllQuery=function(){var e={match_all:{}};return{boost:function(t){return t==null?e.match_all.boost:(e.match_all.boost=t,this)},toString:function(){return JSON.stringify(e)},_type:function(){return"query"},_self:function(){return e}}},O.MatchQuery=function(e,t){var n={match:{}};return n.match[e]={query:t},{boost:function(t){return t==null?n.match[e].boost:(n.match[e].boost=t,this)},query:function(t){return t==null?n.match[e].query:(n.match[e].query=t,this)},type:function(t){if(t==null)return n.match[e].type;t=t.toLowerCase();if(t==="boolean"||t==="phrase"||t==="phrase_prefix")n.match[e].type=t;return this},fuzziness:function(t){return t==null?n.match[e].fuzziness:(n.match[e].fuzziness=t,this)},cutoffFrequency:function(t){return t==null?n.match[e].cutoff_frequency:(n.match[e].cutoff_frequency=t,this)},prefixLength:function(t){return t==null?n.match[e].prefix_length:(n.match[e].prefix_length=t,this)},maxExpansions:function(t){return t==null?n.match[e].max_expansions:(n.match[e].max_expansions=t,this)},operator:function(t){if(t==null)return n.match[e].operator;t=t.toLowerCase();if(t==="and"||t==="or")n.match[e].operator=t;return this},slop:function(t){return t==null?n.match[e].slop:(n.match[e].slop=t,this)},analyzer:function(t){return t==null?n.match[e].analyzer:(n.match[e].analyzer=t,this)},minimumShouldMatch:function(t){return t==null?n.match[e].minimum_should_match:(n.match[e].minimum_should_match=t,this)},rewrite:function(t){if(t==null)return n.match[e].rewrite;t=t.toLowerCase();if(t==="constant_score_auto"||t==="scoring_boolean"||t==="constant_score_boolean"||t==="constant_score_filter"||t.indexOf("top_terms_boost_")===0||t.indexOf("top_terms_")===0)n.match[e].rewrite=t;return this},fuzzyRewrite:function(t){if(t==null)return n.match[e].fuzzy_rewrite;t=t.toLowerCase();if(t==="constant_score_auto"||t==="scoring_boolean"||t==="constant_score_boolean"||t==="constant_score_filter"||t.indexOf("top_terms_boost_")===0||t.indexOf("top_terms_")===0)n.match[e].fuzzy_rewrite=t;return this},fuzzyTranspositions:function(t){return t==null?n.match[e].fuzzy_transpositions:(n.match[e].fuzzy_transpositions=t,this)},lenient:function(t){return t==null?n.match[e].lenient:(n.match[e].lenient=t,this)},zeroTermsQuery:function(t){if(t==null)return n.match[e].zero_terms_query;t=t.toLowerCase();if(t==="all"||t==="none")n.match[e].zero_terms_query=t;return this},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.MoreLikeThisFieldQuery=function(e,t){var n={mlt_field:{}};return n.mlt_field[e]={like_text:t},{field:function(t){var r=n.mlt_field[e];return t==null?e:(delete n.mlt_field[e],e=t,n.mlt_field[t]=r,this)},likeText:function(t){return t==null?n.mlt_field[e].like_text:(n.mlt_field[e].like_text=t,this)},percentTermsToMatch:function(t){return t==null?n.mlt_field[e].percent_terms_to_match:(n.mlt_field[e].percent_terms_to_match=t,this)},minTermFreq:function(t){return t==null?n.mlt_field[e].min_term_freq:(n.mlt_field[e].min_term_freq=t,this)},maxQueryTerms:function(t){return t==null?n.mlt_field[e].max_query_terms:(n.mlt_field[e].max_query_terms=t,this)},stopWords:function(t){return t==null?n.mlt_field[e].stop_words:(n.mlt_field[e].stop_words=t,this)},minDocFreq:function(t){return t==null?n.mlt_field[e].min_doc_freq:(n.mlt_field[e].min_doc_freq=t,this)},maxDocFreq:function(t){return t==null?n.mlt_field[e].max_doc_freq:(n.mlt_field[e].max_doc_freq=t,this)},minWordLen:function(t){return t==null?n.mlt_field[e].min_word_len:(n.mlt_field[e].min_word_len=t,this)},maxWordLen:function(t){return t==null?n.mlt_field[e].max_word_len:(n.mlt_field[e].max_word_len=t,this)},analyzer:function(t){return t==null?n.mlt_field[e].analyzer:(n.mlt_field[e].analyzer=t,this)},boostTerms:function(t){return t==null?n.mlt_field[e].boost_terms:(n.mlt_field[e].boost_terms=t,this)},boost:function(t){return t==null?n.mlt_field[e].boost:(n.mlt_field[e].boost=t,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.MoreLikeThisQuery=function(e,t){var n={mlt:{like_text:t,fields:[]}};if(v(e))n.mlt.fields.push(e);else{if(!p(e))throw new TypeError("Argument must be string or array");n.mlt.fields=e}return{fields:function(e){if(e==null)return n.mlt.fields;if(v(e))n.mlt.fields.push(e);else{if(!p(e))throw new TypeError("Argument must be a string or array");n.mlt.fields=e}return this},likeText:function(e){return e==null?n.mlt.like_text:(n.mlt.like_text=e,this)},percentTermsToMatch:function(e){return e==null?n.mlt.percent_terms_to_match:(n.mlt.percent_terms_to_match=e,this)},minTermFreq:function(e){return e==null?n.mlt.min_term_freq:(n.mlt.min_term_freq=e,this)},maxQueryTerms:function(e){return e==null?n.mlt.max_query_terms:(n.mlt.max_query_terms=e,this)},stopWords:function(e){return e==null?n.mlt.stop_words:(n.mlt.stop_words=e,this)},minDocFreq:function(e){return e==null?n.mlt.min_doc_freq:(n.mlt.min_doc_freq=e,this)},maxDocFreq:function(e){return e==null?n.mlt.max_doc_freq:(n.mlt.max_doc_freq=e,this)},minWordLen:function(e){return e==null?n.mlt.min_word_len:(n.mlt.min_word_len=e,this)},maxWordLen:function(e){return e==null?n.mlt.max_word_len:(n.mlt.max_word_len=e,this)},analyzer:function(e){return e==null?n.mlt.analyzer:(n.mlt.analyzer=e,this)},boostTerms:function(e){return e==null?n.mlt.boost_terms:(n.mlt.boost_terms=e,this)},boost:function(e){return e==null?n.mlt.boost:(n.mlt.boost=e,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.MultiMatchQuery=function(e,t){var n={multi_match:{query:t,fields:[]}};if(v(e))n.multi_match.fields.push(e);else{if(!p(e))throw new TypeError("Argument must be string or array");n.multi_match.fields=e}return{fields:function(e){if(e==null)return n.multi_match.fields;if(v(e))n.multi_match.fields.push(e);else{if(!p(e))throw new TypeError("Argument must be string or array");n.multi_match.fields=e}return this},useDisMax:function(e){return e==null?n.multi_match.use_dis_max:(n.multi_match.use_dis_max=e,this)},tieBreaker:function(e){return e==null?n.multi_match.tie_breaker:(n.multi_match.tie_breaker=e,this)},cutoffFrequency:function(e){return e==null?n.multi_match.cutoff_frequency:(n.multi_match.cutoff_frequency=e,this)},minimumShouldMatch:function(e){return e==null?n.multi_match.minimum_should_match:(n.multi_match.minimum_should_match=e,this)},rewrite:function(e){if(e==null)return n.multi_match.rewrite;e=e.toLowerCase();if(e==="constant_score_auto"||e==="scoring_boolean"||e==="constant_score_boolean"||e==="constant_score_filter"||e.indexOf("top_terms_boost_")===0||e.indexOf("top_terms_")===0)n.multi_match.rewrite=e;return this},fuzzyRewrite:function(e){if(e==null)return n.multi_match.fuzzy_rewrite;e=e.toLowerCase();if(e==="constant_score_auto"||e==="scoring_boolean"||e==="constant_score_boolean"||e==="constant_score_filter"||e.indexOf("top_terms_boost_")===0||e.indexOf("top_terms_")===0)n.multi_match.fuzzy_rewrite=e;return this},lenient:function(e){return e==null?n.multi_match.lenient:(n.multi_match.lenient=e,this)},boost:function(e){return e==null?n.multi_match.boost:(n.multi_match.boost=e,this)},query:function(e){return e==null?n.multi_match.query:(n.multi_match.query=e,this)},type:function(e){if(e==null)return n.multi_match.type;e=e.toLowerCase();if(e==="boolean"||e==="phrase"||e==="phrase_prefix")n.multi_match.type=e;return this},fuzziness:function(e){return e==null?n.multi_match.fuzziness:(n.multi_match.fuzziness=e,this)},prefixLength:function(e){return e==null?n.multi_match.prefix_length:(n.multi_match.prefix_length=e,this)},maxExpansions:function(e){return e==null?n.multi_match.max_expansions:(n.multi_match.max_expansions=e,this)},operator:function(e){if(e==null)return n.multi_match.operator;e=e.toLowerCase();if(e==="and"||e==="or")n.multi_match.operator=e;return this},slop:function(e){return e==null?n.multi_match.slop:(n.multi_match.slop=e,this)},analyzer:function(e){return e==null?n.multi_match.analyzer:(n.multi_match.analyzer=e,this)},zeroTermsQuery:function(e){if(e==null)return n.multi_match.zero_terms_query;e=e.toLowerCase();if(e==="all"||e==="none")n.multi_match.zero_terms_query=e;return this},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.NestedQuery=function(e){var t={nested:{path:e}};return{path:function(e){return e==null?t.nested.path:(t.nested.path=e,this)},query:function(e){if(e==null)return t.nested.query;if(!b(e))throw new TypeError("Argument must be a Query");return t.nested.query=e._self(),this},filter:function(e){if(e==null)return t.nested.filter;if(!w(e))throw new TypeError("Argument must be a Filter");return t.nested.filter=e._self(),this},scoreMode:function(e){if(e==null)return t.nested.score_mode;e=e.toLowerCase();if(e==="avg"||e==="total"||e==="max"||e==="none")t.nested.score_mode=e;return this},scope:function(e){return this},boost:function(e){return e==null?t.nested.boost:(t.nested.boost=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"query"},_self:function(){return t}}},O.PrefixQuery=function(e,t){var n={prefix:{}};return n.prefix[e]={value:t},{field:function(t){var r=n.prefix[e];return t==null?e:(delete n.prefix[e],e=t,n.prefix[t]=r,this)},value:function(t){return t==null?n.prefix[e].value:(n.prefix[e].value=t,this)},rewrite:function(t){if(t==null)return n.prefix[e].rewrite;t=t.toLowerCase();if(t==="constant_score_auto"||t==="scoring_boolean"||t==="constant_score_boolean"||t==="constant_score_filter"||t.indexOf("top_terms_boost_")===0||t.indexOf("top_terms_")===0)n.prefix[e].rewrite=t;return this},boost:function(t){return t==null?n.prefix[e].boost:(n.prefix[e].boost=t,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.QueryStringQuery=function(e){var t={query_string:{}};return t.query_string.query=e,{query:function(e){return e==null?t.query_string.query:(t.query_string.query=e,this)},defaultField:function(e){return e==null?t.query_string.default_field:(t.query_string.default_field=e,this)},fields:function(e){t.query_string.fields==null&&(t.query_string.fields=[]);if(e==null)return t.query_string.fields;if(v(e))t.query_string.fields.push(e);else{if(!p(e))throw new TypeError("Argument must be a string or array");t.query_string.fields=e}return this},useDisMax:function(e){return e==null?t.query_string.use_dis_max:(t.query_string.use_dis_max=e,this)},defaultOperator:function(e){if(e==null)return t.query_string.default_operator;e=e.toUpperCase();if(e==="AND"||e==="OR")t.query_string.default_operator=e;return this},analyzer:function(e){return e==null?t.query_string.analyzer:(t.query_string.analyzer=e,this)},quoteAnalyzer:function(e){return e==null?t.query_string.quote_analyzer:(t.query_string.quote_analyzer=e,this)},allowLeadingWildcard:function(e){return e==null?t.query_string.allow_leading_wildcard:(t.query_string.allow_leading_wildcard=e,this)},lowercaseExpandedTerms:function(e){return e==null?t.query_string.lowercase_expanded_terms:(t.query_string.lowercase_expanded_terms=e,this)},enablePositionIncrements:function(e){return e==null?t.query_string.enable_position_increments:(t.query_string.enable_position_increments=e,this)},fuzzyPrefixLength:function(e){return e==null?t.query_string.fuzzy_prefix_length:(t.query_string.fuzzy_prefix_length=e,this)},fuzzyMinSim:function(e){return e==null?t.query_string.fuzzy_min_sim:(t.query_string.fuzzy_min_sim=e,this)},phraseSlop:function(e){return e==null?t.query_string.phrase_slop:(t.query_string.phrase_slop=e,this)},boost:function(e){return e==null?t.query_string.boost:(t.query_string.boost=e,this)},analyzeWildcard:function(e){return e==null?t.query_string.analyze_wildcard:(t.query_string.analyze_wildcard=e,this)},autoGeneratePhraseQueries:function(e){return e==null?t.query_string.auto_generate_phrase_queries:(t.query_string.auto_generate_phrase_queries=e,this)},minimumShouldMatch:function(e){return e==null?t.query_string.minimum_should_match:(t.query_string.minimum_should_match=e,this)},tieBreaker:function(e){return e==null?t.query_string.tie_breaker:(t.query_string.tie_breaker=e,this)},escape:function(e){return e==null?t.query_string.escape:(t.query_string.escape=e,this)},fuzzyMaxExpansions:function(e){return e==null?t.query_string.fuzzy_max_expansions:(t.query_string.fuzzy_max_expansions=e,this)},fuzzyRewrite:function(e){if(e==null)return t.query_string.fuzzy_rewrite;e=e.toLowerCase();if(e==="constant_score_auto"||e==="scoring_boolean"||e==="constant_score_boolean"||e==="constant_score_filter"||e.indexOf("top_terms_boost_")===0||e.indexOf("top_terms_")===0)t.query_string.fuzzy_rewrite=e;return this},rewrite:function(e){if(e==null)return t.query_string.rewrite;e=e.toLowerCase();if(e==="constant_score_auto"||e==="scoring_boolean"||e==="constant_score_boolean"||e==="constant_score_filter"||e.indexOf("top_terms_boost_")===0||e.indexOf("top_terms_")===0)t.query_string.rewrite=e;return this},quoteFieldSuffix:function(e){return e==null?t.query_string.quote_field_suffix:(t.query_string.quote_field_suffix=e,this)},lenient:function(e){return e==null?t.query_string.lenient:(t.query_string.lenient=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"query"},_self:function(){return t}}},O.RangeQuery=function(e){var t={range:{}};return t.range[e]={},{field:function(n){var r=t.range[e];return n==null?e:(delete t.range[e],e=n,t.range[n]=r,this)},from:function(n){return n==null?t.range[e].from:(t.range[e].from=n,this)},to:function(n){return n==null?t.range[e].to:(t.range[e].to=n,this)},includeLower:function(n){return n==null?t.range[e].include_lower:(t.range[e].include_lower=n,this)},includeUpper:function(n){return n==null?t.range[e].include_upper:(t.range[e].include_upper=n,this)},gt:function(n){return n==null?t.range[e].gt:(t.range[e].gt=n,this)},gte:function(n){return n==null?t.range[e].gte:(t.range[e].gte=n,this)},lt:function(n){return n==null?t.range[e].lt:(t.range[e].lt=n,this)},lte:function(n){return n==null?t.range[e].lte:(t.range[e].lte=n,this)},boost:function(n){return n==null?t.range[e].boost:(t.range[e].boost=n,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"query"},_self:function(){return t}}},O.RegexpQuery=function(e,t){var n={regexp:{}};return n.regexp[e]={value:t},{field:function(t){var r=n.regexp[e];return t==null?e:(delete n.regexp[e],e=t,n.regexp[t]=r,this)},value:function(t){return t==null?n.regexp[e].value:(n.regexp[e].value=t,this)},flags:function(t){return t==null?n.regexp[e].flags:(n.regexp[e].flags=t,this)},flagsValue:function(t){return t==null?n.regexp[e].flags_value:(n.regexp[e].flags_value=t,this)},rewrite:function(t){if(t==null)return n.regexp[e].rewrite;t=t.toLowerCase();if(t==="constant_score_auto"||t==="scoring_boolean"||t==="constant_score_boolean"||t==="constant_score_filter"||t.indexOf("top_terms_boost_")===0||t.indexOf("top_terms_")===0)n.regexp[e].rewrite=t;return this},boost:function(t){return t==null?n.regexp[e].boost:(n.regexp[e].boost=t,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.SpanFirstQuery=function(e,t){if(!b(e))throw new TypeError("Argument must be a SpanQuery");var n={span_first:{match:e._self(),end:t}};return{match:function(e){if(e==null)return n.span_first.match;if(!b(e))throw new TypeError("Argument must be a SpanQuery");return n.span_first.match=e._self(),this},end:function(e){return e==null?n.span_first.end:(n.span_first.end=e,this)},boost:function(e){return e==null?n.span_first.boost:(n.span_first.boost=e,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.SpanNearQuery=function(e,t){var n,r,i={span_near:{clauses:[],slop:t}};if(b(e))i.span_near.clauses.push(e._self());else{if(!p(e))throw new TypeError("Argument must be SpanQuery or array of SpanQueries");for(n=0,r=e.length;n<r;n++){if(!b(e[n]))throw new TypeError("Argument must be array of SpanQueries");i.span_near.clauses.push(e[n]._self())}}return{clauses:function(e){var t,n;if(e==null)return i.span_near.clauses;if(b(e))i.span_near.clauses.push(e._self());else{if(!p(e))throw new TypeError("Argument must be SpanQuery or array of SpanQueries");i.span_near.clauses=[];for(t=0,n=e.length;t<n;t++){if(!b(e[t]))throw new TypeError("Argument must be array of SpanQueries");i.span_near.clauses.push(e[t]._self())}}return this},slop:function(e){return e==null?i.span_near.slop:(i.span_near.slop=e,this)},inOrder:function(e){return e==null?i.span_near.in_order:(i.span_near.in_order=e,this)},collectPayloads:function(e){return e==null?i.span_near.collect_payloads:(i.span_near.collect_payloads=e,this)},boost:function(e){return e==null?i.span_near.boost:(i.span_near.boost=e,this)},toString:function(){return JSON.stringify(i)},_type:function(){return"query"},_self:function(){return i}}},O.SpanNotQuery=function(e,t){if(!b(e)||!b(t))throw new TypeError("Argument must be a SpanQuery");var n={span_not:{include:e._self(),exclude:t._self()}};return{include:function(e){if(e==null)return n.span_not.include;if(!b(e))throw new TypeError("Argument must be a SpanQuery");return n.span_not.include=e._self(),this},exclude:function(e){if(e==null)return n.span_not.exclude;if(!b(e))throw new TypeError("Argument must be a SpanQuery");return n.span_not.exclude=e._self(),this},boost:function(e){return e==null?n.span_not.boost:(n.span_not.boost=e,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.SpanOrQuery=function(e){var t,n,r={span_or:{clauses:[]}};if(b(e))r.span_or.clauses.push(e._self());else{if(!p(e))throw new TypeError("Argument must be SpanQuery or array of SpanQueries");for(t=0,n=e.length;t<n;t++){if(!b(e[t]))throw new TypeError("Argument must be array of SpanQueries");r.span_or.clauses.push(e[t]._self())}}return{clauses:function(e){var t,n;if(e==null)return r.span_or.clauses;if(b(e))r.span_or.clauses.push(e._self());else{if(!p(e))throw new TypeError("Argument must be SpanQuery or array of SpanQueries");r.span_or.clauses=[];for(t=0,n=e.length;t<n;t++){if(!b(e[t]))throw new TypeError("Argument must be array of SpanQueries");r.span_or.clauses.push(e[t]._self())}}return this},boost:function(e){return e==null?r.span_or.boost:(r.span_or.boost=e,this)},toString:function(){return JSON.stringify(r)},_type:function(){return"query"},_self:function(){return r}}},O.SpanTermQuery=function(e,t){var n={span_term:{}};return n.span_term[e]={term:t},{field:function(t){var r=n.span_term[e];return t==null?e:(delete n.span_term[e],e=t,n.span_term[t]=r,this)},term:function(t){return t==null?n.span_term[e].term:(n.span_term[e].term=t,this)},boost:function(t){return t==null?n.span_term[e].boost:(n.span_term[e].boost=t,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.TermQuery=function(e,t){var n={term:{}};return n.term[e]={term:t},{field:function(t){var r=n.term[e];return t==null?e:(delete n.term[e],e=t,n.term[t]=r,this)},term:function(t){return t==null?n.term[e].term:(n.term[e].term=t,this)},boost:function(t){return t==null?n.term[e].boost:(n.term[e].boost=t,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.TermsQuery=function(e,t){var n={terms:{}};if(v(t))n.terms[e]=[t];else{if(!p(t))throw new TypeError("Argument must be string or array");n.terms[e]=t}return{field:function(t){var r=n.terms[e];return t==null?e:(delete n.terms[e],e=t,n.terms[t]=r,this)},terms:function(t){if(t==null)return n.terms[e];if(v(t))n.terms[e].push(t);else{if(!p(t))throw new TypeError("Argument must be string or array");n.terms[e]=t}return this},minimumShouldMatch:function(e){return e==null?n.terms.minimum_should_match:(n.terms.minimum_should_match=e,this)},disableCoord:function(e){return e==null?n.terms.disable_coord:(n.terms.disable_coord=e,this)},boost:function(e){return e==null?n.terms.boost:(n.terms.boost=e,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.TopChildrenQuery=function(e,t){if(!b(e))throw new TypeError("Argument must be a Query");var n={top_children:{query:e._self(),type:t}};return{query:function(e){if(e==null)return n.top_children.query;if(!b(e))throw new TypeError("Argument must be a Query");return n.top_children.query=e._self(),this},type:function(e){return e==null?n.top_children.type:(n.top_children.type=e,this)},scope:function(e){return this},score:function(e){if(e==null)return n.top_children.score;e=e.toLowerCase();if(e==="max"||e==="sum"||e==="avg")n.top_children.score=e;return this},factor:function(e){return e==null?n.top_children.factor:(n.top_children.factor=e,this)},incrementalFactor:function(e){return e==null?n.top_children.incremental_factor:(n.top_children.incremental_factor=e,this)},boost:function(e){return e==null?n.top_children.boost:(n.top_children.boost=e,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.WildcardQuery=function(e,t){var n={wildcard:{}};return n.wildcard[e]={value:t},{field:function(t){var r=n.wildcard[e];return t==null?e:(delete n.wildcard[e],e=t,n.wildcard[t]=r,this)},value:function(t){return t==null?n.wildcard[e].value:(n.wildcard[e].value=t,this)},rewrite:function(t){if(t==null)return n.wildcard[e].rewrite;t=t.toLowerCase();if(t==="constant_score_auto"||t==="scoring_boolean"||t==="constant_score_boolean"||t==="constant_score_filter"||t.indexOf("top_terms_boost_")===0||t.indexOf("top_terms_")===0)n.wildcard[e].rewrite=t;return this},boost:function(t){return t==null?n.wildcard[e].boost:(n.wildcard[e].boost=t,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"query"},_self:function(){return n}}},O.GeoPoint=function(e){var t=[0,0];return e!=null&&p(e)&&e.length===2&&(t=[e[1],e[0]]),{properties:function(e){return e==null?t:(d(e)&&l(e,"lat")&&l(e,"lon")&&(t={lat:e.lat,lon:e.lon}),this)},string:function(e){return e==null?t:(v(e)&&e.indexOf(",")!==-1&&(t=e),this)},geohash:function(e,n){return n=n!=null&&m(n)?n:12,e==null?t:(v(e)&&e.length===n&&(t=e),this)},array:function(e){return e==null?t:(p(e)&&e.length===2&&(t=[e[1],e[0]]),this)},toString:function(){return JSON.stringify(t)},_type:function(){return"geo point"},_self:function(){return t}}},O.Highlight=function(e){var t={fields:{}},n=function(e,n,r){e==null?t[n]=r:(l(t.fields,e)||(t.fields[e]={}),t.fields[e][n]=r)};return e!=null&&(v(e)?t.fields[e]={}:p(e)&&c(e,function(e){t.fields[e]={}})),{fields:function(e){if(e==null)return t.fields;v(e)?l(t.fields,e)||(t.fields[e]={}):p(e)&&c(e,function(e){l(t.fields,e)||(t.fields[e]={})})},preTags:function(e,r){return e===null&&r!=null?t.fields[r].pre_tags:e==null?t.pre_tags:(v(e)?n(r,"pre_tags",[e]):p(e)&&n(r,"pre_tags",e),this)},postTags:function(e,r){return e===null&&r!=null?t.fields[r].post_tags:e==null?t.post_tags:(v(e)?n(r,"post_tags",[e]):p(e)&&n(r,"post_tags",e),this)},order:function(e,r){return e===null&&r!=null?t.fields[r].order:e==null?t.order:(e=e.toLowerCase(),e==="score"&&n(r,"order",e),this)},tagsSchema:function(e){return e==null?t.tags_schema:(e=e.toLowerCase(),e==="styled"&&(t.tags_schema=e),this)},highlightFilter:function(e,r){return e===null&&r!=null?t.fields[r].highlight_filter:e==null?t.highlight_filter:(n(r,"highlight_filter",e),this)},fragmentSize:function(e,r){return e===null&&r!=null?t.fields[r].fragment_size:e==null?t.fragment_size:(n(r,"fragment_size",e),this)},numberOfFragments:function(e,r){return e===null&&r!=null?t.fields[r].number_of_fragments:e==null?t.number_of_fragments:(n(r,"number_of_fragments",e),this)},encoder:function(e){if(e==null)return t.encoder;e=e.toLowerCase();if(e==="default"||e==="html")t.encoder=e;return this},requireFieldMatch:function(e,r){return e===null&&r!=null?t.fields[r].require_field_match:e==null?t.require_field_match:(n(r,"require_field_match",e),this)},boundaryMaxScan:function(e,r){return e===null&&r!=null?t.fields[r].boundary_max_scan:e==null?t.boundary_max_scan:(n(r,"boundary_max_scan",e),this)},boundaryChars:function(e,r){return e===null&&r!=null?t.fields[r].boundary_chars:e==null?t.boundary_chars:(n(r,"boundary_chars",e),this)},type:function(e,r){return e===null&&r!=null?t.fields[r].type:e==null?t.type:(e=e.toLowerCase(),(e==="fast-vector-highlighter"||e==="highlighter")&&n(r,"type",e),this)},fragmenter:function(e,r){return e===null&&r!=null?t.fields[r].fragmenter:e==null?t.fragmenter:(e=e.toLowerCase(),(e==="simple"||e==="span")&&n(r,"fragmenter",e),this)},toString:function(){return JSON.stringify(t)},_type:function(){return"highlight"},_self:function(){return t}}},O.IndexedShape=function(e,t){var n={type:e,id:t};return{type:function(e){return e==null?n.type:(n.type=e,this)},id:function(e){return e==null?n.id:(n.id=e,this)},index:function(e){return e==null?n.index:(n.index=e,this)},shapeFieldName:function(e){return e==null?n.shape_field_name:(n.shape_field_name=e,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"indexed shape"},_self:function(){return n}}},O.Request=function(e){var t,n,r,i={},s=function(e){var t="",s=[];n.length>0&&(t=t+"/"+n.join()),r.length>0&&(t=t+"/"+r.join()),e.length>0&&e[0]!=="/"&&(t+="/"),t+=e;for(var o in i){if(!l(i,o)||i[o]==="")continue;s.push(o+"="+encodeURIComponent(i[o]))}return s.length>0&&(t=t+"?"+s.join("&")),t};return t={},e=e||{},e.indices==null?n=[]:v(e.indices)?n=[e.indices]:n=e.indices,e.types==null?r=[]:v(e.types)?r=[e.types]:r=e.types,n.length===0&&r.length>0&&(n=["_all"]),e.routing!=null&&(i.routing=e.routing),{sort:function(){var e,n;l(t,"sort")||(t.sort=[]);if(arguments.length===0)return t.sort;if(arguments.length===1){var r=arguments[0];if(v(r))t.sort.push(r);else if(C(r))t.sort.push(r._self());else{if(!p(r))throw new TypeError("Argument must be string, Sort, or array");t.sort=[];for(e=0,n=r.length;e<n;e++)if(v(r[e]))t.sort.push(r[e]);else{if(!C(r[e]))throw new TypeError("Invalid object in array");t.sort.push(r[e]._self())}}}else if(arguments.length===2){var i=arguments[0],s=arguments[1];if(v(i)&&v(s)){s=s.toLowerCase();if(s==="asc"||s==="desc"){var o={};o[i]={order:s},t.sort.push(o)}}}return this},trackScores:function(e){return e==null?t.track_scores:(t.track_scores=e,this)},size:function(e){return e==null?t.size:(t.size=e,this)},timeout:function(e){return e==null?i.timeout:(i.timeout=e,this)},routing:function(e){return e==null?i.routing:(i.routing=e,this)},replication:function(e){if(e==null)return i.replication;e=e.toLowerCase();if(e==="async"||e==="sync"||e==="default")i.replication=e;return this},consistency:function(e){if(e==null)return i.consistency;e=e.toLowerCase();if(e==="default"||e==="one"||e==="quorum"||e==="all")i.consistency=e;return this},searchType:function(e){if(e==null)return i.search_type;e=e.toLowerCase();if(e==="dfs_query_then_fetch"||e==="dfs_query_and_fetch"||e==="query_then_fetch"||e==="query_and_fetch"||e==="scan"||e==="count")i.search_type=e;return this},fields:function(e){if(e==null)return t.fields;t.fields==null&&(t.fields=[]);if(v(e))t.fields.push(e);else{if(!p(e))throw new TypeError("Argument must be string or array");t.fields=e}return this},from:function(e){return e==null?t.from:(t.from=e,this)},query:function(e){if(e==null)return t.query;if(!b(e))throw new TypeError("Argument must be a Query");return t.query=e._self(),this},indices:function(e){if(e==null)return n;if(v(e))n=[e];else{if(!p(e))throw new TypeError("Argument must be a string or array");n=e}return n.length===0&&r.length>0&&(n=["_all"]),this},types:function(e){if(e==null)return r;if(v(e))r=[e];else{if(!p(e))throw new TypeError("Argument must be a string or array");r=e}return n.length===0&&r.length>0&&(n=["_all"]),this},facet:function(e){if(e==null)return t.facets;t.facets==null&&(t.facets={});if(!E(e))throw new TypeError("Argument must be a Facet");return h(t.facets,e._self()),this},filter:function(e){if(e==null)return t.filter;if(!w(e))throw new TypeError("Argument must be a Filter");return t.filter=e._self(),this},highlight:function(e){if(e==null)return t.highlight;if(!k(e))throw new TypeError("Argument must be a Highlight object");return t.highlight=e._self(),this},suggest:function(e){if(e==null)return t.suggest;t.suggest==null&&(t.suggest={});if(v(e))t.suggest.text=e;else{if(!L(e))throw new TypeError("Argument must be a string or Suggest object");h(t.suggest,e._self())}return this},scriptField:function(e){if(e==null)return t.script_fields;t.script_fields==null&&(t.script_fields={});if(!S(e))throw new TypeError("Argument must be a ScriptField");return h(t.script_fields,e._self()),this},preference:function(e){return e==null?i.preference:(i.preference=e,this)},ignoreIndices:function(e){if(e==null)return i.ignore_indices;e=e.toLowerCase();if(e==="none"||e==="missing")i.ignore_indices=e;return this},indexBoost:function(e,n){return t.indices_boost==null&&(t.indices_boost={}),arguments.length===0?t.indices_boost:(t.indices_boost[e]=n,this)},explain:function(e){return e==null?t.explain:(t.explain=e,this)},version:function(e){return e==null?t.version:(t.version=e,this)},minScore:function(e){return e==null?t.min_score:(t.min_score=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"request"},_self:function(){return t},doDeleteByQuery:function(e,n){var r=JSON.stringify(t.query);if(O.client==null)throw new Error("No Client Set");return O.client.del(s("_query"),r,e,n)},doCount:function(e,n){var r=JSON.stringify(t.query);if(O.client==null)throw new Error("No Client Set");return O.client.post(s("_count"),r,e,n)},doSearch:function(e,n){var r=JSON.stringify(t);if(O.client==null)throw new Error("No Client Set");return O.client.post(s("_search"),r,e,n)}}},O.ScriptField=function(e){var t={};return t[e]={},{lang:function(n){return n==null?t[e].lang:(t[e].lang=n,this)},script:function(n){return n==null?t[e].script:(t[e].script=n,this)},params:function(n){return n==null?t[e].params:(t[e].params=n,this)},ignoreFailure:function(n){return n==null?t[e].ignore_failure:(t[e].ignore_failure=n,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"script field"},_self:function(){return t}}},O.Shape=function(e,t){var n={},r=function(e){var t=!1;if(e==="point"||e==="linestring"||e==="polygon"||e==="multipoint"||e==="envelope"||e==="multipolygon")t=!0;return t};return e=e.toLowerCase(),r(e)&&(n.type=e,n.coordinates=t),{type:function(e){return e==null?n.type:(e=e.toLowerCase(),r(e)&&(n.type=e),this)},coordinates:function(e){return e==null?n.coordinates:(n.coordinates=e,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"shape"},_self:function(){return n}}},O.Sort=function(e){e==null&&(e="_score");var t={},n=e,r="_geo_distance",i="_script";return t[n]={},{field:function(r){var i=t[n];return r==null?e:(delete t[n],e=r,n=r,t[n]=i,this)},geoDistance:function(i){var s=t[n];if(i==null)return t[n][e];if(!x(i))throw new TypeError("Argument must be a GeoPoint");return delete t[n],n=r,t[n]=s,t[n][e]=i._self(),this},script:function(e){var r=t[n];return e==null?t[n].script:(delete t[n],n=i,t[n]=r,t[n].script=e,this)},order:function(e){if(e==null)return t[n].order;e=e.toLowerCase();if(e==="asc"||e==="desc")t[n].order=e;return this},asc:function(){return t[n].order="asc",this},desc:function(){return t[n].order="desc",this},reverse:function(e){return e==null?t[n].reverse:(t[n].reverse=e,this)},missing:function(e){return e==null?t[n].missing:(t[n].missing=e,this)},ignoreUnmapped:function(e){return e==null?t[n].ignore_unmapped:(t[n].ignore_unmapped=e,this)},unit:function(e){if(e==null)return t[n].unit;e=e.toLowerCase();if(e==="mi"||e==="km")t[n].unit=e;return this},normalize:function(e){return e==null?t[n].normalize:(t[n].normalize=e,this)},distanceType:function(e){if(e==null)return t[n].distance_type;e=e.toLowerCase();if(e==="arc"||e==="plane")t[n].distance_type=e;return this},params:function(e){return e==null?t[n].params:(t[n].params=e,this)},lang:function(e){return e==null?t[n].lang:(t[n].lang=e,this)},type:function(e){if(e==null)return t[n].type;e=e.toLowerCase();if(e==="string"||e==="number")t[n].type=e;return this},mode:function(e){if(e==null)return t[n].mode;e=e.toLowerCase();if(e==="min"||e==="max"||e==="sum"||e==="avg")t[n].mode=e;return this},nestedPath:function(e){return e==null?t[n].nested_path:(t[n].nested_path=e,this)},nestedFilter:function(e){if(e==null)return t[n].nested_filter;if(!w(e))throw new TypeError("Argument must be a Filter");return t[n].nested_filter=e._self(),this},toString:function(){return JSON.stringify(t)},_type:function(){return"sort"},_self:function(){return t}}},O.DirectGenerator=function(){var e=O.DirectSettingsMixin(),t=e._self();return h(e,{preFilter:function(e){return e==null?t.pre_filter:(t.pre_filter=e,this)},postFilter:function(e){return e==null?t.post_filter:(t.post_filter=e,this)},field:function(e){return e==null?t.field:(t.field=e,this)},size:function(e){return e==null?t.size:(t.size=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"generator"},_self:function(){return t}})},O.DirectSettingsMixin=function(){var e={};return{accuracy:function(t){return t==null?e.accuracy:(e.accuracy=t,this)},suggestMode:function(t){if(t==null)return e.suggest_mode;t=t.toLowerCase();if(t==="missing"||t==="popular"||t==="always")e.suggest_mode=t;return this},sort:function(t){if(t==null)return e.sort;t=t.toLowerCase();if(t==="score"||t==="frequency")e.sort=t;return this},stringDistance:function(t){if(t==null)return e.string_distance;t=t.toLowerCase();if(t==="internal"||t==="damerau_levenshtein"||t==="levenstein"||t==="jarowinkler"||t==="ngram")e.string_distance=t;return this},maxEdits:function(t){return t==null?e.max_edits:(e.max_edits=t,this)},maxInspections:function(t){return t==null?e.max_inspections:(e.max_inspections=t,this)},maxTermFreq:function(t){return t==null?e.max_term_freq:(e.max_term_freq=t,this)},prefixLength:function(t){return t==null?e.prefix_length:(e.prefix_length=t,this)},minWordLen:function(t){return t==null?e.min_word_len:(e.min_word_len=t,this)},minDocFreq:function(t){return t==null?e.min_doc_freq:(e.min_doc_freq=t,this)},_self:function(){return e}}},O.PhraseSuggester=function(e){var t={};return t[e]={phrase:{}},{text:function(n){return n==null?t[e].text:(t[e].text=n,this)},analyzer:function(n){return n==null?t[e].phrase.analyzer:(t[e].phrase.analyzer=n,this)},field:function(n){return n==null?t[e].phrase.field:(t[e].phrase.field=n,this)},size:function(n){return n==null?t[e].phrase.size:(t[e].phrase.size=n,this)},shardSize:function(n){return n==null?t[e].phrase.shard_size:(t[e].phrase.shard_size=n,this)},realWorldErrorLikelihood:function(n){return n==null?t[e].phrase.real_world_error_likelihood:(t[e].phrase.real_world_error_likelihood=n,this)},confidence:function(n){return n==null?t[e].phrase.confidence:(t[e].phrase.confidence=n,this)},separator:function(n){return n==null?t[e].phrase.separator:(t[e].phrase.separator=n,this)},maxErrors:function(n){return n==null?t[e].phrase.max_errors:(t[e].phrase.max_errors=n,this)},gramSize:function(n){return n==null?t[e].phrase.gram_size:(t[e].phrase.gram_size=n,this)},forceUnigrams:function(n){return n==null?t[e].phrase.force_unigrams:(t[e].phrase.force_unigrams=n,this)},linearSmoothing:function(n,r,i){return arguments.length===0?t[e].phrase.smoothing:(t[e].phrase.smoothing={linear:{trigram_lambda:n,bigram_lambda:r,unigram_lambda:i}},this)},laplaceSmoothing:function(n){return n==null?t[e].phrase.smoothing:(t[e].phrase.smoothing={laplace:{alpha:n}},this)},stupidBackoffSmoothing:function(n){return n==null?t[e].phrase.smoothing:(t[e].phrase.smoothing={stupid_backoff:{discount:n}},this)},directGenerator:function(n){var r,i;t[e].phrase.direct_generator==null&&(t[e].phrase.direct_generator=[]);if(n==null)return t[e].phrase.direct_generator;if(A(n))t[e].phrase.direct_generator.push(n._self());else{if(!p(n))throw new TypeError("Argument must be a Generator or array of Generators");t[e].phrase.direct_generator=[];for(r=0,i=n.length;r<i;r++){if(!A(n[r]))throw new TypeError("Argument must be an array of Generators");t[e].phrase.direct_generator.push(n[r]._self())}}return this},toString:function(){return JSON.stringify(t)},_type:function(){return"suggest"},_self:function(){return t}}},O.TermSuggester=function(e){var t={},n=O.DirectSettingsMixin();return t[e]={term:n._self()},h(n,{text:function(n){return n==null?t[e].text:(t[e].text=n,this)},analyzer:function(n){return n==null?t[e].term.analyzer:(t[e].term.analyzer=n,this)},field:function(n){return n==null?t[e].term.field:(t[e].term.field=n,this)},size:function(n){return n==null?t[e].term.size:(t[e].term.size=n,this)},shardSize:function(n){return n==null?t[e].term.shard_size:(t[e].term.shard_size=n,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"suggest"},_self:function(){return t}})},O.noConflict=function(){return e.ejs=t,this}}).call(this);