mongodb - Python Eve not following set schema and returning full document when using aggregation pipeline -
i have simple api in coordinates , distance provided , , documents within distance returned. intend return id , distance defined schema being ignored , whole document being returned. ideas?
item = {'item_title': 'relate', 'datasource': { 'source': 'api', 'filter': {'_type': 'line'}, 'aggregation': {'pipeline': [{'$geonear':{'near':{'type': 'point', 'coordinates': '$coords'},'distancefield': 'distance','maxdistance': '$maxdist','num': 1, 'spherical': 'true'}}]} }, 'schema': { '_id': {'type': 'string'}, 'distance': {'type': 'float'} }, } domain = {"data": item}
and postman query is:
http://localhost:8090/data?aggregate={"$maxdist": 500, "$coords": [-1.47, 50.93]}
edit:
following neil's comment tried this:
item = {'item_title': 'relate', 'schema': { 'uri': {'type': 'string'}, 'distance': {'type': 'float'} }, 'datasource': { 'source': 'api', 'filter': {'_type': 'link'}, 'aggregation': {'pipeline': [{'$geonear':{'near':{'type': 'point', 'coordinates': ['$lng', '$lat']},'distancefield': 'distance','maxdistance': '$maxdist','num': 1, 'spherical': 'true'}}]} } }
with following postman request:
http://localhost:8090/data?aggregate={"$maxdist": 500, "$lng": -1.47, "$lat": 50.93}
this leading following error:
geonear command failed: { ok: 0.0, errmsg: "'near' field must point", code: 17304, codename: "location17304" }
Comments
Post a Comment