Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
/*! elastic.js - v1.1.1 - 2013-08-14
 * https://github.com/fullscale/elastic.js
 * Copyright (c) 2013 FullScale Labs, LLC; Licensed MIT */

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