From e9d1fc7b1a4f72f156ef5cf80f13caa66417a5ce Mon Sep 17 00:00:00 2001
From: Rashid Khan The DateHistogram facet works with time-based values by building a histogram across time
@@ -290,13 +300,14 @@
},
/**
- By default, time values are stored in UTC format. This method allows users
- to set a time zone value that is then used to compute intervals
- before rounding on the interval value. Equalivent to
- By default, time values are stored in UTC format.
+
+ This method allows users to set a time zone value that is then used
+ to compute intervals before rounding on the interval value. Equalivent to
+
- For example, to use EST you would set the value to For example, to use EST you would set the value to By default, time values are stored in UTC format.
+
+ This method allows users to set a time zone value that is then used to
+ compute intervals before rounding on the interval value. The value is an
+ offset from UTC.
- For example, to use EST you would set the value to For example, to use EST you would set the value to Enables large date interval conversions (day and up). Set to true to enable and then set the By default, time values are stored in UTC format.
+
+ This method allows users to set a time zone value that is then used to compute
+ intervals after rounding on the interval value. The value is an offset from UTC.
+ The tz offset value is simply added to the resulting bucket's date value.
- For example, to use EST you would set the value to For example, to use EST you would set the value to The date histogram works on numeric values (since time is stored
+ in milliseconds since the epoch in UTC).
+
+ But, sometimes, systems will store a different resolution (like seconds since UTC)
+ in a numeric field. The factor parameter can be used to change the value in the field
+ to milliseconds to actual do the relevant rounding, and then be applied again to get to
+ the original unit. For example, when storing in a numeric field seconds resolution,
+ the factor can be set to 1000.
@member ejs.DateHistogramFacet
@param {Integer} f The conversion factor.
@@ -445,12 +460,14 @@
},
/**
- Sets the type of ordering that will be performed on the date
- buckets. Valid values are:
+ Sets the type of ordering that will be performed on the date
+ buckets. Valid values are:
- time - the default, sort by the buckets start time in milliseconds.
- count - sort by the number of items in the bucket
- total - sort by the sum/total of the items in the bucket
+ Sets the mode the facet will use.
+
+ Computes values across the the specified scope Sets the mode the facet will use.
+
+ Computes values across the the specified scope Sets the mode the facet will use.
+
+ Computes values across the the specified scope Sets the mode the facet will use.
+
+ Computes values across the the specified scope Sets the mode the facet will use.
+
+ Computes values across the the specified scope Sets the mode the facet will use.
+
+ Computes values across the the specified scope Sets the mode the facet will use.
+
+ Computes values across the the specified scope A termsStatsFacet allows you to compute statistics over an aggregate key (term). Essentially this
+ facet provides the functionality of what is often refered to as a pivot table. Facets are similar to SQL A facet which computes statistical data based on an aggregate key. Allows you to return all terms, even if the frequency count is 0. This should not be
+ used on fields that contain a large number of unique terms because it could cause
+ out-of-memory errors. Allows you to reduce the documents used for computing facet results. Computes values across the entire index Sets the mode the facet will use.
+
+ Computes values across the the specified scope Enables caching of the Sets the path to the nested document if faceting against a
+ nested field. Allows you to serialize this object into a JSON encoded string. Retrieves the internal A facet which returns the N most frequent terms within a collection
@@ -2673,19 +3192,40 @@
return this;
},
+ /**
+ Sets the mode the facet will use.
+
+ Computes values across the the specified scope A termsStatsFacet allows you to compute statistics over an aggregate key (term). Essentially this
- facet provides the functionality of what is often refered to as a pivot table. Facets are similar to SQL A facet which computes statistical data based on an aggregate key. Allows you to return all terms, even if the frequency count is 0. This should not be
- used on fields that contain a large number of unique terms because it could cause
- out-of-memory errors. Allows you to reduce the documents used for computing facet results. Computes values across the entire index Computes values across the the specified scope Enables caching of the Sets the path to the nested document if faceting against a
- nested field. Allows you to serialize this object into a JSON encoded string. Retrieves the internal Sets the spatial strategy. Valid values are: This is an advanced setting, use with care. Sets the routing value.
+
+ By default, the shard the document is placed on is controlled by using a
+ hash of the document’s id value. For more explicit control, this routing value
+ will be fed into the hash function used by the router. This option is valid during the following operations:
+ Sets parent value for a child document. When indexing a child document, the routing value is automatically set to be
+ the same as it’s parent, unless the routing value is explicitly specified
+ using the routing parameter. This option is valid during the following operations:
+ Sets timestamp of the document. By default the timestamp will be set to the time the docuement was indexed. This option is valid during the following operations:
+ preZone if possible. The
- value is an offset from UTC.
+ preZone if possible. The
+ value is an offset from UTC.-5.
+ -5.-5.
+ -5.interval to an
- interval greater than a day.
+ interval to an
+ interval greater than a day.-5.
+ -5.
+
time - the default, sort by the buckets start time in milliseconds.count - sort by the number of items in the buckettotal - sort by the sum/total of the items in the bucket
@member ejs.DateHistogramFacet
@param {String} o The ordering method: time, count, or total.
@@ -539,20 +556,41 @@
facet[name].global = trueFalse;
return this;
},
+
+ /**
+
+
collectorpost
+
+ @member ejs.DateHistogramFacet
+ @param {String} m The mode: collector or post.
+ @returns {Object} returns
this so that calls can be chained.
+ */
+ mode: function (m) {
+ if (m == null) {
+ return facet[name].mode;
+ }
+ m = m.toLowerCase();
+ if (m === 'collector' || m === 'post') {
+ facet[name].mode = m;
+ }
+
+ return this;
+ },
+
/**
this so that calls can be chained.
*/
scope: function (scope) {
- if (scope == null) {
- return facet[name].scope;
- }
-
- facet[name].scope = scope;
return this;
},
@@ -719,19 +757,40 @@
return this;
},
+ /**
+
+
collectorpost
+
+ @member ejs.FilterFacet
+ @param {String} m The mode: collector or post.
+ @returns {Object} returns
this so that calls can be chained.
+ */
+ mode: function (m) {
+ if (m == null) {
+ return facet[name].mode;
+ }
+
+ m = m.toLowerCase();
+ if (m === 'collector' || m === 'post') {
+ facet[name].mode = m;
+ }
+
+ return this;
+ },
+
/**
this so that calls can be chained.
*/
scope: function (scope) {
- if (scope == null) {
- return facet[name].scope;
- }
-
- facet[name].scope = scope;
return this;
},
@@ -1120,19 +1179,40 @@
return this;
},
+ /**
+
+
collectorpost
+
+ @member ejs.GeoDistanceFacet
+ @param {String} m The mode: collector or post.
+ @returns {Object} returns
this so that calls can be chained.
+ */
+ mode: function (m) {
+ if (m == null) {
+ return facet[name].mode;
+ }
+
+ m = m.toLowerCase();
+ if (m === 'collector' || m === 'post') {
+ facet[name].mode = m;
+ }
+
+ return this;
+ },
+
/**
this so that calls can be chained.
*/
scope: function (scope) {
- if (scope == null) {
- return facet[name].scope;
- }
-
- facet[name].scope = scope;
return this;
},
@@ -1497,19 +1577,40 @@
return this;
},
+ /**
+
+
collectorpost
+
+ @member ejs.HistogramFacet
+ @param {String} m The mode: collector or post.
+ @returns {Object} returns
this so that calls can be chained.
+ */
+ mode: function (m) {
+ if (m == null) {
+ return facet[name].mode;
+ }
+
+ m = m.toLowerCase();
+ if (m === 'collector' || m === 'post') {
+ facet[name].mode = m;
+ }
+
+ return this;
+ },
+
/**
this so that calls can be chained.
*/
scope: function (scope) {
- if (scope == null) {
- return facet[name].scope;
- }
-
- facet[name].scope = scope;
return this;
},
@@ -1676,19 +1777,40 @@
return this;
},
+ /**
+
+
collectorpost
+
+ @member ejs.QueryFacet
+ @param {String} m The mode: collector or post.
+ @returns {Object} returns
this so that calls can be chained.
+ */
+ mode: function (m) {
+ if (m == null) {
+ return facet[name].mode;
+ }
+
+ m = m.toLowerCase();
+ if (m === 'collector' || m === 'post') {
+ facet[name].mode = m;
+ }
+
+ return this;
+ },
+
/**
this so that calls can be chained.
*/
scope: function (scope) {
- if (scope == null) {
- return facet[name].scope;
- }
-
- facet[name].scope = scope;
return this;
},
@@ -2016,19 +2138,40 @@
return this;
},
+ /**
+
+
collectorpost
+
+ @member ejs.RangeFacet
+ @param {String} m The mode: collector or post.
+ @returns {Object} returns
this so that calls can be chained.
+ */
+ mode: function (m) {
+ if (m == null) {
+ return facet[name].mode;
+ }
+
+ m = m.toLowerCase();
+ if (m === 'collector' || m === 'post') {
+ facet[name].mode = m;
+ }
+
+ return this;
+ },
+
/**
this so that calls can be chained.
*/
scope: function (scope) {
- if (scope == null) {
- return facet[name].scope;
- }
-
- facet[name].scope = scope;
return this;
},
@@ -2264,19 +2407,40 @@
return this;
},
+ /**
+
+
collectorpost
+
+ @member ejs.StatisticalFacet
+ @param {String} m The mode: collector or post.
+ @returns {Object} returns
this so that calls can be chained.
+ */
+ mode: function (m) {
+ if (m == null) {
+ return facet[name].mode;
+ }
+
+ m = m.toLowerCase();
+ if (m === 'collector' || m === 'post') {
+ facet[name].mode = m;
+ }
+
+ return this;
+ },
+
/**
this so that calls can be chained.
*/
scope: function (scope) {
- if (scope == null) {
- return facet[name].scope;
- }
-
- facet[name].scope = scope;
return this;
},
@@ -2346,6 +2510,361 @@
};
};
+ /**
+ @class
+ GROUP BY statements but perform much
+ better. You can also construct several "groups" at once by simply
+ specifying multiple facets.doc_authors. Setting
+ name to Authors would allow you to refer to the
+ facet by that name, possibly simplifying some of the display logic.
+
+ */
+ ejs.TermStatsFacet = function (name) {
+
+ /**
+ The internal facet object.
+ @member ejs.TermStatsFacet
+ @property {Object} facet
+ */
+ var facet = {};
+
+ facet[name] = {
+ terms_stats: {}
+ };
+
+ return {
+
+ /**
+ Sets the field for which statistical information will be generated.
+
+ @member ejs.TermStatsFacet
+ @param {String} fieldName The field name whose data will be used to construct the facet.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ valueField: function (fieldName) {
+ if (fieldName == null) {
+ return facet[name].terms_stats.value_field;
+ }
+
+ facet[name].terms_stats.value_field = fieldName;
+ return this;
+ },
+
+ /**
+ Sets the field which will be used to pivot on (group-by).
+
+ @member ejs.TermStatsFacet
+ @param {String} fieldName The field name whose data will be used to construct the facet.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ keyField: function (fieldName) {
+ if (fieldName == null) {
+ return facet[name].terms_stats.key_field;
+ }
+
+ facet[name].terms_stats.key_field = fieldName;
+ return this;
+ },
+
+ /**
+ Sets a script that will provide the terms for a given document.
+
+ @member ejs.TermStatsFacet
+ @param {String} script The script code.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ scriptField: function (script) {
+ if (script == null) {
+ return facet[name].terms_stats.script_field;
+ }
+
+ facet[name].terms_stats.script_field = script;
+ return this;
+ },
+
+ /**
+ Define a script to evaluate of which the result will be used to generate
+ the statistical information.
+
+ @member ejs.TermStatsFacet
+ @param {String} code The script code to execute.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ valueScript: function (code) {
+ if (code == null) {
+ return facet[name].terms_stats.value_script;
+ }
+
+ facet[name].terms_stats.value_script = code;
+ return this;
+ },
+
+ /**
+ true or false
+ @returns {Object} returns this so that calls can be chained.
+ */
+ allTerms: function (trueFalse) {
+ if (trueFalse == null) {
+ return facet[name].terms_stats.all_terms;
+ }
+
+ facet[name].terms_stats.all_terms = trueFalse;
+ return this;
+ },
+
+ /**
+ The script language being used. Currently supported values are
+ javascript, groovy, and mvel.
+
+ @member ejs.TermStatsFacet
+ @param {String} language The language of the script.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ lang: function (language) {
+ if (language == null) {
+ return facet[name].terms_stats.lang;
+ }
+
+ facet[name].terms_stats.lang = language;
+ return this;
+ },
+
+ /**
+ Allows you to set script parameters to be used during the execution of the script.
+
+ @member ejs.TermStatsFacet
+ @param {Object} oParams An object containing key/value pairs representing param name/value.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ params: function (oParams) {
+ if (oParams == null) {
+ return facet[name].terms_stats.params;
+ }
+
+ facet[name].terms_stats.params = oParams;
+ return this;
+ },
+
+ /**
+ Sets the number of facet entries that will be returned for this facet. For instance, you
+ might ask for only the top 5 aggregate keys although there might be hundreds of
+ unique keys. Higher settings could cause memory strain.
+
+ @member ejs.TermStatsFacet
+ @param {Integer} facetSize The numer of facet entries to be returned.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ size: function (facetSize) {
+ if (facetSize == null) {
+ return facet[name].terms_stats.size;
+ }
+
+ facet[name].terms_stats.size = facetSize;
+ return this;
+ },
+
+ /**
+ Sets the type of ordering that will be performed on the date
+ buckets. Valid values are:
+
+ count - default, sort by the number of items in the bucket
+ term - sort by term value.
+ reverse_count - reverse sort of the number of items in the bucket
+ reverse_term - reverse sort of the term value.
+ total - sorts by the total value of the bucket contents
+ reverse_total - reverse sort of the total value of bucket contents
+ min - the minimum value in the bucket
+ reverse_min - the reverse sort of the minimum value
+ max - the maximum value in the bucket
+ reverse_max - the reverse sort of the maximum value
+ mean - the mean value of the bucket contents
+ reverse_mean - the reverse sort of the mean value of bucket contents.
+
+ @member ejs.TermStatsFacet
+ @param {String} o The ordering method
+ @returns {Object} returns this so that calls can be chained.
+ */
+ order: function (o) {
+ if (o == null) {
+ return facet[name].terms_stats.order;
+ }
+
+ o = o.toLowerCase();
+ if (o === 'count' || o === 'term' || o === 'reverse_count' ||
+ o === 'reverse_term' || o === 'total' || o === 'reverse_total' ||
+ o === 'min' || o === 'reverse_min' || o === 'max' ||
+ o === 'reverse_max' || o === 'mean' || o === 'reverse_mean') {
+
+ facet[name].terms_stats.order = o;
+ }
+
+ return this;
+ },
+
+ /**
+ Filter object.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ facetFilter: function (oFilter) {
+ if (oFilter == null) {
+ return facet[name].facet_filter;
+ }
+
+ if (!isFilter(oFilter)) {
+ throw new TypeError('Argument must be a Filter');
+ }
+
+ facet[name].facet_filter = oFilter._self();
+ return this;
+ },
+
+ /**
+ this so that calls can be chained.
+ */
+ global: function (trueFalse) {
+ if (trueFalse == null) {
+ return facet[name].global;
+ }
+
+ facet[name].global = trueFalse;
+ return this;
+ },
+
+ /**
+
+
collectorpost
+
+ @member ejs.TermStatsFacet
+ @param {String} m The mode: collector or post.
+ @returns {Object} returns
this so that calls can be chained.
+ */
+ mode: function (m) {
+ if (m == null) {
+ return facet[name].mode;
+ }
+
+ m = m.toLowerCase();
+ if (m === 'collector' || m === 'post') {
+ facet[name].mode = m;
+ }
+
+ return this;
+ },
+
+ /**
+ this so that calls can be chained.
+ */
+ scope: function (scope) {
+ return this;
+ },
+
+ /**
+ facetFilterthis so that calls can be chained.
+ */
+ cacheFilter: function (trueFalse) {
+ if (trueFalse == null) {
+ return facet[name].cache_filter;
+ }
+
+ facet[name].cache_filter = trueFalse;
+ return this;
+ },
+
+ /**
+ this so that calls can be chained.
+ */
+ nested: function (path) {
+ if (path == null) {
+ return facet[name].nested;
+ }
+
+ facet[name].nested = path;
+ return this;
+ },
+
+ /**
+ facet object. This is typically used by
+ internal API functions so use with caution.facet property.
+ */
+ _self: function () {
+ return facet;
+ }
+ };
+ };
+
/**
@class
+
collectorpost
+
+ @member ejs.TermsFacet
+ @param {String} m The mode: collector or post.
+ @returns {Object} returns
this so that calls can be chained.
+ */
+ mode: function (m) {
+ if (m == null) {
+ return facet[name].mode;
+ }
+
+ m = m.toLowerCase();
+ if (m === 'collector' || m === 'post') {
+ facet[name].mode = m;
+ }
+
+ return this;
+ },
+
/**
this so that calls can be chained.
*/
scope: function (scope) {
- if (scope == null) {
- return facet[name].scope;
- }
-
- facet[name].scope = scope;
return this;
},
@@ -2755,340 +3295,6 @@
};
};
- /**
- @class
- GROUP BY statements but perform much
- better. You can also construct several "groups" at once by simply
- specifying multiple facets.doc_authors. Setting
- name to Authors would allow you to refer to the
- facet by that name, possibly simplifying some of the display logic.
-
- */
- ejs.TermStatsFacet = function (name) {
-
- /**
- The internal facet object.
- @member ejs.TermStatsFacet
- @property {Object} facet
- */
- var facet = {};
-
- facet[name] = {
- terms_stats: {}
- };
-
- return {
-
- /**
- Sets the field for which statistical information will be generated.
-
- @member ejs.TermStatsFacet
- @param {String} fieldName The field name whose data will be used to construct the facet.
- @returns {Object} returns this so that calls can be chained.
- */
- valueField: function (fieldName) {
- if (fieldName == null) {
- return facet[name].terms_stats.value_field;
- }
-
- facet[name].terms_stats.value_field = fieldName;
- return this;
- },
-
- /**
- Sets the field which will be used to pivot on (group-by).
-
- @member ejs.TermStatsFacet
- @param {String} fieldName The field name whose data will be used to construct the facet.
- @returns {Object} returns this so that calls can be chained.
- */
- keyField: function (fieldName) {
- if (fieldName == null) {
- return facet[name].terms_stats.key_field;
- }
-
- facet[name].terms_stats.key_field = fieldName;
- return this;
- },
-
- /**
- Sets a script that will provide the terms for a given document.
-
- @member ejs.TermStatsFacet
- @param {String} script The script code.
- @returns {Object} returns this so that calls can be chained.
- */
- scriptField: function (script) {
- if (script == null) {
- return facet[name].terms_stats.script_field;
- }
-
- facet[name].terms_stats.script_field = script;
- return this;
- },
-
- /**
- Define a script to evaluate of which the result will be used to generate
- the statistical information.
-
- @member ejs.TermStatsFacet
- @param {String} code The script code to execute.
- @returns {Object} returns this so that calls can be chained.
- */
- valueScript: function (code) {
- if (code == null) {
- return facet[name].terms_stats.value_script;
- }
-
- facet[name].terms_stats.value_script = code;
- return this;
- },
-
- /**
- true or false
- @returns {Object} returns this so that calls can be chained.
- */
- allTerms: function (trueFalse) {
- if (trueFalse == null) {
- return facet[name].terms_stats.all_terms;
- }
-
- facet[name].terms_stats.all_terms = trueFalse;
- return this;
- },
-
- /**
- The script language being used. Currently supported values are
- javascript, groovy, and mvel.
-
- @member ejs.TermStatsFacet
- @param {String} language The language of the script.
- @returns {Object} returns this so that calls can be chained.
- */
- lang: function (language) {
- if (language == null) {
- return facet[name].terms_stats.lang;
- }
-
- facet[name].terms_stats.lang = language;
- return this;
- },
-
- /**
- Allows you to set script parameters to be used during the execution of the script.
-
- @member ejs.TermStatsFacet
- @param {Object} oParams An object containing key/value pairs representing param name/value.
- @returns {Object} returns this so that calls can be chained.
- */
- params: function (oParams) {
- if (oParams == null) {
- return facet[name].terms_stats.params;
- }
-
- facet[name].terms_stats.params = oParams;
- return this;
- },
-
- /**
- Sets the number of facet entries that will be returned for this facet. For instance, you
- might ask for only the top 5 aggregate keys although there might be hundreds of
- unique keys. Higher settings could cause memory strain.
-
- @member ejs.TermStatsFacet
- @param {Integer} facetSize The numer of facet entries to be returned.
- @returns {Object} returns this so that calls can be chained.
- */
- size: function (facetSize) {
- if (facetSize == null) {
- return facet[name].terms_stats.size;
- }
-
- facet[name].terms_stats.size = facetSize;
- return this;
- },
-
- /**
- Sets the type of ordering that will be performed on the date
- buckets. Valid values are:
-
- count - default, sort by the number of items in the bucket
- term - sort by term value.
- reverse_count - reverse sort of the number of items in the bucket
- reverse_term - reverse sort of the term value.
- total - sorts by the total value of the bucket contents
- reverse_total - reverse sort of the total value of bucket contents
- min - the minimum value in the bucket
- reverse_min - the reverse sort of the minimum value
- max - the maximum value in the bucket
- reverse_max - the reverse sort of the maximum value
- mean - the mean value of the bucket contents
- reverse_mean - the reverse sort of the mean value of bucket contents.
-
- @member ejs.TermStatsFacet
- @param {String} o The ordering method
- @returns {Object} returns this so that calls can be chained.
- */
- order: function (o) {
- if (o == null) {
- return facet[name].terms_stats.order;
- }
-
- o = o.toLowerCase();
- if (o === 'count' || o === 'term' || o === 'reverse_count' ||
- o === 'reverse_term' || o === 'total' || o === 'reverse_total' ||
- o === 'min' || o === 'reverse_min' || o === 'max' ||
- o === 'reverse_max' || o === 'mean' || o === 'reverse_mean') {
-
- facet[name].terms_stats.order = o;
- }
-
- return this;
- },
-
- /**
- Filter object.
- @returns {Object} returns this so that calls can be chained.
- */
- facetFilter: function (oFilter) {
- if (oFilter == null) {
- return facet[name].facet_filter;
- }
-
- if (!isFilter(oFilter)) {
- throw new TypeError('Argument must be a Filter');
- }
-
- facet[name].facet_filter = oFilter._self();
- return this;
- },
-
- /**
- this so that calls can be chained.
- */
- global: function (trueFalse) {
- if (trueFalse == null) {
- return facet[name].global;
- }
-
- facet[name].global = trueFalse;
- return this;
- },
-
- /**
- this so that calls can be chained.
- */
- scope: function (scope) {
- if (scope == null) {
- return facet[name].scope;
- }
-
- facet[name].scope = scope;
- return this;
- },
-
- /**
- facetFilterthis so that calls can be chained.
- */
- cacheFilter: function (trueFalse) {
- if (trueFalse == null) {
- return facet[name].cache_filter;
- }
-
- facet[name].cache_filter = trueFalse;
- return this;
- },
-
- /**
- this so that calls can be chained.
- */
- nested: function (path) {
- if (path == null) {
- return facet[name].nested;
- }
-
- facet[name].nested = path;
- return this;
- },
-
- /**
- facet object. This is typically used by
- internal API functions so use with caution.facet property.
- */
- _self: function () {
- return facet;
- }
- };
- };
-
/**
@class
A container Filter that allows Boolean AND composition of Filters.
@@ -4740,7 +4946,40 @@
return this;
},
-
+
+ /**
+
+
+
+ recursive - default, recursively traverse nodes in
+ the spatial prefix tree. This strategy has support for
+ searching non-point shapes.term - uses a large TermsFilter on each node
+ in the spatial prefix tree. It only supports the search of
+ indexed Point shapes.this so that calls can be chained.
+ */
+ strategy: function (strategy) {
+ if (strategy == null) {
+ return filter.geo_shape[field].strategy;
+ }
+
+ strategy = strategy.toLowerCase();
+ if (strategy === 'recursive' || strategy === 'term') {
+ filter.geo_shape[field].strategy = strategy;
+ }
+
+ return this;
+ },
+
/**
Sets the filter name.
@@ -4875,6 +5114,27 @@
return this;
},
+ /**
+ Sets the filter
+
+ @since elasticsearch 0.90
+ @member ejs.HasChildFilter
+ @param {Query} f A valid Filter object
+ @returns {Object} returns this so that calls can be chained.
+ */
+ filter: function (f) {
+ if (f == null) {
+ return filter.has_child.filter;
+ }
+
+ if (!isFilter(f)) {
+ throw new TypeError('Argument must be a Filter object');
+ }
+
+ filter.has_child.filter = f._self();
+ return this;
+ },
+
/**
Sets the child document type to search against
@@ -4895,16 +5155,12 @@
Sets the scope of the filter. A scope allows to run facets on the
same scope name that will work against the child documents.
+ @deprecated since elasticsearch 0.90
@member ejs.HasChildFilter
@param {String} s The scope name as a string.
@returns {Object} returns this so that calls can be chained.
*/
scope: function (s) {
- if (s == null) {
- return filter.has_child._scope;
- }
-
- filter.has_child._scope = s;
return this;
},
@@ -5009,6 +5265,27 @@
filter.has_parent.query = q._self();
return this;
},
+
+ /**
+ Sets the filter
+
+ @since elasticsearch 0.90
+ @member ejs.HasParentFilter
+ @param {Object} f A valid Filter object
+ @returns {Object} returns this so that calls can be chained.
+ */
+ filter: function (f) {
+ if (f == null) {
+ return filter.has_parent.filter;
+ }
+
+ if (!isFilter(f)) {
+ throw new TypeError('Argument must be a Filter object');
+ }
+
+ filter.has_parent.filter = f._self();
+ return this;
+ },
/**
Sets the child document type to search against
@@ -5030,16 +5307,12 @@
Sets the scope of the filter. A scope allows to run facets on the
same scope name that will work against the parent documents.
+ @deprecated since elasticsearch 0.90
@member ejs.HasParentFilter
@param {String} s The scope name as a string.
@returns {Object} returns this so that calls can be chained.
*/
scope: function (s) {
- if (s == null) {
- return filter.has_parent._scope;
- }
-
- filter.has_parent._scope = s;
return this;
},
@@ -5742,23 +6015,36 @@
return this;
},
+ /**
+ If the nested query should be "joined" with the parent document.
+ Defaults to false.
+
+ @member ejs.NestedFilter
+ @param {Boolean} trueFalse If the query should be joined or not.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ join: function (trueFalse) {
+ if (trueFalse == null) {
+ return filter.nested.join;
+ }
+
+ filter.nested.join = trueFalse;
+ return this;
+ },
+
/**
Sets the scope of the filter. A scope allows to run facets on the
same scope name that will work against the nested documents.
+ @deprecated since elasticsearch 0.90
@member ejs.NestedFilter
@param {String} s The scope name as a string.
@returns {Object} returns this so that calls can be chained.
*/
scope: function (s) {
- if (s == null) {
- return filter.nested._scope;
- }
-
- filter.nested._scope = s;
return this;
},
-
+
/**
Sets the filter name.
@@ -7494,6 +7780,20 @@
*/
var filter = {
terms: {}
+ },
+
+ // make sure we are setup for a list of terms
+ setupTerms = function () {
+ if (!isArray(filter.terms[field])) {
+ filter.terms[field] = [];
+ }
+ },
+
+ // make sure we are setup for a terms lookup
+ setupLookup = function () {
+ if (isArray(filter.terms[field])) {
+ filter.terms[field] = {};
+ }
};
if (isArray(terms)) {
@@ -7535,10 +7835,11 @@
@returns {Object} returns this so that calls can be chained.
*/
terms: function (t) {
+ setupTerms();
if (t == null) {
return filter.terms[field];
}
-
+
if (isArray(t)) {
filter.terms[field] = t;
} else {
@@ -7548,6 +7849,84 @@
return this;
},
+ /**
+ Sets the index the document containing the terms is in when
+ performing a terms lookup. Defaults to the index currently
+ being searched.
+
+ @since elasticsearch 0.90
+ @member ejs.TermsFilter
+ @param {String} idx A valid index name.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ index: function (idx) {
+ setupLookup();
+ if (idx == null) {
+ return filter.terms[field].index;
+ }
+
+ filter.terms[field].index = idx;
+ return this;
+ },
+
+ /**
+ Sets the type the document containing the terms when performing a
+ terms lookup.
+
+ @since elasticsearch 0.90
+ @member ejs.TermsFilter
+ @param {String} type A valid type name.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ type: function (type) {
+ setupLookup();
+ if (type == null) {
+ return filter.terms[field].type;
+ }
+
+ filter.terms[field].type = type;
+ return this;
+ },
+
+
+ /**
+ Sets the document id of the document containing the terms to use
+ when performing a terms lookup.
+
+ @since elasticsearch 0.90
+ @member ejs.TermsFilter
+ @param {String} id A valid index name.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ id: function (id) {
+ setupLookup();
+ if (id == null) {
+ return filter.terms[field].id;
+ }
+
+ filter.terms[field].id = id;
+ return this;
+ },
+
+ /**
+ Sets the path/field name where the terms in the source document
+ are located when performing a terms lookup.
+
+ @since elasticsearch 0.90
+ @member ejs.TermsFilter
+ @param {String} path A valid index name.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ path: function (path) {
+ setupLookup();
+ if (path == null) {
+ return filter.terms[field].path;
+ }
+
+ filter.terms[field].path = path;
+ return this;
+ },
+
/**
Sets the way terms filter executes is by iterating over the terms
provided and finding matches docs (loading into a bitset) and
@@ -7855,13 +8234,14 @@
},
/**
- Sets the routing value. By default, the shard the document is
- placed on is controlled by using a hash of the document’s id
- value. For more explicit control, this routing value will be fed
- into the hash function used by the router.
+ index, delete, get, and updateindex, delete, get, and update.index and update
The provided ttl must be strictly positive and can be a number (in milliseconds)
+ or any valid time value such as "1d", "2h", "5m", etc.
This option is valid during the following operations:
+ index and update
Set's a timeout for the given operation.
+ + If the primary shard has not completed the operation before this value, an error will + occur. The default timeout is 1 minute. The provided timeout must be strictly positive + and can be a number (in milliseconds) or any valid time value such as +"1d", "2h", "5m", etc.
- This option is valid during the following operations:
- index, delete, and update
+ This option is valid during the following operations:
+ index, delete, and update
Enables the index to be refreshed immediately after the operation + occurs. This is an advanced setting and can lead to performance + issues.
- This option is valid during the following operations: - index, delete, get, and update +This option is valid during the following operations:
+ index, delete, get, and update
Sets the document version.
+ + Used for optimistic concurrency control when set. If the version of the currently + indexed document is less-than or equal to the version specified, an error is produced, + otherwise the operation is permitted. + +By default, internal versioning is used that starts at 1 and
+ increments with each update.
This option is valid during the following operations:
+ index, delete, and update
Sets the version type.
+ + Possible values are: - internal - the default - external - to use your own version (ie. version number from a database) +internal - the defaultexternal - to use your own version (ie. version number from a database)This option is valid during the following operations:
+ index, delete, and update
Perform percolation at index time.
+ +Set to * to run document against all registered queries. It is also possible
+ to set this value to a string in query string format, ie. "color:green".
This option is valid during the following operations:
+ index and update
Sets the indexing operation type.
+ +Valid values are:
- index - the default, create or replace - create - create only +index - the default, create or replacecreate - create onlyThis option is valid during the following operations:
+ index
Sets the replication mode.
+ +Valid values are:
- async - asynchronous replication to slaves - sync - synchronous replication to the slaves - default - the currently configured system default. +async - asynchronous replication to slavessync - synchronous replication to the slavesdefault - the currently configured system default.This option is valid during the following operations:
+ index, delete, and update
Sets the write consistency.
+ +Valid values are:
- one - only requires write to one shard - quorum - requires writes to quorum (N/2 + 1) - all - requires write to succeed on all shards - default - the currently configured system default +one - only requires write to one shardquorum - requires writes to quorum (N/2 + 1)all - requires write to succeed on all shardsdefault - the currently configured system defaultThis option is valid during the following operations:
+ index, delete, and update
Sets the preference of which shard replicas to execute the get + request on.
+ +By default, the operation is randomized between the shard replicas. + This value can be:
- _primary - execute only on the primary shard - _local - the local shard if possible - any string value - to guarentee the same shards will always be used +_primary - execute only on the primary shard_local - the local shard if possibleany string value - to guarentee the same shards will always be usedThis option is valid during the following operations:
+ get
Sets if the get request is performed in realtime or waits for + the indexing operations to complete. By default it is realtime.
- This option is valid during the following operations: - get +This option is valid during the following operations:
+ get
Sets the fields of the document to return.
+ +By default the _source field is returned. Pass a single value
+ to append to the current list of fields, pass an array to overwrite the current
+ list of fields. The returned fields will either be loaded if they are stored,
+ or fetched from the _source
This option is valid during the following operations:
+ get and update
Sets the update script.
- This option is valid during the following operations: - update +This option is valid during the following operations:
+ update
Sets the update script lanauge. Defaults to mvel
This option is valid during the following operations:
+ update
Sets the parameters sent to the update script.
+ +The params must be an object where the key is the parameter name and + the value is the parameter value to use in the script.
- This option is valid during the following operations: - update +This option is valid during the following operations:
+ update
Sets how many times to retry if there is a version conflict + between getting the document and indexing / deleting it.
- This option is valid during the following operations: - update +Defaults to 0.
+ +
This option is valid during the following operations:
+ update
Sets the upsert document.
+ +The upsert document is used during updates when the specified document + you are attempting to update does not exist.
- This option is valid during the following operations: - update +This option is valid during the following operations:
+ update
Sets the source document.
- This option is valid during the following operations: - index and update +When set during an update operation, it is used as the partial update document.
+ +This option is valid during the following operations:
+ index and update
The type of ejs object. For internal use only.
@member ejs.Document @returns {String} the type of object @@ -8389,10 +8802,11 @@Retrieves a document from the given index and type.
@member ejs.Document - @param {Function} fnCallBack A callback function that handles the response. + @param {Function} successcb A callback function that handles the response. + @param {Function} errorcb A callback function that handles errors. @returns {Object} The return value is dependent on client implementation. */ - doGet: function (fnCallBack) { + doGet: function (successcb, errorcb) { // make sure the user has set a client if (ejs.client == null) { throw new Error("No Client Set"); @@ -8407,7 +8821,7 @@ // params as the data var url = '/' + index + '/' + type + '/' + id; - return ejs.client.get(url, genClientParams(), fnCallBack); + return ejs.client.get(url, genClientParams(), successcb, errorcb); }, /** @@ -8415,10 +8829,11 @@ is set, one is created during indexing. @member ejs.Document - @param {Function} fnCallBack A callback function that handles the response. + @param {Function} successcb A callback function that handles the response. + @param {Function} errorcb A callback function that handles errors. @returns {Object} The return value is dependent on client implementation. */ - doIndex: function (fnCallBack) { + doIndex: function (successcb, errorcb) { // make sure the user has set a client if (ejs.client == null) { throw new Error("No Client Set"); @@ -8447,27 +8862,30 @@ // do post if id not set so one is created if (id == null) { - response = ejs.client.post(url, data, fnCallBack); + response = ejs.client.post(url, data, successcb, errorcb); } else { // put when id is specified - response = ejs.client.put(url, data, fnCallBack); + response = ejs.client.put(url, data, successcb, errorcb); } return response; }, /** -Updates a document in the given index and type. If the - document is not found in the index, the "upsert" value is used - if set. The document is updated via an update script or partial - document. To use a script, set the script option, to use a +
Updates a document in the given index and type.
+ +If the document is not found in the index, the "upsert" value is used + if set. The document is updated via an update script or partial document.
+ +To use a script, set the script option, to use a partial document, set the source with the partial document.
@member ejs.Document - @param {Function} fnCallBack A callback function that handles the response. + @param {Function} successcb A callback function that handles the response. + @param {Function} errorcb A callback function that handles errors. @returns {Object} The return value is dependent on client implementation. */ - doUpdate: function (fnCallBack) { + doUpdate: function (successcb, errorcb) { // make sure the user has set a client if (ejs.client == null) { throw new Error("No Client Set"); @@ -8509,7 +8927,7 @@ data.doc = params.source; } - return ejs.client.post(url, JSON.stringify(data), fnCallBack); + return ejs.client.post(url, JSON.stringify(data), successcb, errorcb); }, /** @@ -8517,10 +8935,11 @@ speciifed id. @member ejs.Document - @param {Function} fnCallBack A callback function that handles the response. + @param {Function} successcb A callback function that handles the response. + @param {Function} errorcb A callback function that handles errors. @returns {void} Returns the value of the callback when executing on the server. */ - doDelete: function (fnCallBack) { + doDelete: function (successcb, errorcb) { // make sure the user has set a client if (ejs.client == null) { throw new Error("No Client Set"); @@ -8538,7 +8957,7 @@ url = url + '?' + paramStr; } - return ejs.client.del(url, data, fnCallBack); + return ejs.client.del(url, data, successcb, errorcb); } }; @@ -8713,15 +9132,15 @@ }, /** - Sets the number of optional clauses that must match. +Sets the number of optional clauses that must match.
- By default no optional clauses are necessary for a match +By default no optional clauses are necessary for a match (unless there are no required clauses). If this method is used, - then the specified number of clauses is required.. + then the specified number of clauses is required.
- Use of this method is totally independent of specifying that +Use of this method is totally independent of specifying that any specific clauses are required (or prohibited). This number will - only be compared against the number of matching optional clauses. + only be compared against the number of matching optional clauses.
@member ejs.BoolQuery @param {Integer} minMatch A positiveinteger value.
@@ -8916,6 +9335,251 @@
};
};
+ /**
+ @class
+ A query that executes high-frequency terms in a optional sub-query to + prevent slow queries due to "common" terms like stopwords.
+ +This query basically builds two queries out of the terms in the query + string where low-frequency terms are added to a required boolean clause and + high-frequency terms are added to an optional boolean clause. The optional + clause is only executed if the required "low-frequency' clause matches.
+ +CommonTermsQuery has several advantages over stopword
+ filtering at index or query time since a term can be "classified" based on
+ the actual document frequency in the index and can prevent slow queries even
+ across domains without specialized stopword files.
Use get()
+ @member ejs.CommonTermsQuery
+ @property {Object} query
+ */
+ var query = {
+ common: {}
+ };
+
+ // support for full Builder functionality where no constructor is used
+ // use dummy field until one is set
+ if (field == null) {
+ field = 'no_field_set';
+ }
+
+ query.common[field] = {};
+
+ // only set the query is one is passed in
+ if (qstr != null) {
+ query.common[field].query = qstr;
+ }
+
+ return {
+
+ /**
+ Sets the field to query against.
+
+ @member ejs.CommonTermsQuery
+ @param {String} f A valid field name.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ field: function (f) {
+ var oldValue = query.common[field];
+
+ if (f == null) {
+ return field;
+ }
+
+ delete query.common[field];
+ field = f;
+ query.common[f] = oldValue;
+
+ return this;
+ },
+
+ /**
+ Sets the query string.
+
+ @member ejs.CommonTermsQuery
+ @param {String} qstr The query string.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ query: function (qstr) {
+ if (qstr == null) {
+ return query.common[field].query;
+ }
+
+ query.common[field].query = qstr;
+ return this;
+ },
+
+ /**
+ Sets the analyzer name used to analyze the Query object.
+
+ @member ejs.CommonTermsQuery
+ @param {String} analyzer A valid analyzer name.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ analyzer: function (analyzer) {
+ if (analyzer == null) {
+ return query.common[field].analyzer;
+ }
+
+ query.common[field].analyzer = analyzer;
+ return this;
+ },
+
+ /**
+ Enables or disables similarity coordinate scoring of documents
+ commoning the Query. Default: false.
+
+ @member ejs.CommonTermsQuery
+ @param {String} trueFalse A true/falsethis so that calls can be chained.
+ */
+ disableCoords: function (trueFalse) {
+ if (trueFalse == null) {
+ return query.common[field].disable_coords;
+ }
+
+ query.common[field].disable_coords = trueFalse;
+ return this;
+ },
+
+ /**
+ Sets the maximum threshold/frequency to be considered a low
+ frequency term. Set to a value between 0 and 1.
+
+ @member ejs.CommonTermsQuery
+ @param {Number} freq A positive double value.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ cutoffFrequency: function (freq) {
+ if (freq == null) {
+ return query.common[field].cutoff_frequency;
+ }
+
+ query.common[field].cutoff_frequency = freq;
+ return this;
+ },
+
+ /**
+ Sets the boolean operator to be used for high frequency terms.
+ Default: AND
+
+ @member ejs.CommonTermsQuery
+ @param {String} op Any of "and" or "or", no quote characters.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ highFreqOperator: function (op) {
+ if (op == null) {
+ return query.common[field].high_freq_operator;
+ }
+
+ op = op.toLowerCase();
+ if (op === 'and' || op === 'or') {
+ query.common[field].high_freq_operator = op;
+ }
+
+ return this;
+ },
+
+ /**
+ Sets the boolean operator to be used for low frequency terms.
+ Default: AND
+
+ @member ejs.CommonTermsQuery
+ @param {String} op Any of "and" or "or", no quote characters.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ lowFreqOperator: function (op) {
+ if (op == null) {
+ return query.common[field].low_freq_operator;
+ }
+
+ op = op.toLowerCase();
+ if (op === 'and' || op === 'or') {
+ query.common[field].low_freq_operator = op;
+ }
+
+ return this;
+ },
+
+ /**
+ Sets the minimum number of common that need to common in a document
+ before that document is returned in the results.
+
+ @member ejs.CommonTermsQuery
+ @param {Integer} min A positive integer.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ minimumShouldMatch: function (min) {
+ if (min == null) {
+ return query.common[field].minimum_should_match;
+ }
+
+ query.common[field].minimum_should_match = min;
+ return this;
+ },
+
+ /**
+ Sets the boost value for documents commoning the Query.
+
+ @member ejs.CommonTermsQuery
+ @param {Number} boost A positive double value.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ boost: function (boost) {
+ if (boost == null) {
+ return query.common[field].boost;
+ }
+
+ query.common[field].boost = boost;
+ return this;
+ },
+
+ /**
+ Allows you to serialize this object into a JSON encoded string.
+
+ @member ejs.CommonTermsQuery
+ @returns {String} returns this object as a serialized JSON string.
+ */
+ toString: function () {
+ return JSON.stringify(query);
+ },
+
+ /**
+ The type of ejs object. For internal use only.
+
+ @member ejs.CommonTermsQuery
+ @returns {String} the type of object
+ */
+ _type: function () {
+ return 'query';
+ },
+
+ /**
+ Retrieves the internal query object. This is typically used by
+ internal API functions so use with caution.
+
+ @member ejs.CommonTermsQuery
+ @returns {String} returns this object's internal query property.
+ */
+ _self: function () {
+ return query;
+ }
+ };
+ };
+
/**
@class
A constant score query wraps another Query or
@@ -9277,11 +9941,12 @@
},
/**
- Sets the filters and their related boost or script scoring method.
- Takes an array of objects where each object has a 'filter' property
+
Sets the filters and their related boost or script scoring method.
+ +Takes an array of objects where each object has a 'filter' property and either a 'boost' or 'script' property. Pass a single object to add to the current list of filters or pass a list of objects to - overwrite all existing filters. + overwrite all existing filters.
{filter: someFilter, boost: 2.1}
@@ -9312,12 +9977,13 @@
},
/**
- A score_mode can be defined to control how multiple matching
- filters control the score. By default, it is set to first which
- means the first matching filter will control the score of the
- result. It can also be set to min/max/total/avg/multiply which
- will aggregate the result from all matching filters based on the
- aggregation type.
+ A score_mode can be defined to control how multiple matching
+ filters control the score.
+
+
By default, it is set to first which means the first matching filter
+ will control the score of the result. It can also be set to
+ min/max/total/avg/multiply which will aggregate the result from all
+ matching filters based on the aggregation type.
@member ejs.CustomFiltersScoreQuery
@param {String} s The scoring type as a string.
@@ -9671,11 +10337,14 @@
/**
- The tie breaker value. The tie breaker capability allows results
- that include the same term in multiple fields to be judged better than
- results that include this term in only the best of those multiple
- fields, without confusing this with the better case of two different
- terms in the multiple fields. Default: 0.0.
+
The tie breaker value.
+
+ The tie breaker capability allows results that include the same term in multiple
+ fields to be judged better than results that include this term in only the best of those
+ multiple fields, without confusing this with the better case of two different terms in
+ the multiple fields.
+
+ Default: 0.0.
@member ejs.DisMaxQuery
@param {Double} tieBreaker A positive double value.
@@ -9723,6 +10392,7 @@
};
};
+
/**
@class
Wrapper to allow SpanQuery objects participate in composite single-field
@@ -9897,7 +10567,7 @@
},
/**
- Sets the query string.
+
Sets the query string.
@member ejs.FieldQuery
@param {String} q The lucene query string.
@@ -9913,10 +10583,11 @@
},
/**
- Set the default Boolean operator. This operator is used
- to join individual query terms when no operator is explicity used
- in the query string (i.e., this AND that).
- Defaults to OR (same as Google).
+ Set the default Boolean operator.
+
+ This operator is used to join individual query terms when no operator is
+ explicity used in the query string (i.e., this AND that).
+ Defaults to OR (same as Google).
@member ejs.FieldQuery
@param {String} op The operator, AND or OR.
@@ -9936,7 +10607,7 @@
},
/**
- Sets the analyzer name used to analyze the Query object.
+ Sets the analyzer name used to analyze the Query object.
@member ejs.FieldQuery
@param {String} analyzer A valid analyzer name.
@@ -9952,8 +10623,8 @@
},
/**
- Sets the quote analyzer name used to analyze the query
- when in quoted text.
+ Sets the quote analyzer name used to analyze the query
+ when in quoted text.
@member ejs.FieldQuery
@param {String} analyzer A valid analyzer name.
@@ -9969,8 +10640,8 @@
},
/**
- Sets whether or not we should auto generate phrase queries *if* the
- analyzer returns more than one term. Default: false.
+ Sets whether or not we should auto generate phrase queries *if* the
+ analyzer returns more than one term. Default: false.
@member ejs.FieldQuery
@param {Boolean} trueFalse A true/false value.
@@ -9986,8 +10657,10 @@
},
/**
- Sets whether or not wildcard characters (* and ?) are allowed as the
- first character of the Query. Default: true.
+ Sets whether or not wildcard characters (* and ?) are allowed as the
+ first character of the Query.
+
+ Default: true.
@member ejs.FieldQuery
@param {Boolean} trueFalse A true/false value.
@@ -10003,9 +10676,11 @@
},
/**
- Sets whether or not terms from wildcard, prefix, fuzzy, and
- range queries should automatically be lowercased in the Query
- since they are not analyzed. Default: true.
+ Sets whether or not terms from wildcard, prefix, fuzzy, and
+ range queries should automatically be lowercased in the Query
+ since they are not analyzed.
+
+ Default: true.
@member ejs.FieldQuery
@param {Boolean} trueFalse A true/false value.
@@ -10021,8 +10696,10 @@
},
/**
- Sets whether or not position increments will be used in the
- Query. Default: true.
+ Sets whether or not position increments will be used in the
+ Query.
+
+ Default: true.
@member ejs.FieldQuery
@param {Boolean} trueFalse A true/false value.
@@ -10038,7 +10715,9 @@
},
/**
- Set the minimum similarity for fuzzy queries. Default: 0.5.
+ Set the minimum similarity for fuzzy queries.
+
+ Default: 0.5.
@member ejs.FieldQuery
@param {Double} minSim A double value between 0 and 1.
@@ -10054,7 +10733,9 @@
},
/**
- Sets the boost value of the Query. Default: 1.0.
+ Sets the boost value of the Query.
+
+ Default: 1.0.
@member ejs.FieldQuery
@param {Double} boost A positive double value.
@@ -10070,7 +10751,9 @@
},
/**
- Sets the prefix length for fuzzy queries. Default: 0.
+ Sets the prefix length for fuzzy queries.
+
+ Default: 0.
@member ejs.FieldQuery
@param {Integer} fuzzLen A positive integer value.
@@ -10086,7 +10769,7 @@
},
/**
- Sets the max number of term expansions for fuzzy queries.
+ Sets the max number of term expansions for fuzzy queries.
@member ejs.FieldQuery
@param {Integer} max A positive integer value.
@@ -10102,31 +10785,35 @@
},
/**
- Sets fuzzy rewrite method. Valid values are:
-
- constant_score_auto - tries to pick the best constant-score rewrite
- method based on term and document counts from the query
-
- scoring_boolean - translates each term into boolean should and
- keeps the scores as computed by the query
-
- constant_score_boolean - same as scoring_boolean, expect no scores
- are computed.
-
- constant_score_filter - first creates a private Filter, by visiting
- each term in sequence and marking all docs for that term
-
- top_terms_boost_N - first translates each term into boolean should
- and scores are only computed as the boost using the top N
- scoring terms. Replace N with an integer value.
-
- top_terms_N - first translates each term into boolean should
- and keeps the scores as computed by the query. Only the top N
- scoring terms are used. Replace N with an integer value.
-
- Default is constant_score_auto.
+ Sets fuzzy rewrite method.
- This is an advanced option, use with care.
+
Valid values are:
+
+
+ constant_score_auto - tries to pick the best constant-score rewrite
+ method based on term and document counts from the query
+
+ scoring_boolean - translates each term into boolean should and
+ keeps the scores as computed by the query
+
+ constant_score_boolean - same as scoring_boolean, expect no scores
+ are computed.
+
+ constant_score_filter - first creates a private Filter, by visiting
+ each term in sequence and marking all docs for that term
+
+ top_terms_boost_N - first translates each term into boolean should
+ and scores are only computed as the boost using the top N
+ scoring terms. Replace N with an integer value.
+
+ top_terms_N - first translates each term into boolean should
+ and keeps the scores as computed by the query. Only the top N
+ scoring terms are used. Replace N with an integer value.
+
+
+ Default is constant_score_auto.
+
+ This is an advanced option, use with care.
@member ejs.FieldQuery
@param {String} m The rewrite method as a string.
@@ -10150,29 +10837,33 @@
},
/**
- Sets rewrite method. Valid values are:
+ Sets rewrite method.
+
+ Valid values are:
- constant_score_auto - tries to pick the best constant-score rewrite
- method based on term and document counts from the query
+
+ constant_score_auto - tries to pick the best constant-score rewrite
+ method based on term and document counts from the query
- scoring_boolean - translates each term into boolean should and
- keeps the scores as computed by the query
+ scoring_boolean - translates each term into boolean should and
+ keeps the scores as computed by the query
- constant_score_boolean - same as scoring_boolean, expect no scores
- are computed.
+ constant_score_boolean - same as scoring_boolean, expect no scores
+ are computed.
- constant_score_filter - first creates a private Filter, by visiting
- each term in sequence and marking all docs for that term
+ constant_score_filter - first creates a private Filter, by visiting
+ each term in sequence and marking all docs for that term
- top_terms_boost_N - first translates each term into boolean should
- and scores are only computed as the boost using the top N
- scoring terms. Replace N with an integer value.
+ top_terms_boost_N - first translates each term into boolean should
+ and scores are only computed as the boost using the top N
+ scoring terms. Replace N with an integer value.
- top_terms_N - first translates each term into boolean should
- and keeps the scores as computed by the query. Only the top N
- scoring terms are used. Replace N with an integer value.
+ top_terms_N - first translates each term into boolean should
+ and keeps the scores as computed by the query. Only the top N
+ scoring terms are used. Replace N with an integer value.
+
- Default is constant_score_auto.
+ Default is constant_score_auto.
This is an advanced option, use with care.
@@ -10198,8 +10889,8 @@
},
/**
- Sets the suffix to automatically add to the field name when
- performing a quoted search.
+ Sets the suffix to automatically add to the field name when
+ performing a quoted search.
@member ejs.FieldQuery
@param {String} s The suffix as a string.
@@ -10215,8 +10906,10 @@
},
/**
- Sets the default slop for phrases. If zero, then exact phrase matches
- are required. Default: 0.
+ Sets the default slop for phrases. If zero, then exact phrase matches
+ are required.
+
+ Default: 0.
@member ejs.FieldQuery
@param {Integer} slop A positive integer value.
@@ -10232,9 +10925,12 @@
},
/**
- Sets whether or not we should attempt to analyzed wilcard terms in the
- Query. By default, wildcard terms are not analyzed.
- Analysis of wildcard characters is not perfect. Default: false.
+ Sets whether or not we should attempt to analyzed wilcard terms in the
+ Query.
+
+ By default, wildcard terms are not analyzed. Analysis of wildcard characters is not perfect.
+
+ Default: false.
@member ejs.FieldQuery
@param {Boolean} trueFalse A true/false value.
@@ -10250,7 +10946,7 @@
},
/**
- If they query string should be escaped or not.
+ If the query string should be escaped or not.
@member ejs.FieldQuery
@param {Boolean} trueFalse A true/false value.
@@ -10266,8 +10962,8 @@
},
/**
- Sets a percent value controlling how many "should" clauses in the
- resulting Query should match.
+ Sets a percent value controlling how many should clauses in the
+ resulting Query should match.
@member ejs.FieldQuery
@param {Integer} minMatch An integer between 0 and 100.
@@ -10283,7 +10979,7 @@
},
/**
- Allows you to serialize this object into a JSON encoded string.
+ Allows you to serialize this object into a JSON encoded string.
@member ejs.FieldQuery
@returns {String} returns this object as a serialized JSON string.
@@ -10293,7 +10989,7 @@
},
/**
- The type of ejs object. For internal use only.
+ The type of ejs object. For internal use only.
@member ejs.FieldQuery
@returns {String} the type of object
@@ -10303,8 +10999,8 @@
},
/**
- Retrieves the internal query object. This is typically used by
- internal API functions so use with caution.
+ Retrieves the internal query object. This is typically used by
+ internal API functions so use with caution.
@member ejs.FieldQuery
@returns {String} returns this object's internal query property.
@@ -10361,7 +11057,7 @@
return {
/**
- Adds the query to apply a constant score to.
+ Adds the query to apply a constant score to.
@member ejs.FilteredQuery
@param {Object} oQuery A valid Query object
@@ -10381,7 +11077,7 @@
},
/**
- Adds the filter to apply a constant score to.
+ Adds the filter to apply a constant score to.
@member ejs.FilteredQuery
@param {Object} oFilter A valid Filter object
@@ -10401,17 +11097,21 @@
},
/**
- Sets the filter strategy. The strategy defines how the filter is
- applied during document collection. Valid values are:
-
- query_filter - advance query scorer first then filter
- random_access_random - random access filter
- leap_frog - query scorer and filter "leap-frog", query goes first
- leap_frog_filter_first - same as leap_frog, but filter goes first
- random_access_N - replace N with integer, same as random access
- except you can specify a custom threshold
+ Sets the filter strategy.
- This is an advanced setting, use with care.
+ The strategy defines how the filter is applied during document collection.
+ Valid values are:
+
+
+ query_first - advance query scorer first then filter
+ random_access_random - random access filter
+ leap_frog - query scorer and filter "leap-frog", query goes first
+ leap_frog_filter_first - same as leap_frog, but filter goes first
+ random_access_N - replace N with integer, same as random access
+ except you can specify a custom threshold
+
+
+ This is an advanced setting, use with care.
@member ejs.FilteredQuery
@param {String} strategy The strategy as a string.
@@ -10423,7 +11123,7 @@
}
strategy = strategy.toLowerCase();
- if (strategy === 'query_filter' || strategy === 'random_access_random' ||
+ if (strategy === 'query_first' || strategy === 'random_access_always' ||
strategy === 'leap_frog' || strategy === 'leap_frog_filter_first' ||
strategy.indexOf('random_access_') === 0) {
@@ -10434,7 +11134,7 @@
},
/**
- Enables caching of the filter.
+ Enables caching of the filter.
@member ejs.FilteredQuery
@param {Boolean} trueFalse A boolean value.
@@ -10450,7 +11150,7 @@
},
/**
- Set the cache key.
+ Set the cache key.
@member ejs.FilteredQuery
@param {String} k A string cache key.
@@ -10466,7 +11166,7 @@
},
/**
- Sets the boost value of the Query.
+ Sets the boost value of the Query.
@member ejs.FilteredQuery
@param {Double} boost A positive double value.
@@ -10482,7 +11182,8 @@
},
/**
- Converts this object to a json string
+ Converts this object to a json string
+
@member ejs.FilteredQuery
@returns {Object} string
*/
@@ -10491,7 +11192,7 @@
},
/**
- The type of ejs object. For internal use only.
+ The type of ejs object. For internal use only.
@member ejs.FilteredQuery
@returns {String} the type of object
@@ -10501,7 +11202,8 @@
},
/**
- returns the query object.
+ returns the query object.
+
@member ejs.FilteredQuery
@returns {Object} query object
*/
@@ -10981,7 +11683,7 @@
return {
/**
- The field to run the query against.
+ The field to run the query against.
@member ejs.FuzzyQuery
@param {String} f A single field name.
@@ -11002,7 +11704,7 @@
},
/**
- The query text to fuzzify.
+ The query text to fuzzify.
@member ejs.FuzzyQuery
@param {String} s A text string.
@@ -11018,7 +11720,7 @@
},
/**
- Set to false to use classic Levenshtein edit distance.
+ Set to false to use classic Levenshtein edit distance.
@member ejs.FuzzyQuery
@param {Boolean} trueFalse A boolean value
@@ -11034,8 +11736,8 @@
},
/**
- The maximum number of query terms that will be included in any
- generated query. Defaults to 50.
+ The maximum number of query terms that will be included in any
+ generated query. Defaults to 50.
@member ejs.FuzzyQuery
@param {Integer} max A positive integer value.
@@ -11051,7 +11753,7 @@
},
/**
- The minimum similarity of the term variants. Defaults to 0.5.
+
The minimum similarity of the term variants. Defaults to 0.5.
@member ejs.FuzzyQuery
@param {Double} min A positive double value.
@@ -11067,7 +11769,7 @@
},
/**
- Length of required common prefix on variant terms. Defaults to 0..
+ Length of required common prefix on variant terms. Defaults to 0.
@member ejs.FuzzyQuery
@param {Integer} len A positive integer value.
@@ -11083,31 +11785,33 @@
},
/**
- Sets rewrite method. Valid values are:
+ Sets rewrite method. Valid values are:
- constant_score_auto - tries to pick the best constant-score rewrite
- method based on term and document counts from the query
+
+ constant_score_auto - tries to pick the best constant-score rewrite
+ method based on term and document counts from the query
- scoring_boolean - translates each term into boolean should and
- keeps the scores as computed by the query
+ scoring_boolean - translates each term into boolean should and
+ keeps the scores as computed by the query
- constant_score_boolean - same as scoring_boolean, expect no scores
- are computed.
+ constant_score_boolean - same as scoring_boolean, expect no scores
+ are computed.
- constant_score_filter - first creates a private Filter, by visiting
- each term in sequence and marking all docs for that term
+ constant_score_filter - first creates a private Filter, by visiting
+ each term in sequence and marking all docs for that term
- top_terms_boost_N - first translates each term into boolean should
- and scores are only computed as the boost using the top N
- scoring terms. Replace N with an integer value.
+ top_terms_boost_N - first translates each term into boolean should
+ and scores are only computed as the boost using the top N
+ scoring terms. Replace N with an integer value.
- top_terms_N - first translates each term into boolean should
- and keeps the scores as computed by the query. Only the top N
- scoring terms are used. Replace N with an integer value.
+ top_terms_N - first translates each term into boolean should
+ and keeps the scores as computed by the query. Only the top N
+ scoring terms are used. Replace N with an integer value.
+
- Default is constant_score_auto.
+ Default is constant_score_auto.
- This is an advanced option, use with care.
+ This is an advanced option, use with care.
@member ejs.FuzzyQuery
@param {String} m The rewrite method as a string.
@@ -11132,7 +11836,7 @@
/**
- Sets the boost value of the Query.
+ Sets the boost value of the Query.
@member ejs.FuzzyQuery
@param {Double} boost A positive double value.
@@ -11148,7 +11852,8 @@
},
/**
- Serializes the internal query object as a JSON string.
+ Serializes the internal query object as a JSON string.
+
@member ejs.FuzzyQuery
@returns {String} Returns a JSON representation of the Query object.
*/
@@ -11157,7 +11862,7 @@
},
/**
- The type of ejs object. For internal use only.
+ The type of ejs object. For internal use only.
@member ejs.FuzzyQuery
@returns {String} the type of object
@@ -11167,8 +11872,9 @@
},
/**
- This method is used to retrieve the raw query object. It's designed
- for internal use when composing and serializing queries.
+ This method is used to retrieve the raw query object. It's designed
+ for internal use when composing and serializing queries.
+
@member ejs.FuzzyQuery
@returns {Object} Returns the object's query property.
*/
@@ -11294,7 +12000,40 @@
return this;
},
+
+ /**
+ Sets the spatial strategy.
+ Valid values are:
+
+ recursive - default, recursively traverse nodes in
+ the spatial prefix tree. This strategy has support for
+ searching non-point shapes.
+ term - uses a large TermsFilter on each node
+ in the spatial prefix tree. It only supports the search of
+ indexed Point shapes.
+
+
+ This is an advanced setting, use with care.
+
+ @since elasticsearch 0.90
+ @member ejs.GeoShapeQuery
+ @param {String} strategy The strategy as a string.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ strategy: function (strategy) {
+ if (strategy == null) {
+ return query.geo_shape[field].strategy;
+ }
+
+ strategy = strategy.toLowerCase();
+ if (strategy === 'recursive' || strategy === 'term') {
+ query.geo_shape[field].strategy = strategy;
+ }
+
+ return this;
+ },
+
/**
Sets the boost value for documents matching the Query.
@@ -11418,16 +12157,12 @@
Sets the scope of the query. A scope allows to run facets on the
same scope name that will work against the child documents.
+ @deprecated since elasticsearch 0.90
@member ejs.HasChildQuery
@param {String} s The scope name as a string.
@returns {Object} returns this so that calls can be chained.
*/
scope: function (s) {
- if (s == null) {
- return query.has_child._scope;
- }
-
- query.has_child._scope = s;
return this;
},
@@ -11579,16 +12314,12 @@
Sets the scope of the query. A scope allows to run facets on the
same scope name that will work against the parent documents.
+ @deprecated since elasticsearch 0.90
@member ejs.HasParentQuery
@param {String} s The scope name as a string.
@returns {Object} returns this so that calls can be chained.
*/
scope: function (s) {
- if (s == null) {
- return query.has_parent._scope;
- }
-
- query.has_parent._scope = s;
return this;
},
@@ -12140,6 +12871,24 @@
return this;
},
+ /**
+ Sets the maximum threshold/frequency to be considered a low
+ frequency term in a CommonTermsQuery.
+ Set to a value between 0 and 1.
+
+ @member ejs.MatchQuery
+ @param {Number} freq A positive double value.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ cutoffFrequency: function (freq) {
+ if (freq == null) {
+ return query.match[field].cutoff_frequency;
+ }
+
+ query.match[field].cutoff_frequency = freq;
+ return this;
+ },
+
/**
Sets the prefix length for a fuzzy prefix MatchQuery.
@@ -12376,7 +13125,7 @@
"all" or "none".
@member ejs.MatchQuery
- @param {String} q A valid analyzer name.
+ @param {String} q A no match action, "all" or "none".
@returns {Object} returns this so that calls can be chained.
*/
zeroTermsQuery: function (q) {
@@ -13120,6 +13869,24 @@
return this;
},
+ /**
+ Sets the maximum threshold/frequency to be considered a low
+ frequency term in a CommonTermsQuery.
+ Set to a value between 0 and 1.
+
+ @member ejs.MultiMatchQuery
+ @param {Number} freq A positive double value.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ cutoffFrequency: function (freq) {
+ if (freq == null) {
+ return query.multi_match.cutoff_frequency;
+ }
+
+ query.multi_match.cutoff_frequency = freq;
+ return this;
+ },
+
/**
Sets a percent value controlling how many "should" clauses in the
resulting Query should match.
@@ -13403,6 +14170,27 @@
return this;
},
+ /**
+ Sets what happens when no terms match. Valid values are
+ "all" or "none".
+
+ @member ejs.MultiMatchQuery
+ @param {String} q A no match action, "all" or "none".
+ @returns {Object} returns this so that calls can be chained.
+ */
+ zeroTermsQuery: function (q) {
+ if (q == null) {
+ return query.multi_match.zero_terms_query;
+ }
+
+ q = q.toLowerCase();
+ if (q === 'all' || q === 'none') {
+ query.multi_match.zero_terms_query = q;
+ }
+
+ return this;
+ },
+
/**
Allows you to serialize this object into a JSON encoded string.
@@ -13555,16 +14343,12 @@
Sets the scope of the query. A scope allows to run facets on the
same scope name that will work against the nested documents.
+ @deprecated since elasticsearch 0.90
@member ejs.NestedQuery
@param {String} s The scope name as a string.
@returns {Object} returns this so that calls can be chained.
*/
scope: function (s) {
- if (s == null) {
- return query.nested._scope;
- }
-
- query.nested._scope = s;
return this;
},
@@ -15801,16 +16585,12 @@
Sets the scope of the query. A scope allows to run facets on the
same scope name that will work against the child documents.
+ @deprecated since elasticsearch 0.90
@member ejs.TopChildrenQuery
@param {String} s The scope name as a string.
@returns {Object} returns this so that calls can be chained.
*/
scope: function (s) {
- if (s == null) {
- return query.top_children._scope;
- }
-
- query.top_children._scope = s;
return this;
},
@@ -16820,7 +17600,44 @@
*/
ejs.Request = function (conf) {
- var query, indices, types, routing;
+ var query, indices, types, params = {},
+
+ // gernerates the correct url to the specified REST endpoint
+ getRestPath = function (endpoint) {
+ var searchUrl = '',
+ parts = [];
+
+ // join any indices
+ if (indices.length > 0) {
+ searchUrl = searchUrl + '/' + indices.join();
+ }
+
+ // join any types
+ if (types.length > 0) {
+ searchUrl = searchUrl + '/' + types.join();
+ }
+
+ // add the endpoint
+ if (endpoint.length > 0 && endpoint[0] !== '/') {
+ searchUrl = searchUrl + '/';
+ }
+
+ searchUrl = searchUrl + endpoint;
+
+ for (var p in params) {
+ if (!has(params, p) || params[p] === '') {
+ continue;
+ }
+
+ parts.push(p + '=' + encodeURIComponent(params[p]));
+ }
+
+ if (parts.length > 0) {
+ searchUrl = searchUrl + '?' + parts.join('&');
+ }
+
+ return searchUrl;
+ };
/**
The internal query object.
@@ -16855,29 +17672,28 @@
}
if (conf.routing != null) {
- routing = conf.routing;
- } else {
- routing = '';
+ params.routing = conf.routing;
}
return {
/**
- Sets the sorting for the query. This accepts many input formats.
+ Sets the sorting for the query. This accepts many input formats.
- sort() - The current sorting values are returned.
- sort(fieldName) - Adds the field to the current list of sorting values.
- sort(fieldName, order) - Adds the field to the current list of
- sorting with the specified order. Order must be asc or desc.
- sort(ejs.Sort) - Adds the Sort value to the current list of sorting values.
- sort(array) - Replaces all current sorting values with values
- from the array. The array must contain only strings and Sort
- objects.
+
+ sort() - The current sorting values are returned.
+ sort(fieldName) - Adds the field to the current list of sorting values.
+ sort(fieldName, order) - Adds the field to the current list of
+ sorting with the specified order. Order must be asc or desc.
+ sort(ejs.Sort) - Adds the Sort value to the current list of sorting values.
+ sort(array) - Replaces all current sorting values with values
+ from the array. The array must contain only strings and Sort objects.
+
- Multi-level sorting is supported so the order in which sort fields
- are added to the query requests is relevant.
+ Multi-level sorting is supported so the order in which sort fields
+ are added to the query requests is relevant.
- It is recommended to use Sort objects when possible.
+ It is recommended to use Sort objects when possible.
@member ejs.Request
@param {String} fieldName The field to be sorted by.
@@ -16974,20 +17790,22 @@
},
/**
- A search timeout, bounding the search request to be executed
- within the specified time value and bail with the hits accumulated
- up to that point when expired. Defaults to no timeout.
+ A timeout, bounding the request to be executed within the
+ specified time value and bail when expired. Defaults to no timeout.
+ This option is valid during the following operations:
+ search and delete by query
+
@member ejs.Request
@param {Long} t The timeout value in milliseconds.
@returns {Object} returns this so that calls can be chained.
*/
timeout: function (t) {
if (t == null) {
- return query.timeout;
+ return params.timeout;
}
- query.timeout = t;
+ params.timeout = t;
return this;
},
@@ -16996,19 +17814,129 @@
values will be searched. Set to an empty string to disable routing.
Disabled by default.
+ This option is valid during the following operations:
+ search, count and delete by query
+
@member ejs.Request
@param {String} route The routing values as a comma-separated string.
@returns {Object} returns this so that calls can be chained.
*/
routing: function (route) {
if (route == null) {
- return routing;
+ return params.routing;
}
- routing = route;
+ params.routing = route;
return this;
},
+ /**
+ Sets the replication mode.
+
+ Valid values are:
+
+
+ async - asynchronous replication to slaves
+ sync - synchronous replication to the slaves
+ default - the currently configured system default.
+
+
+ This option is valid during the following operations:
+ delete by query
+
+ @member ejs.Request
+ @param {String} r The replication mode (async, sync, or default)
+ @returns {Object} returns this so that calls can be chained.
+ */
+ replication: function (r) {
+ if (r == null) {
+ return params.replication;
+ }
+
+ r = r.toLowerCase();
+ if (r === 'async' || r === 'sync' || r === 'default') {
+ params.replication = r;
+ }
+
+ return this;
+ },
+
+ /**
+ Sets the write consistency.
+
+ Valid values are:
+
+
+ one - only requires write to one shard
+ quorum - requires writes to quorum (N/2 + 1)
+ all - requires write to succeed on all shards
+ default - the currently configured system default
+
+
+ This option is valid during the following operations:
+ delete by query
+
+ @member ejs.Request
+ @param {String} c The write consistency (one, quorum, all, or default)
+ @returns {Object} returns this so that calls can be chained.
+ */
+ consistency: function (c) {
+ if (c == null) {
+ return params.consistency;
+ }
+
+ c = c.toLowerCase();
+ if (c === 'default' || c === 'one' || c === 'quorum' || c === 'all') {
+ params.consistency = c;
+ }
+
+ return this;
+ },
+
+ /**
+ Sets the search execution type for the request.
+
+ Valid values are:
+
+
+ dfs_query_then_fetch - same as query_then_fetch,
+ except distributed term frequencies are calculated first.
+ dfs_query_and_fetch - same as query_and_fetch,
+ except distributed term frequencies are calculated first.
+ query_then_fetch - executed against all
+ shards, but only enough information is returned. When ready,
+ only the relevant shards are asked for the actual document
+ content
+ query_and_fetch - execute the query on all
+ relevant shards and return the results, including content.
+ scan - efficiently scroll a large result set
+ count - special search type that returns the
+ count that matched the search request without any docs
+
+
+ This option is valid during the following operations:
+ search
+
+ @member ejs.Request
+ @param {String} t The search execution type
+ @returns {Object} returns this so that calls can be chained.
+ */
+ searchType: function (t) {
+ if (t == null) {
+ return params.search_type;
+ }
+
+ t = t.toLowerCase();
+ if (t === 'dfs_query_then_fetch' || t === 'dfs_query_and_fetch' ||
+ t === 'query_then_fetch' || t === 'query_and_fetch' ||
+ t === 'scan' || t === 'count') {
+
+ params.search_type = t;
+ }
+
+ return this;
+ },
+
/**
By default, searches return full documents, meaning every property or field.
This method allows you to specify which fields you want returned.
@@ -17204,6 +18132,39 @@
return this;
},
+ /**
+ Allows you to set the specified suggester on this request object.
+ Multiple suggesters can be set, all of which will be returned when
+ the search is executed. Global suggestion text can be set by
+ passing in a string vs. a Suggest object.
+
+ @since elasticsearch 0.90
+
+ @member ejs.Request
+ @param {String || Suggest} s A valid Suggest object or a String to
+ set as the global suggest text.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ suggest: function (s) {
+ if (s == null) {
+ return query.suggest;
+ }
+
+ if (query.suggest == null) {
+ query.suggest = {};
+ }
+
+ if (isString(s)) {
+ query.suggest.text = s;
+ } else if (isSuggest(s)) {
+ extend(query.suggest, s._self());
+ } else {
+ throw new TypeError('Argument must be a string or Suggest object');
+ }
+
+ return this;
+ },
+
/**
Computes a document property dynamically based on the supplied ScriptField.
@@ -17229,28 +18190,63 @@
},
/**
- Controls a preference of which shard replicas to execute the search request on.
+ Controls the preference of which shard replicas to execute the search request on.
By default, the operation is randomized between the each shard replicas. The
- preference can be one of the following:
+ preference can be one of the following:
- _primary - the operation will only be executed on primary shards
- _local - the operation will prefer to be executed on local shards
- _only_node:$nodeid - the search will only be executed on node with id $nodeid
- custom - any string, will guarentee searches always happen on same node.
+
+ _primary - the operation will only be executed on primary shards
+ _local - the operation will prefer to be executed on local shards
+ _only_node:$nodeid - the search will only be executed on node with id $nodeid
+ custom - any string, will guarentee searches always happen on same node.
+
+ This option is valid during the following operations:
+ search and count
+
@member ejs.Request
- @param {String} perf the preference, any of _primary, _local, _only_:$nodeid, or a custom string value.
+ @param {String} perf the preference, any of _primary, _local,
+ _only_:$nodeid, or a custom string value.
@returns {Object} returns this so that calls can be chained.
*/
preference: function (perf) {
if (perf == null) {
- return query.preference;
+ return params.preference;
}
- query.preference = perf;
+ params.preference = perf;
return this;
},
+ /**
+ Determines what type of indices to exclude from a request. The
+ value can be one of the following:
+
+
+ none - No indices / aliases will be excluded from a request
+ missing - Indices / aliases that are missing will be excluded from a request
+
+
+ This option is valid during the following operations:
+ search, count and delete by query
+
+ @member ejs.Request
+ @param {String} ignoreType the type of ignore (none or missing).
+ @returns {Object} returns this so that calls can be chained.
+ */
+ ignoreIndices: function (ignoreType) {
+ if (ignoreType == null) {
+ return params.ignore_indices;
+ }
+
+ ignoreType = ignoreType.toLowerCase();
+ if (ignoreType === 'none' || ignoreType === 'missing') {
+ params.ignore_indices = ignoreType;
+ }
+
+ return this;
+ },
+
/**
Boosts hits in the specified index by the given boost value.
@@ -17350,41 +18346,62 @@
_self: function () {
return query;
},
-
- /**
- Executes the search. This call runs synchronously when used on the server side.
- The callback is still executed and the function returns the return value of the callback.
+ /**
+ Executes a delete by query request using the current query.
+
@member ejs.Request
- @param {Function} fnCallBack A callback function that handles the search response.
- @returns {void} Returns the value of the callback when executing on the server.
+ @param {Function} successcb A callback function that handles the response.
+ @param {Function} errorcb A callback function that handles errors.
+ @returns {Object} Returns a client specific object.
*/
- doSearch: function (fnCallBack) {
- var
- queryData = JSON.stringify(query),
- searchUrl = '';
+ doDeleteByQuery: function (successcb, errorcb) {
+ var queryData = JSON.stringify(query.query);
// make sure the user has set a client
if (ejs.client == null) {
throw new Error("No Client Set");
}
-
- // generate the search url
- if (indices.length > 0) {
- searchUrl = searchUrl + '/' + indices.join();
- }
+
+ return ejs.client.del(getRestPath('_query'), queryData, successcb, errorcb);
+ },
- if (types.length > 0) {
- searchUrl = searchUrl + '/' + types.join();
+ /**
+ Executes a count request using the current query.
+
+ @member ejs.Request
+ @param {Function} successcb A callback function that handles the count response.
+ @param {Function} errorcb A callback function that handles errors.
+ @returns {Object} Returns a client specific object.
+ */
+ doCount: function (successcb, errorcb) {
+ var queryData = JSON.stringify(query.query);
+
+ // make sure the user has set a client
+ if (ejs.client == null) {
+ throw new Error("No Client Set");
}
- searchUrl = searchUrl + '/_search';
-
- if (routing !== '') {
- searchUrl = searchUrl + '?routing=' + encodeURIComponent(routing);
- }
+ return ejs.client.post(getRestPath('_count'), queryData, successcb, errorcb);
+ },
+
+ /**
+ Executes the search.
- return ejs.client.post(searchUrl, queryData, fnCallBack);
+ @member ejs.Request
+ @param {Function} successcb A callback function that handles the search response.
+ @param {Function} errorcb A callback function that handles errors.
+ @returns {Object} Returns a client specific object.
+ */
+ doSearch: function (successcb, errorcb) {
+ var queryData = JSON.stringify(query);
+
+ // make sure the user has set a client
+ if (ejs.client == null) {
+ throw new Error("No Client Set");
+ }
+
+ return ejs.client.post(getRestPath('_search'), queryData, successcb, errorcb);
}
};
};
@@ -17461,6 +18478,23 @@
return this;
},
+ /**
+ If execeptions thrown from the script should be ignored or not.
+ Default: false
+
+ @member ejs.ScriptField
+ @param {Boolean} trueFalse if execptions should be ignored
+ @returns {Object} returns this so that calls can be chained.
+ */
+ ignoreFailure: function (trueFalse) {
+ if (trueFalse == null) {
+ return script[fieldName].ignore_failure;
+ }
+
+ script[fieldName].ignore_failure = trueFalse;
+ return this;
+ },
+
/**
Allows you to serialize this object into a JSON encoded string.
@@ -17926,8 +18960,10 @@
/**
Sets the script sort type. Valid values are:
- string - script return value is sorted as a string
- number - script return value is sorted as a number
+
+ string - script return value is sorted as a string
+ number - script return value is sorted as a number
+
Valid during sort types: script
@@ -17947,7 +18983,78 @@
return this;
},
-
+
+ /**
+ Sets the sort mode. Valid values are:
+
+
+ min - sort by lowest value
+ max - sort by highest value
+ sum - sort by the sum of all values
+ avg - sort by the average of all values
+
+
+ Valid during sort types: field
+
+ @since elasticsearch 0.90
+ @member ejs.Sort
+ @param {String} m The sort mode. Either min, max, sum, or avg.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ mode: function (m) {
+ if (m == null) {
+ return sort[key].mode;
+ }
+
+ m = m.toLowerCase();
+ if (m === 'min' || m === 'max' || m === 'sum' || m === 'avg') {
+ sort[key].mode = m;
+ }
+
+ return this;
+ },
+
+ /**
+ Sets the path of the nested object.
+
+ Valid during sort types: field
+
+ @since elasticsearch 0.90
+ @member ejs.Sort
+ @param {String} path The nested path value.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ nestedPath: function (path) {
+ if (path == null) {
+ return sort[key].nested_path;
+ }
+
+ sort[key].nested_path = path;
+ return this;
+ },
+
+ /**
+ Allows you to set a filter that nested objects must match
+ in order to be considered during sorting.
+
+ @since elasticsearch 0.90
+ @member ejs.Sort
+ @param {Object} oFilter A valid Filter object.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ nestedFilter: function (oFilter) {
+ if (oFilter == null) {
+ return sort[key].nested_filter;
+ }
+
+ if (!isFilter(oFilter)) {
+ throw new TypeError('Argument must be a Filter');
+ }
+
+ sort[key].nested_filter = oFilter._self();
+ return this;
+ },
+
/**
Allows you to serialize this object into a JSON encoded string.
@@ -17981,6 +19088,902 @@
};
};
+ /**
+ @class
+ DirectGenerator is a candidate generator for PhraseSuggester.
+ It generates terms based on edit distance and operators much like the
+ TermSuggester.
+
+ @name ejs.DirectGenerator
+
+ @since elasticsearch 0.90
+
+ @desc
+ A candidate generator that generates terms based on edit distance.
+
+ @borrows ejs.DirectSettingsMixin.accuracy as accuracy
+ @borrows ejs.DirectSettingsMixin.suggestMode as suggestMode
+ @borrows ejs.DirectSettingsMixin.sort as sort
+ @borrows ejs.DirectSettingsMixin.stringDistance as stringDistance
+ @borrows ejs.DirectSettingsMixin.maxEdits as maxEdits
+ @borrows ejs.DirectSettingsMixin.maxInspections as maxInspections
+ @borrows ejs.DirectSettingsMixin.maxTermFreq as maxTermFreq
+ @borrows ejs.DirectSettingsMixin.prefixLength as prefixLength
+ @borrows ejs.DirectSettingsMixin.minWordLen as minWordLen
+ @borrows ejs.DirectSettingsMixin.minDocFreq as minDocFreq
+ */
+ ejs.DirectGenerator = function () {
+
+
+ var
+
+ // common suggester options used in this generator
+ _common = ejs.DirectSettingsMixin(),
+
+ /**
+ The internal generator object.
+ @member ejs.DirectGenerator
+ @property {Object} suggest
+ */
+ generator = _common._self();
+
+ return extend(_common, {
+
+ /**
+ Sets an analyzer that is applied to each of the tokens passed to
+ this generator. The analyzer is applied to the original tokens,
+ not the generated tokens.
+
+ @member ejs.DirectGenerator
+ @param {String} analyzer A valid analyzer name.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ preFilter: function (analyzer) {
+ if (analyzer == null) {
+ return generator.pre_filter;
+ }
+
+ generator.pre_filter = analyzer;
+ return this;
+ },
+
+ /**
+ Sets an analyzer that is applied to each of the generated tokens
+ before they are passed to the actual phrase scorer.
+
+ @member ejs.DirectGenerator
+ @param {String} analyzer A valid analyzer name.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ postFilter: function (analyzer) {
+ if (analyzer == null) {
+ return generator.post_filter;
+ }
+
+ generator.post_filter = analyzer;
+ return this;
+ },
+
+ /**
+ Sets the field used to generate suggestions from.
+
+ @member ejs.DirectGenerator
+ @param {String} field A valid field name.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ field: function (field) {
+ if (field == null) {
+ return generator.field;
+ }
+
+ generator.field = field;
+ return this;
+ },
+
+ /**
+ Sets the number of suggestions returned for each token.
+
+ @member ejs.DirectGenerator
+ @param {Integer} s A positive integer value.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ size: function (s) {
+ if (s == null) {
+ return generator.size;
+ }
+
+ generator.size = s;
+ return this;
+ },
+
+ /**
+ Allows you to serialize this object into a JSON encoded string.
+
+ @member ejs.DirectGenerator
+ @returns {String} returns this object as a serialized JSON string.
+ */
+ toString: function () {
+ return JSON.stringify(generator);
+ },
+
+ /**
+ The type of ejs object. For internal use only.
+
+ @member ejs.DirectGenerator
+ @returns {String} the type of object
+ */
+ _type: function () {
+ return 'generator';
+ },
+
+ /**
+ Retrieves the internal generator object. This is typically used by
+ internal API functions so use with caution.
+
+ @member ejs.DirectGenerator
+ @returns {String} returns this object's internal generator property.
+ */
+ _self: function () {
+ return generator;
+ }
+ });
+ };
+
+ /**
+ @mixin
+ The DirectSettingsMixin provides support for common options used across
+ various Suggester implementations. This object should not be
+ used directly.
+
+ @name ejs.DirectSettingsMixin
+ */
+ ejs.DirectSettingsMixin = function () {
+
+ /**
+ The internal settings object.
+ @member ejs.DirectSettingsMixin
+ @property {Object} settings
+ */
+ var settings = {};
+
+ return {
+
+ /**
+ Sets the accuracy. How similar the suggested terms at least
+ need to be compared to the original suggest text.
+
+ @member ejs.DirectSettingsMixin
+ @param {Double} a A positive double value between 0 and 1.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ accuracy: function (a) {
+ if (a == null) {
+ return settings.accuracy;
+ }
+
+ settings.accuracy = a;
+ return this;
+ },
+
+ /**
+ Sets the suggest mode. Valid values are:
+
+
+ missing - Only suggest terms in the suggest text that aren't in the index
+ popular - Only suggest suggestions that occur in more docs then the original suggest text term
+ always - Suggest any matching suggestions based on terms in the suggest text
+
+
+ @member ejs.DirectSettingsMixin
+ @param {String} m The mode of missing, popular, or always.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ suggestMode: function (m) {
+ if (m == null) {
+ return settings.suggest_mode;
+ }
+
+ m = m.toLowerCase();
+ if (m === 'missing' || m === 'popular' || m === 'always') {
+ settings.suggest_mode = m;
+ }
+
+ return this;
+ },
+
+ /**
+ Sets the sort mode. Valid values are:
+
+
+ score - Sort by score first, then document frequency, and then the term itself
+ frequency - Sort by document frequency first, then simlarity score and then the term itself
+
+
+ @member ejs.DirectSettingsMixin
+ @param {String} s The score type of score or frequency.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ sort: function (s) {
+ if (s == null) {
+ return settings.sort;
+ }
+
+ s = s.toLowerCase();
+ if (s === 'score' || s === 'frequency') {
+ settings.sort = s;
+ }
+
+ return this;
+ },
+
+ /**
+ Sets what string distance implementation to use for comparing
+ how similar suggested terms are. Valid values are:
+
+
+ internal - based on damerau_levenshtein but but highly optimized for comparing string distance for terms inside the index
+ damerau_levenshtein - String distance algorithm based on Damerau-Levenshtein algorithm
+ levenstein - String distance algorithm based on Levenstein edit distance algorithm
+ jarowinkler - String distance algorithm based on Jaro-Winkler algorithm
+ ngram - String distance algorithm based on character n-grams
+
+
+ @member ejs.DirectSettingsMixin
+ @param {String} s The string distance algorithm name.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ stringDistance: function (s) {
+ if (s == null) {
+ return settings.string_distance;
+ }
+
+ s = s.toLowerCase();
+ if (s === 'internal' || s === 'damerau_levenshtein' ||
+ s === 'levenstein' || s === 'jarowinkler' || s === 'ngram') {
+ settings.string_distance = s;
+ }
+
+ return this;
+ },
+
+ /**
+ Sets the maximum edit distance candidate suggestions can have
+ in order to be considered as a suggestion.
+
+ @member ejs.DirectSettingsMixin
+ @param {Integer} max An integer value greater than 0.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ maxEdits: function (max) {
+ if (max == null) {
+ return settings.max_edits;
+ }
+
+ settings.max_edits = max;
+ return this;
+ },
+
+ /**
+ The factor that is used to multiply with the size in order
+ to inspect more candidate suggestions.
+
+ @member ejs.DirectSettingsMixin
+ @param {Integer} max A positive integer value.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ maxInspections: function (max) {
+ if (max == null) {
+ return settings.max_inspections;
+ }
+
+ settings.max_inspections = max;
+ return this;
+ },
+
+ /**
+ Sets a maximum threshold in number of documents a suggest text
+ token can exist in order to be corrected.
+
+ @member ejs.DirectSettingsMixin
+ @param {Double} max A positive double value.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ maxTermFreq: function (max) {
+ if (max == null) {
+ return settings.max_term_freq;
+ }
+
+ settings.max_term_freq = max;
+ return this;
+ },
+
+ /**
+ Sets the number of minimal prefix characters that must match in
+ order be a candidate suggestion.
+
+ @member ejs.DirectSettingsMixin
+ @param {Integer} len A positive integer value.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ prefixLength: function (len) {
+ if (len == null) {
+ return settings.prefix_length;
+ }
+
+ settings.prefix_length = len;
+ return this;
+ },
+
+ /**
+ Sets the minimum length a suggest text term must have in order
+ to be corrected.
+
+ @member ejs.DirectSettingsMixin
+ @param {Integer} len A positive integer value.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ minWordLen: function (len) {
+ if (len == null) {
+ return settings.min_word_len;
+ }
+
+ settings.min_word_len = len;
+ return this;
+ },
+
+ /**
+ Sets a minimal threshold of the number of documents a suggested
+ term should appear in.
+
+ @member ejs.DirectSettingsMixin
+ @param {Double} min A positive double value.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ minDocFreq: function (min) {
+ if (min == null) {
+ return settings.min_doc_freq;
+ }
+
+ settings.min_doc_freq = min;
+ return this;
+ },
+
+ /**
+ Retrieves the internal settings object. This is typically used by
+ internal API functions so use with caution.
+
+ @member ejs.DirectSettingsMixin
+ @returns {String} returns this object's internal settings property.
+ */
+ _self: function () {
+ return settings;
+ }
+ };
+ };
+
+ /**
+ @class
+ PhraseSuggester extends the PhraseSuggester and suggests
+ entire corrected phrases instead of individual tokens. The individual
+ phrase suggestions are weighted based on ngram-langugage models. In practice
+ it will be able to make better decision about which tokens to pick based on
+ co-occurence and frequencies.
+
+ @name ejs.PhraseSuggester
+
+ @since elasticsearch 0.90
+
+ @desc
+ A suggester that suggests entire corrected phrases.
+
+ @param {String} name The name which be used to refer to this suggester.
+ */
+ ejs.PhraseSuggester = function (name) {
+
+ /**
+ The internal suggest object.
+ @member ejs.PhraseSuggester
+ @property {Object} suggest
+ */
+ var suggest = {};
+ suggest[name] = {phrase: {}};
+
+ return {
+
+ /**
+ Sets the text to get suggestions for. If not set, the global
+ suggestion text will be used.
+
+ @member ejs.PhraseSuggester
+ @param {String} txt A string to get suggestions for.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ text: function (txt) {
+ if (txt == null) {
+ return suggest[name].text;
+ }
+
+ suggest[name].text = txt;
+ return this;
+ },
+
+ /**
+ Sets analyzer used to analyze the suggest text.
+
+ @member ejs.PhraseSuggester
+ @param {String} analyzer A valid analyzer name.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ analyzer: function (analyzer) {
+ if (analyzer == null) {
+ return suggest[name].phrase.analyzer;
+ }
+
+ suggest[name].phrase.analyzer = analyzer;
+ return this;
+ },
+
+ /**
+ Sets the field used to generate suggestions from.
+
+ @member ejs.PhraseSuggester
+ @param {String} field A valid field name.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ field: function (field) {
+ if (field == null) {
+ return suggest[name].phrase.field;
+ }
+
+ suggest[name].phrase.field = field;
+ return this;
+ },
+
+ /**
+ Sets the number of suggestions returned for each token.
+
+ @member ejs.PhraseSuggester
+ @param {Integer} s A positive integer value.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ size: function (s) {
+ if (s == null) {
+ return suggest[name].phrase.size;
+ }
+
+ suggest[name].phrase.size = s;
+ return this;
+ },
+
+ /**
+ Sets the maximum number of suggestions to be retrieved from
+ each individual shard.
+
+ @member ejs.PhraseSuggester
+ @param {Integer} s A positive integer value.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ shardSize: function (s) {
+ if (s == null) {
+ return suggest[name].phrase.shard_size;
+ }
+
+ suggest[name].phrase.shard_size = s;
+ return this;
+ },
+
+ /**
+ Sets the likelihood of a term being a misspelled even if the
+ term exists in the dictionary. The default it 0.95 corresponding
+ to 5% or the real words are misspelled.
+
+ @member ejs.PhraseSuggester
+ @param {Double} l A positive double value greater than 0.0.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ realWorldErrorLikelihood: function (l) {
+ if (l == null) {
+ return suggest[name].phrase.real_world_error_likelihood;
+ }
+
+ suggest[name].phrase.real_world_error_likelihood = l;
+ return this;
+ },
+
+ /**
+ Sets the confidence level defines a factor applied to the input
+ phrases score which is used as a threshold for other suggest
+ candidates. Only candidates that score higher than the threshold
+ will be included in the result.
+
+ @member ejs.PhraseSuggester
+ @param {Double} c A positive double value.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ confidence: function (c) {
+ if (c == null) {
+ return suggest[name].phrase.confidence;
+ }
+
+ suggest[name].phrase.confidence = c;
+ return this;
+ },
+
+ /**
+ Sets the separator that is used to separate terms in the bigram
+ field. If not set the whitespce character is used as a
+ separator.
+
+ @member ejs.PhraseSuggester
+ @param {String} sep A string separator.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ separator: function (sep) {
+ if (sep == null) {
+ return suggest[name].phrase.separator;
+ }
+
+ suggest[name].phrase.separator = sep;
+ return this;
+ },
+
+ /**
+ Sets the maximum percentage of the terms that at most
+ considered to be misspellings in order to form a correction.
+
+ @member ejs.PhraseSuggester
+ @param {Double} c A positive double value greater between 0 and 1.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ maxErrors: function (max) {
+ if (max == null) {
+ return suggest[name].phrase.max_errors;
+ }
+
+ suggest[name].phrase.max_errors = max;
+ return this;
+ },
+
+ /**
+ Sets the max size of the n-grams (shingles) in the field. If
+ the field doesn't contain n-grams (shingles) this should be
+ omitted or set to 1.
+
+ @member ejs.PhraseSuggester
+ @param {Integer} s A positive integer value.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ gramSize: function (s) {
+ if (s == null) {
+ return suggest[name].phrase.gram_size;
+ }
+
+ suggest[name].phrase.gram_size = s;
+ return this;
+ },
+
+ /**
+ Forces the use of unigrams.
+
+ @member ejs.PhraseSuggester
+ @param {Boolean} trueFalse True to force unigrams, false otherwise.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ forceUnigrams: function (trueFalse) {
+ if (trueFalse == null) {
+ return suggest[name].phrase.force_unigrams;
+ }
+
+ suggest[name].phrase.force_unigrams = trueFalse;
+ return this;
+ },
+
+ /**
+ A smoothing model that takes the weighted mean of the unigrams,
+ bigrams and trigrams based on user supplied weights (lambdas). The
+ sum of tl, bl, and ul must equal 1.
+
+ @member ejs.PhraseSuggester
+ @param {Double} tl A positive double value used for trigram weight.
+ @param {Double} bl A positive double value used for bigram weight.
+ @param {Double} ul A positive double value used for unigram weight.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ linearSmoothing: function (tl, bl, ul) {
+ if (arguments.length === 0) {
+ return suggest[name].phrase.smoothing;
+ }
+
+ suggest[name].phrase.smoothing = {
+ linear: {
+ trigram_lambda: tl,
+ bigram_lambda: bl,
+ unigram_lambda: ul
+ }
+ };
+
+ return this;
+ },
+
+ /**
+ A smoothing model that uses an additive smoothing model where a
+ constant (typically 1.0 or smaller) is added to all counts to
+ balance weights, The default alpha is 0.5.
+
+ @member ejs.PhraseSuggester
+ @param {Double} alpha A double value.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ laplaceSmoothing: function (alpha) {
+ if (alpha == null) {
+ return suggest[name].phrase.smoothing;
+ }
+
+ suggest[name].phrase.smoothing = {
+ laplace: {
+ alpha: alpha
+ }
+ };
+
+ return this;
+ },
+
+ /**
+ A simple backoff model that backs off to lower order n-gram
+ models if the higher order count is 0 and discounts the lower
+ order n-gram model by a constant factor. The default discount is
+ 0.4.
+
+ @member ejs.PhraseSuggester
+ @param {Double} discount A double value.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ stupidBackoffSmoothing: function (discount) {
+ if (discount == null) {
+ return suggest[name].phrase.smoothing;
+ }
+
+ suggest[name].phrase.smoothing = {
+ stupid_backoff: {
+ discount: discount
+ }
+ };
+
+ return this;
+ },
+
+ /**
+ Adds a direct generator. If passed a single Generator
+ it is added to the list of existing generators. If passed an
+ array of Generators, they replace all existing generators.
+
+ @member ejs.PhraseSuggester
+ @param {Generator || Array} oGenerator A valid Generator or
+ array of Generator objects.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ directGenerator: function (oGenerator) {
+ var i, len;
+
+ if (suggest[name].phrase.direct_generator == null) {
+ suggest[name].phrase.direct_generator = [];
+ }
+
+ if (oGenerator == null) {
+ return suggest[name].phrase.direct_generator;
+ }
+
+ if (isGenerator(oGenerator)) {
+ suggest[name].phrase.direct_generator.push(oGenerator._self());
+ } else if (isArray(oGenerator)) {
+ suggest[name].phrase.direct_generator = [];
+ for (i = 0, len = oGenerator.length; i < len; i++) {
+ if (!isGenerator(oGenerator[i])) {
+ throw new TypeError('Argument must be an array of Generators');
+ }
+
+ suggest[name].phrase.direct_generator.push(oGenerator[i]._self());
+ }
+ } else {
+ throw new TypeError('Argument must be a Generator or array of Generators');
+ }
+
+ return this;
+ },
+
+ /**
+ Allows you to serialize this object into a JSON encoded string.
+
+ @member ejs.PhraseSuggester
+ @returns {String} returns this object as a serialized JSON string.
+ */
+ toString: function () {
+ return JSON.stringify(suggest);
+ },
+
+ /**
+ The type of ejs object. For internal use only.
+
+ @member ejs.PhraseSuggester
+ @returns {String} the type of object
+ */
+ _type: function () {
+ return 'suggest';
+ },
+
+ /**
+ Retrieves the internal suggest object. This is typically used by
+ internal API functions so use with caution.
+
+ @member ejs.PhraseSuggester
+ @returns {String} returns this object's internal suggest property.
+ */
+ _self: function () {
+ return suggest;
+ }
+ };
+ };
+
+ /**
+ @class
+ TermSuggester suggests terms based on edit distance. The provided suggest
+ text is analyzed before terms are suggested. The suggested terms are
+ provided per analyzed suggest text token. This leaves the suggest-selection
+ to the API consumer. For a higher level suggester, please use the
+ PhraseSuggester.
+
+ @name ejs.TermSuggester
+
+ @since elasticsearch 0.90
+
+ @desc
+ A suggester that suggests terms based on edit distance.
+
+ @borrows ejs.DirectSettingsMixin.accuracy as accuracy
+ @borrows ejs.DirectSettingsMixin.suggestMode as suggestMode
+ @borrows ejs.DirectSettingsMixin.sort as sort
+ @borrows ejs.DirectSettingsMixin.stringDistance as stringDistance
+ @borrows ejs.DirectSettingsMixin.maxEdits as maxEdits
+ @borrows ejs.DirectSettingsMixin.maxInspections as maxInspections
+ @borrows ejs.DirectSettingsMixin.maxTermFreq as maxTermFreq
+ @borrows ejs.DirectSettingsMixin.prefixLength as prefixLength
+ @borrows ejs.DirectSettingsMixin.minWordLen as minWordLen
+ @borrows ejs.DirectSettingsMixin.minDocFreq as minDocFreq
+
+ @param {String} name The name which be used to refer to this suggester.
+ */
+ ejs.TermSuggester = function (name) {
+
+ /**
+ The internal suggest object.
+ @member ejs.TermSuggester
+ @property {Object} suggest
+ */
+ var suggest = {},
+
+ // common suggester options
+ _common = ejs.DirectSettingsMixin();
+
+ // setup correct term suggestor format
+ suggest[name] = {term: _common._self()};
+
+ return extend(_common, {
+
+ /**
+ Sets the text to get suggestions for. If not set, the global
+ suggestion text will be used.
+
+ @member ejs.TermSuggester
+ @param {String} txt A string to get suggestions for.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ text: function (txt) {
+ if (txt == null) {
+ return suggest[name].text;
+ }
+
+ suggest[name].text = txt;
+ return this;
+ },
+
+ /**
+ Sets analyzer used to analyze the suggest text.
+
+ @member ejs.TermSuggester
+ @param {String} analyzer A valid analyzer name.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ analyzer: function (analyzer) {
+ if (analyzer == null) {
+ return suggest[name].term.analyzer;
+ }
+
+ suggest[name].term.analyzer = analyzer;
+ return this;
+ },
+
+ /**
+ Sets the field used to generate suggestions from.
+
+ @member ejs.TermSuggester
+ @param {String} field A valid field name.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ field: function (field) {
+ if (field == null) {
+ return suggest[name].term.field;
+ }
+
+ suggest[name].term.field = field;
+ return this;
+ },
+
+ /**
+ Sets the number of suggestions returned for each token.
+
+ @member ejs.TermSuggester
+ @param {Integer} s A positive integer value.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ size: function (s) {
+ if (s == null) {
+ return suggest[name].term.size;
+ }
+
+ suggest[name].term.size = s;
+ return this;
+ },
+
+ /**
+ Sets the maximum number of suggestions to be retrieved from
+ each individual shard.
+
+ @member ejs.TermSuggester
+ @param {Integer} s A positive integer value.
+ @returns {Object} returns this so that calls can be chained.
+ */
+ shardSize: function (s) {
+ if (s == null) {
+ return suggest[name].term.shard_size;
+ }
+
+ suggest[name].term.shard_size = s;
+ return this;
+ },
+
+ /**
+ Allows you to serialize this object into a JSON encoded string.
+
+ @member ejs.TermSuggester
+ @returns {String} returns this object as a serialized JSON string.
+ */
+ toString: function () {
+ return JSON.stringify(suggest);
+ },
+
+ /**
+ The type of ejs object. For internal use only.
+
+ @member ejs.TermSuggester
+ @returns {String} the type of object
+ */
+ _type: function () {
+ return 'suggest';
+ },
+
+ /**
+ Retrieves the internal suggest object. This is typically used by
+ internal API functions so use with caution.
+
+ @member ejs.TermSuggester
+ @returns {String} returns this object's internal suggest property.
+ */
+ _self: function () {
+ return suggest;
+ }
+ });
+ };
+
// run in noConflict mode
ejs.noConflict = function () {
root.ejs = _ejs;
diff --git a/common/lib/elastic.min.js b/common/lib/elastic.min.js
index b63fb6de718..586930115e7 100644
--- a/common/lib/elastic.min.js
+++ b/common/lib/elastic.min.js
@@ -1,4 +1,4 @@
-/*! elastic.js - v1.0.0 - 2013-01-15
+/*! elastic.js - v1.0.0 - 2013-04-04
* https://github.com/fullscale/elastic.js
* Copyright (c) 2013 FullScale Labs, LLC; Licensed MIT */
-(function(){"use strict";var e=this,t=e&&e.ejs,n=Array.prototype,r=Object.prototype,i=n.slice,s=r.toString,o=r.hasOwnProperty,u=n.forEach,a=Array.isArray,f={},l,c,h,p,d,v,m,g,y,b,w,E,S,x,T,N,C,k,L;typeof exports!="undefined"?L=exports:L=e.ejs={},l=function(e,t){return o.call(e,t)},c=function(e,t,n){if(e==null)return;if(u&&e.forEach===u)e.forEach(t,n);else if(e.length===+e.length){for(var r=0,i=e.length;r0&&(n=["_all"]),e.routing!=null?i=e.routing:i="",{sort:function(){var e,n;l(t,"sort")||(t.sort=[]);if(arguments.length===0)return t.sort;if(arguments.length===1){var r=arguments[0];if(v(r))t.sort.push(r);else if(C(r))t.sort.push(r._self());else{if(!p(r))throw new TypeError("Argument must be string, Sort, or array");t.sort=[];for(e=0,n=r.length;e0&&(n=["_all"]),this},types:function(e){if(e==null)return r;if(v(e))r=[e];else{if(!p(e))throw new TypeError("Argument must be a string or array");r=e}return n.length===0&&r.length>0&&(n=["_all"]),this},facet:function(e){if(e==null)return t.facets;t.facets==null&&(t.facets={});if(!E(e))throw new TypeError("Argument must be a Facet");return h(t.facets,e._self()),this},filter:function(e){if(e==null)return t.filter;if(!w(e))throw new TypeError("Argument must be a Filter");return t.filter=e._self(),this},highlight:function(e){if(e==null)return t.highlight;if(!k(e))throw new TypeError("Argument must be a Highlight object");return t.highlight=e._self(),this},scriptField:function(e){if(e==null)return t.script_fields;t.script_fields==null&&(t.script_fields={});if(!S(e))throw new TypeError("Argument must be a ScriptField");return h(t.script_fields,e._self()),this},preference:function(e){return e==null?t.preference:(t.preference=e,this)},indexBoost:function(e,n){return t.indices_boost==null&&(t.indices_boost={}),arguments.length===0?t.indices_boost:(t.indices_boost[e]=n,this)},explain:function(e){return e==null?t.explain:(t.explain=e,this)},version:function(e){return e==null?t.version:(t.version=e,this)},minScore:function(e){return e==null?t.min_score:(t.min_score=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"request"},_self:function(){return t},doSearch:function(e){var s=JSON.stringify(t),o="";if(L.client==null)throw new Error("No Client Set");return n.length>0&&(o=o+"/"+n.join()),r.length>0&&(o=o+"/"+r.join()),o+="/_search",i!==""&&(o=o+"?routing="+encodeURIComponent(i)),L.client.post(o,s,e)}}},L.ScriptField=function(e){var t={};return t[e]={},{lang:function(n){return n==null?t[e].lang:(t[e].lang=n,this)},script:function(n){return n==null?t[e].script:(t[e].script=n,this)},params:function(n){return n==null?t[e].params:(t[e].params=n,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"script field"},_self:function(){return t}}},L.Shape=function(e,t){var n={},r=function(e){var t=!1;if(e==="point"||e==="linestring"||e==="polygon"||e==="multipoint"||e==="envelope"||e==="multipolygon")t=!0;return t};return e=e.toLowerCase(),r(e)&&(n.type=e,n.coordinates=t),{type:function(e){return e==null?n.type:(e=e.toLowerCase(),r(e)&&(n.type=e),this)},coordinates:function(e){return e==null?n.coordinates:(n.coordinates=e,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"shape"},_self:function(){return n}}},L.Sort=function(e){e==null&&(e="_score");var t={},n=e,r="_geo_distance",i="_script";return t[n]={},{field:function(r){var i=t[n];return r==null?e:(delete t[n],e=r,n=r,t[n]=i,this)},geoDistance:function(i){var s=t[n];if(i==null)return t[n][e];if(!x(i))throw new TypeError("Argument must be a GeoPoint");return delete t[n],n=r,t[n]=s,t[n][e]=i._self(),this},script:function(e){var r=t[n];return e==null?t[n].script:(delete t[n],n=i,t[n]=r,t[n].script=e,this)},order:function(e){if(e==null)return t[n].order;e=e.toLowerCase();if(e==="asc"||e==="desc")t[n].order=e;return this},asc:function(){return t[n].order="asc",this},desc:function(){return t[n].order="desc",this},reverse:function(e){return e==null?t[n].reverse:(t[n].reverse=e,this)},missing:function(e){return e==null?t[n].missing:(t[n].missing=e,this)},ignoreUnmapped:function(e){return e==null?t[n].ignore_unmapped:(t[n].ignore_unmapped=e,this)},unit:function(e){if(e==null)return t[n].unit;e=e.toLowerCase();if(e==="mi"||e==="km")t[n].unit=e;return this},normalize:function(e){return e==null?t[n].normalize:(t[n].normalize=e,this)},distanceType:function(e){if(e==null)return t[n].distance_type;e=e.toLowerCase();if(e==="arc"||e==="plane")t[n].distance_type=e;return this},params:function(e){return e==null?t[n].params:(t[n].params=e,this)},lang:function(e){return e==null?t[n].lang:(t[n].lang=e,this)},type:function(e){if(e==null)return t[n].type;e=e.toLowerCase();if(e==="string"||e==="number")t[n].type=e;return this},toString:function(){return JSON.stringify(t)},_type:function(){return"sort"},_self:function(){return t}}},L.noConflict=function(){return e.ejs=t,this}}).call(this);
\ No newline at end of file
+(function(){"use strict";var e=this,t=e&&e.ejs,n=Array.prototype,r=Object.prototype,i=n.slice,s=r.toString,o=r.hasOwnProperty,u=n.forEach,a=Array.isArray,f={},l,c,h,p,d,v,m,g,y,b,w,E,S,x,T,N,C,k,L,A,O;typeof exports!="undefined"?O=exports:O=e.ejs={},l=function(e,t){return o.call(e,t)},c=function(e,t,n){if(e==null)return;if(u&&e.forEach===u)e.forEach(t,n);else if(e.length===+e.length){for(var r=0,i=e.length;r0&&(t=t+"/"+n.join()),r.length>0&&(t=t+"/"+r.join()),e.length>0&&e[0]!=="/"&&(t+="/"),t+=e;for(var o in i){if(!l(i,o)||i[o]==="")continue;s.push(o+"="+encodeURIComponent(i[o]))}return s.length>0&&(t=t+"?"+s.join("&")),t};return t={},e=e||{},e.indices==null?n=[]:v(e.indices)?n=[e.indices]:n=e.indices,e.types==null?r=[]:v(e.types)?r=[e.types]:r=e.types,n.length===0&&r.length>0&&(n=["_all"]),e.routing!=null&&(i.routing=e.routing),{sort:function(){var e,n;l(t,"sort")||(t.sort=[]);if(arguments.length===0)return t.sort;if(arguments.length===1){var r=arguments[0];if(v(r))t.sort.push(r);else if(C(r))t.sort.push(r._self());else{if(!p(r))throw new TypeError("Argument must be string, Sort, or array");t.sort=[];for(e=0,n=r.length;e0&&(n=["_all"]),this},types:function(e){if(e==null)return r;if(v(e))r=[e];else{if(!p(e))throw new TypeError("Argument must be a string or array");r=e}return n.length===0&&r.length>0&&(n=["_all"]),this},facet:function(e){if(e==null)return t.facets;t.facets==null&&(t.facets={});if(!E(e))throw new TypeError("Argument must be a Facet");return h(t.facets,e._self()),this},filter:function(e){if(e==null)return t.filter;if(!w(e))throw new TypeError("Argument must be a Filter");return t.filter=e._self(),this},highlight:function(e){if(e==null)return t.highlight;if(!k(e))throw new TypeError("Argument must be a Highlight object");return t.highlight=e._self(),this},suggest:function(e){if(e==null)return t.suggest;t.suggest==null&&(t.suggest={});if(v(e))t.suggest.text=e;else{if(!L(e))throw new TypeError("Argument must be a string or Suggest object");h(t.suggest,e._self())}return this},scriptField:function(e){if(e==null)return t.script_fields;t.script_fields==null&&(t.script_fields={});if(!S(e))throw new TypeError("Argument must be a ScriptField");return h(t.script_fields,e._self()),this},preference:function(e){return e==null?i.preference:(i.preference=e,this)},ignoreIndices:function(e){if(e==null)return i.ignore_indices;e=e.toLowerCase();if(e==="none"||e==="missing")i.ignore_indices=e;return this},indexBoost:function(e,n){return t.indices_boost==null&&(t.indices_boost={}),arguments.length===0?t.indices_boost:(t.indices_boost[e]=n,this)},explain:function(e){return e==null?t.explain:(t.explain=e,this)},version:function(e){return e==null?t.version:(t.version=e,this)},minScore:function(e){return e==null?t.min_score:(t.min_score=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"request"},_self:function(){return t},doDeleteByQuery:function(e,n){var r=JSON.stringify(t.query);if(O.client==null)throw new Error("No Client Set");return O.client.del(s("_query"),r,e,n)},doCount:function(e,n){var r=JSON.stringify(t.query);if(O.client==null)throw new Error("No Client Set");return O.client.post(s("_count"),r,e,n)},doSearch:function(e,n){var r=JSON.stringify(t);if(O.client==null)throw new Error("No Client Set");return O.client.post(s("_search"),r,e,n)}}},O.ScriptField=function(e){var t={};return t[e]={},{lang:function(n){return n==null?t[e].lang:(t[e].lang=n,this)},script:function(n){return n==null?t[e].script:(t[e].script=n,this)},params:function(n){return n==null?t[e].params:(t[e].params=n,this)},ignoreFailure:function(n){return n==null?t[e].ignore_failure:(t[e].ignore_failure=n,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"script field"},_self:function(){return t}}},O.Shape=function(e,t){var n={},r=function(e){var t=!1;if(e==="point"||e==="linestring"||e==="polygon"||e==="multipoint"||e==="envelope"||e==="multipolygon")t=!0;return t};return e=e.toLowerCase(),r(e)&&(n.type=e,n.coordinates=t),{type:function(e){return e==null?n.type:(e=e.toLowerCase(),r(e)&&(n.type=e),this)},coordinates:function(e){return e==null?n.coordinates:(n.coordinates=e,this)},toString:function(){return JSON.stringify(n)},_type:function(){return"shape"},_self:function(){return n}}},O.Sort=function(e){e==null&&(e="_score");var t={},n=e,r="_geo_distance",i="_script";return t[n]={},{field:function(r){var i=t[n];return r==null?e:(delete t[n],e=r,n=r,t[n]=i,this)},geoDistance:function(i){var s=t[n];if(i==null)return t[n][e];if(!x(i))throw new TypeError("Argument must be a GeoPoint");return delete t[n],n=r,t[n]=s,t[n][e]=i._self(),this},script:function(e){var r=t[n];return e==null?t[n].script:(delete t[n],n=i,t[n]=r,t[n].script=e,this)},order:function(e){if(e==null)return t[n].order;e=e.toLowerCase();if(e==="asc"||e==="desc")t[n].order=e;return this},asc:function(){return t[n].order="asc",this},desc:function(){return t[n].order="desc",this},reverse:function(e){return e==null?t[n].reverse:(t[n].reverse=e,this)},missing:function(e){return e==null?t[n].missing:(t[n].missing=e,this)},ignoreUnmapped:function(e){return e==null?t[n].ignore_unmapped:(t[n].ignore_unmapped=e,this)},unit:function(e){if(e==null)return t[n].unit;e=e.toLowerCase();if(e==="mi"||e==="km")t[n].unit=e;return this},normalize:function(e){return e==null?t[n].normalize:(t[n].normalize=e,this)},distanceType:function(e){if(e==null)return t[n].distance_type;e=e.toLowerCase();if(e==="arc"||e==="plane")t[n].distance_type=e;return this},params:function(e){return e==null?t[n].params:(t[n].params=e,this)},lang:function(e){return e==null?t[n].lang:(t[n].lang=e,this)},type:function(e){if(e==null)return t[n].type;e=e.toLowerCase();if(e==="string"||e==="number")t[n].type=e;return this},mode:function(e){if(e==null)return t[n].mode;e=e.toLowerCase();if(e==="min"||e==="max"||e==="sum"||e==="avg")t[n].mode=e;return this},nestedPath:function(e){return e==null?t[n].nested_path:(t[n].nested_path=e,this)},nestedFilter:function(e){if(e==null)return t[n].nested_filter;if(!w(e))throw new TypeError("Argument must be a Filter");return t[n].nested_filter=e._self(),this},toString:function(){return JSON.stringify(t)},_type:function(){return"sort"},_self:function(){return t}}},O.DirectGenerator=function(){var e=O.DirectSettingsMixin(),t=e._self();return h(e,{preFilter:function(e){return e==null?t.pre_filter:(t.pre_filter=e,this)},postFilter:function(e){return e==null?t.post_filter:(t.post_filter=e,this)},field:function(e){return e==null?t.field:(t.field=e,this)},size:function(e){return e==null?t.size:(t.size=e,this)},toString:function(){return JSON.stringify(t)},_type:function(){return"generator"},_self:function(){return t}})},O.DirectSettingsMixin=function(){var e={};return{accuracy:function(t){return t==null?e.accuracy:(e.accuracy=t,this)},suggestMode:function(t){if(t==null)return e.suggest_mode;t=t.toLowerCase();if(t==="missing"||t==="popular"||t==="always")e.suggest_mode=t;return this},sort:function(t){if(t==null)return e.sort;t=t.toLowerCase();if(t==="score"||t==="frequency")e.sort=t;return this},stringDistance:function(t){if(t==null)return e.string_distance;t=t.toLowerCase();if(t==="internal"||t==="damerau_levenshtein"||t==="levenstein"||t==="jarowinkler"||t==="ngram")e.string_distance=t;return this},maxEdits:function(t){return t==null?e.max_edits:(e.max_edits=t,this)},maxInspections:function(t){return t==null?e.max_inspections:(e.max_inspections=t,this)},maxTermFreq:function(t){return t==null?e.max_term_freq:(e.max_term_freq=t,this)},prefixLength:function(t){return t==null?e.prefix_length:(e.prefix_length=t,this)},minWordLen:function(t){return t==null?e.min_word_len:(e.min_word_len=t,this)},minDocFreq:function(t){return t==null?e.min_doc_freq:(e.min_doc_freq=t,this)},_self:function(){return e}}},O.PhraseSuggester=function(e){var t={};return t[e]={phrase:{}},{text:function(n){return n==null?t[e].text:(t[e].text=n,this)},analyzer:function(n){return n==null?t[e].phrase.analyzer:(t[e].phrase.analyzer=n,this)},field:function(n){return n==null?t[e].phrase.field:(t[e].phrase.field=n,this)},size:function(n){return n==null?t[e].phrase.size:(t[e].phrase.size=n,this)},shardSize:function(n){return n==null?t[e].phrase.shard_size:(t[e].phrase.shard_size=n,this)},realWorldErrorLikelihood:function(n){return n==null?t[e].phrase.real_world_error_likelihood:(t[e].phrase.real_world_error_likelihood=n,this)},confidence:function(n){return n==null?t[e].phrase.confidence:(t[e].phrase.confidence=n,this)},separator:function(n){return n==null?t[e].phrase.separator:(t[e].phrase.separator=n,this)},maxErrors:function(n){return n==null?t[e].phrase.max_errors:(t[e].phrase.max_errors=n,this)},gramSize:function(n){return n==null?t[e].phrase.gram_size:(t[e].phrase.gram_size=n,this)},forceUnigrams:function(n){return n==null?t[e].phrase.force_unigrams:(t[e].phrase.force_unigrams=n,this)},linearSmoothing:function(n,r,i){return arguments.length===0?t[e].phrase.smoothing:(t[e].phrase.smoothing={linear:{trigram_lambda:n,bigram_lambda:r,unigram_lambda:i}},this)},laplaceSmoothing:function(n){return n==null?t[e].phrase.smoothing:(t[e].phrase.smoothing={laplace:{alpha:n}},this)},stupidBackoffSmoothing:function(n){return n==null?t[e].phrase.smoothing:(t[e].phrase.smoothing={stupid_backoff:{discount:n}},this)},directGenerator:function(n){var r,i;t[e].phrase.direct_generator==null&&(t[e].phrase.direct_generator=[]);if(n==null)return t[e].phrase.direct_generator;if(A(n))t[e].phrase.direct_generator.push(n._self());else{if(!p(n))throw new TypeError("Argument must be a Generator or array of Generators");t[e].phrase.direct_generator=[];for(r=0,i=n.length;r