[#111,backend/elasticsearch][s]: geo distance filter now working - hurrah!.
This commit is contained in:
@@ -121,9 +121,9 @@ this.recline.Backend.ElasticSearch = this.recline.Backend.ElasticSearch || {};
|
|||||||
out[filter.type] = {}
|
out[filter.type] = {}
|
||||||
if (filter.type === 'term') {
|
if (filter.type === 'term') {
|
||||||
out.term[filter.field] = filter.term;
|
out.term[filter.field] = filter.term;
|
||||||
} else if (filter.type === 'geo_point') {
|
} else if (filter.type === 'geo_distance') {
|
||||||
out.geo_point[filter.field] = filter.point;
|
out.geo_distance[filter.field] = filter.point;
|
||||||
out.geo_point[filter.distance] = filter.distance;
|
out.geo_distance.distance = filter.distance;
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -49,6 +49,31 @@ test("queryNormalize", function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
deepEqual(out, exp);
|
deepEqual(out, exp);
|
||||||
|
|
||||||
|
var in_ = new recline.Model.Query();
|
||||||
|
in_.addFilter({
|
||||||
|
type: 'geo_distance',
|
||||||
|
field: 'xyz'
|
||||||
|
});
|
||||||
|
var out = backend._normalizeQuery(in_);
|
||||||
|
var exp = {
|
||||||
|
constant_score: {
|
||||||
|
query: {
|
||||||
|
match_all: {}
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
and: [
|
||||||
|
{
|
||||||
|
geo_distance: {
|
||||||
|
distance: '10km',
|
||||||
|
'xyz': { lon: 0, lat: 0 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
deepEqual(out, exp);
|
||||||
});
|
});
|
||||||
|
|
||||||
var mapping_data = {
|
var mapping_data = {
|
||||||
|
|||||||
Reference in New Issue
Block a user