【问题标题】:GeoJSON Python Eve ExampleGeoJSON Python Eve 示例
【发布时间】:2015-09-30 10:44:15
【问题描述】:

我正在尝试按照 Eve 文档 (v0.6.1-dev) 进行 GeoJSON 查询:http://python-eve.org/features.html

但是,postman 中的查询返回错误:

邮递员 GET: http://localhost:5000/people?where={"location": {"$near": {"$geometry": {"type":"Point", "coordinates": [10.0, 20.0 ]}, "$maxDistance": 1000}}}

错误: 500内部服务器错误 服务器遇到内部错误,无法完成您的请求。要么是服务器超载,要么是应用程序出错。

“人”集合包含如下所示的位置:

邮递员 GET: http://localhost:5000/people

"_items": [
    {
        "_updated": "Wed, 30 Sep 2015 10:26:51 GMT",
        "firstname": "John",
        "lastname": "Doe",
        "born": "Thu, 27 Aug 1970 14:37:13 GMT",
        "role": [
            "author"
        ],
        **"location": {
            "type": "Point",
            "coordinates": [
                100,
                0
            ]
        },**
        "_links": {
            "self": {
                "href": "people/560bb8eb6adf7d0e70f26cd0",
                "title": "person"
            }
        },

知道为什么这不起作用吗?

【问题讨论】:

    标签: eve


    【解决方案1】:

    尝试打开调试模式(在设置中设置DEBUG = True)并查看实际错误是什么。该字段很可能没有地理索引(Eve 不会自动为您创建索引)。

    更新:从 v0.6 开始,您还可以要求 Eve 为您维护索引,请参阅文档中的 mongo_indexes 关键字

    【讨论】:

    • 谢谢。这成功了:> db.people.ensureIndex({location:"2dsphere"});
    • 优秀。从 v0.6 开始,您还可以要求 Eve 为您维护索引,请参阅文档中的 mongo_indexes 关键字。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多