Skip to content

Commit

Permalink
Merge branch 'function_score_query_max_boost'
Browse files Browse the repository at this point in the history
Conflicts:
	dist/elastic.js
	dist/elastic.min.js
  • Loading branch information
phjardas committed Nov 19, 2014
2 parents b9c30da + d57b64d commit d299479
Show file tree
Hide file tree
Showing 5 changed files with 3,616 additions and 3,580 deletions.
382 changes: 199 additions & 183 deletions dist/elastic.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! elastic.js - v1.2.0 - 2014-10-17
/*! elastic.js - v1.2.0 - 2014-11-19
* https://github.com/fullscale/elastic.js
* Copyright (c) 2014 FullScale Labs, LLC; Licensed MIT */

Expand Down Expand Up @@ -9959,188 +9959,204 @@
});
};

/**
@class
<p>The function_score allows you to modify the score of documents that are
retrieved by a query. This can be useful if, for example, a score function is
computationally expensive and it is sufficient to compute the score on a
filtered set of documents.</p>

@name ejs.FunctionScoreQuery
@ejs query
@borrows ejs.QueryMixin.boost as boost
@borrows ejs.QueryMixin._type as _type
@borrows ejs.QueryMixin.toJSON as toJSON

@desc
<p>A query that allows you to modify the score of matching documents.</p>

*/
ejs.FunctionScoreQuery = function () {

var
_common = ejs.QueryMixin('function_score'),
query = _common.toJSON();

return extend(_common, {

/**
Set the source query.

@member ejs.FunctionScoreQuery
@param {Query} oQuery A valid <code>Query</code> object
@returns {Object} returns <code>this</code> so that calls can be chained.
*/
query: function (oQuery) {
if (oQuery == null) {
return query.function_score.query;
}

if (!isQuery(oQuery)) {
throw new TypeError('Argument must be a Query');
}

query.function_score.query = oQuery.toJSON();
return this;
},

/**
Set the source filter.

@member ejs.FunctionScoreQuery
@param {Filter} oFilter A valid <code>Filter</code> object
@returns {Object} returns <code>this</code> so that calls can be chained.
*/
filter: function (oFilter) {
if (oFilter == null) {
return query.function_score.filter;
}

if (!isFilter(oFilter)) {
throw new TypeError('Argument must be a Filter');
}

query.function_score.filter = oFilter.toJSON();
return this;
},

/**
Set the scoring mode which specifies how the computed scores are combined.
Valid values are: avg, max, min, sum, multiply, and first.

@member ejs.FunctionScoreQuery
@param {String} mode A scoring mode.
@returns {Object} returns <code>this</code> so that calls can be chained.
*/
scoreMode: function (mode) {
if (mode == null) {
return query.function_score.score_mode;
}

mode = mode.toLowerCase();
if (mode === 'avg' || mode === 'max' || mode === 'min' ||
mode === 'sum' || mode === 'multiply' || mode === 'first') {
query.function_score.score_mode = mode;
}

return this;
},

/**
Set the setermines how the new calculated score is combined with the
score from the original query. Valid values are: multiply, replace, sum,
avg, max, and min.

@member ejs.FunctionScoreQuery
@param {String} mode A boosting mode.
@returns {Object} returns <code>this</code> so that calls can be chained.
*/
boostMode: function (mode) {
if (mode == null) {
return query.function_score.boost_mode;
}

mode = mode.toLowerCase();
if (mode === 'multiply' || mode === 'replace' || mode === 'sum' ||
mode === 'avg' || mode === 'max' || mode === 'min') {
query.function_score.boost_mode = mode;
}

return this;
},

/**
Sets the boost value for all documents matching the query.

@member ejs.FunctionScoreQuery
@param {Float} boost A positive <code>float</code> value.
@returns {Object} returns <code>this</code> so that calls can be chained.
*/
boost: function (boost) {
if (boost == null) {
return query.function_score.boost;
}

query.function_score.boost = boost;
return this;
},

/**
Add a single score function to the list of existing functions.

@member ejs.FunctionScoreQuery
@param {ScoreFunction} func A valid <code>ScoreFunction</code> object.
@returns {Object} returns <code>this</code> so that calls can be chained.
*/
function: function (func) {
if (query.function_score.functions == null) {
query.function_score.functions = [];
}

if (func == null) {
return query.function_score.functions;
}

if (!isScoreFunction(func)) {
throw new TypeError('Argument must be a ScoreFunction');
}

query.function_score.functions.push(func.toJSON());
return this;
},

/**
Sets the score functions. Replaces any existing score functions.

@member ejs.FunctionScoreQuery
@param {ScoreFunction[]} funcs A array of <code>ScoreFunctions</code>.
@returns {Object} returns <code>this</code> so that calls can be chained.
*/
functions: function (funcs) {
var i, len;

if (funcs == null) {
return query.function_score.functions;
}

if (!isArray(funcs)) {
throw new TypeError('Argument must be an array of ScoreFunctions');
}

query.function_score.functions = [];
for (i = 0, len = funcs.length; i < len; i++) {
if (!isScoreFunction(funcs[i])) {
throw new TypeError('Argument must be an array of ScoreFunctions');
}

query.function_score.functions.push(funcs[i].toJSON());
}

return this;
}

});
};
/**
@class
<p>The function_score allows you to modify the score of documents that are
retrieved by a query. This can be useful if, for example, a score function is
computationally expensive and it is sufficient to compute the score on a
filtered set of documents.</p>

@name ejs.FunctionScoreQuery
@ejs query
@borrows ejs.QueryMixin.boost as boost
@borrows ejs.QueryMixin._type as _type
@borrows ejs.QueryMixin.toJSON as toJSON

@desc
<p>A query that allows you to modify the score of matching documents.</p>

*/
ejs.FunctionScoreQuery = function () {

var
_common = ejs.QueryMixin('function_score'),
query = _common.toJSON();

return extend(_common, {

/**
Set the source query.

@member ejs.FunctionScoreQuery
@param {Query} oQuery A valid <code>Query</code> object
@returns {Object} returns <code>this</code> so that calls can be chained.
*/
query: function (oQuery) {
if (oQuery == null) {
return query.function_score.query;
}

if (!isQuery(oQuery)) {
throw new TypeError('Argument must be a Query');
}

query.function_score.query = oQuery.toJSON();
return this;
},

/**
Set the source filter.

@member ejs.FunctionScoreQuery
@param {Filter} oFilter A valid <code>Filter</code> object
@returns {Object} returns <code>this</code> so that calls can be chained.
*/
filter: function (oFilter) {
if (oFilter == null) {
return query.function_score.filter;
}

if (!isFilter(oFilter)) {
throw new TypeError('Argument must be a Filter');
}

query.function_score.filter = oFilter.toJSON();
return this;
},

/**
Set the scoring mode which specifies how the computed scores are combined.
Valid values are: avg, max, min, sum, multiply, and first.

@member ejs.FunctionScoreQuery
@param {String} mode A scoring mode.
@returns {Object} returns <code>this</code> so that calls can be chained.
*/
scoreMode: function (mode) {
if (mode == null) {
return query.function_score.score_mode;
}

mode = mode.toLowerCase();
if (mode === 'avg' || mode === 'max' || mode === 'min' ||
mode === 'sum' || mode === 'multiply' || mode === 'first') {
query.function_score.score_mode = mode;
}

return this;
},

/**
Set the setermines how the new calculated score is combined with the
score from the original query. Valid values are: multiply, replace, sum,
avg, max, and min.

@member ejs.FunctionScoreQuery
@param {String} mode A boosting mode.
@returns {Object} returns <code>this</code> so that calls can be chained.
*/
boostMode: function (mode) {
if (mode == null) {
return query.function_score.boost_mode;
}

mode = mode.toLowerCase();
if (mode === 'multiply' || mode === 'replace' || mode === 'sum' ||
mode === 'avg' || mode === 'max' || mode === 'min') {
query.function_score.boost_mode = mode;
}

return this;
},

/**
Sets the boost value for all documents matching the query.

@member ejs.FunctionScoreQuery
@param {Float} boost A positive <code>float</code> value.
@returns {Object} returns <code>this</code> so that calls can be chained.
*/
boost: function (boost) {
if (boost == null) {
return query.function_score.boost;
}

query.function_score.boost = boost;
return this;
},

/**
Sets the maximum boost value.

@member ejs.FunctionScoreQuery
@param {Float} maxBoost A positive <code>float</code> value.
@returns {Object} returns <code>this</code> so that calls can be chained.
*/
maxBoost: function (maxBoost) {
if (maxBoost == null) {
return query.function_score.max_boost;
}

query.function_score.max_boost = maxBoost;
return this;
},

/**
Add a single score function to the list of existing functions.

@member ejs.FunctionScoreQuery
@param {ScoreFunction} func A valid <code>ScoreFunction</code> object.
@returns {Object} returns <code>this</code> so that calls can be chained.
*/
function: function (func) {
if (query.function_score.functions == null) {
query.function_score.functions = [];
}

if (func == null) {
return query.function_score.functions;
}

if (!isScoreFunction(func)) {
throw new TypeError('Argument must be a ScoreFunction');
}

query.function_score.functions.push(func.toJSON());
return this;
},

/**
Sets the score functions. Replaces any existing score functions.

@member ejs.FunctionScoreQuery
@param {ScoreFunction[]} funcs A array of <code>ScoreFunctions</code>.
@returns {Object} returns <code>this</code> so that calls can be chained.
*/
functions: function (funcs) {
var i, len;

if (funcs == null) {
return query.function_score.functions;
}

if (!isArray(funcs)) {
throw new TypeError('Argument must be an array of ScoreFunctions');
}

query.function_score.functions = [];
for (i = 0, len = funcs.length; i < len; i++) {
if (!isScoreFunction(funcs[i])) {
throw new TypeError('Argument must be an array of ScoreFunctions');
}

query.function_score.functions.push(funcs[i].toJSON());
}

return this;
}

});
};

/**
@class
Expand Down
8 changes: 4 additions & 4 deletions dist/elastic.min.js
100644 → 100755

Large diffs are not rendered by default.

Loading

0 comments on commit d299479

Please sign in to comment.