[backend/es][xs] Prevent exception if ElasticSearch did not return a valid mapping

This commit is contained in:
amercader 2012-07-09 15:36:42 +01:00
parent aa4916dc20
commit a5e3ef7a72

View File

@ -166,6 +166,12 @@ this.recline.Backend.ElasticSearch = this.recline.Backend.ElasticSearch || {};
var es = new my.Wrapper(dataset.url, my.esOptions);
var dfd = $.Deferred();
es.mapping().done(function(schema) {
if (!schema){
dfd.reject({'message':'Elastic Search did not return a mapping'});
return;
}
// only one top level key in ES = the type so we can ignore it
var key = _.keys(schema)[0];
var fieldData = _.map(schema[key].properties, function(dict, fieldName) {