Skip to content

Commit

Permalink
add support for script fields
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-jones committed Jan 3, 2015
1 parent 63e3974 commit f54c832
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions es.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ function optionsFromQuery(query) {
}

var opts = {}


// FIXME: note that fields are not supported here

// from position
if (query.from) { opts["from"] = query.from }

Expand Down Expand Up @@ -250,6 +252,7 @@ function elasticSearchQuery(params) {
if (include_fields) {
options.fields ? qs['fields'] = options.fields : "";
options.partial_fields ? qs['partial_fields'] = options.partial_fields : "";
options.script_fields ? qs["script_fields"] = options.script_fields : "";
}

// paging (number of results, and start cursor)
Expand Down Expand Up @@ -368,7 +371,7 @@ function elasticSearchSuccess(callback) {
for (var item = 0; item < data.hits.hits.length; item++) {
var res = data.hits.hits[item]
if ("fields" in res) {
// partial fields are also included here - no special treatment
// partial_fields and script_fields are also included here - no special treatment
resultobj.records.push(res.fields)
} else {
resultobj.records.push(res._source)
Expand Down
5 changes: 5 additions & 0 deletions jquery.facetview2.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ function getUrlVars() {

// list of partial fields to be returned by the elasticsearch query. If omitted, full result set is returned
"partial_fields" : false, // or an array of partial fields

// list of script fields to be executed. Note that you should, in general, not pass actual scripts but
// references to stored scripts in the back-end ES. If not false, then an object corresponding to the
// ES script_fields structure
"script_fields" : false,

// number of results to display per page (i.e. to retrieve per query)
"page_size" : 10,
Expand Down

0 comments on commit f54c832

Please sign in to comment.