Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Couchdb 在ibm bluemix节点红色环境中排序未按预期工作_Couchdb_Ibm Cloud_Cloudant_Node Red - Fatal编程技术网

Couchdb 在ibm bluemix节点红色环境中排序未按预期工作

Couchdb 在ibm bluemix节点红色环境中排序未按预期工作,couchdb,ibm-cloud,cloudant,node-red,Couchdb,Ibm Cloud,Cloudant,Node Red,我已经使用 有效载荷: { "index": { "fields": [ "sortdate","coordinates" ] }, "type": "json" } 并成功创建了索引。 现在我使用 有效载荷: { "selector": { "coordinates": [18.497484,73.81349] }, "sort": [ { "sortdate": "asc

我已经使用 有效载荷:

{
  "index": {
    "fields": [

        "sortdate","coordinates"
            ]
      },
    "type": "json"
  }
并成功创建了索引。 现在我使用

有效载荷:

{
  "selector": {
    "coordinates": [18.497484,73.81349]
  },
   "sort": [
    {
      "sortdate": "asc"
    }
  ]
}
并得到以下回应:

{
    "warning": "no matching index found, create an index to optimize query time",
    "docs": [
        {
            "_id": "4254f2d4638806b54802144ff25ecba7",
            "_rev": "1-6d3d573f21eb6d6518093aeb36a3ed5f",
            "aqi": 26,
            "coordinates": [
                18.497484,
                73.81349
            ],
            "so2": {
                "avg": 10,
                "aqi": 12
            },
            "pm10": {
                "avg": 26,
                "aqi": 26
            },
            "pm25": {
                "avg": 13,
                "aqi": 21
            },
            "date": "2017-06-30T11:08:45.439Z",
            "sortdate": 1498820925439
        },
        {
            "_id": "7c0278d8dfb3182c54ee1d6b03839b74",
            "_rev": "1-09d2b1354177f306b859f7f8c33d65d1",
            "aqi": 25,
            "coordinates": [
                18.497484,
                73.81349
            ],
            "so2": {
                "avg": 9,
                "aqi": 11
            },
            "pm10": {
                "avg": 25,
                "aqi": 25
            },
            "pm25": {
                "avg": 14,
                "aqi": 23
            },
            "date": "2017-06-30T09:56:55.004Z",
            "sortdate": 1498816615004
        },
        {
            "_id": "98e28cd2012a7c1b922f944162d12e00",
            "_rev": "1-b62d7c5fee4c9c9699cb7a9f950ec62c",
            "aqi": 25,
            "coordinates": [
                18.497484,
                73.81349
            ],
            "so2": {
                "avg": 9,
                "aqi": 11
            },
            "pm10": {
                "avg": 25,
                "aqi": 25
            },
            "pm25": {
                "avg": 14,
                "aqi": 23
            },
            "date": "2017-06-30T10:23:22.896Z",
            "sortdate": 1498818202896
        },
        {
            "_id": "cb6f3d1a313df7e95326d13085b480c9",
            "_rev": "1-77678d8df1c04dfc33f513906a97ca1e",
            "aqi": 26,
            "coordinates": [
                18.497484,
                73.81349
            ],
            "so2": {
                "avg": 10,
                "aqi": 12
            },
            "pm10": {
                "avg": 26,
                "aqi": 26
            },
            "pm25": {
                "avg": 13,
                "aqi": 21
            },
            "date": "2017-06-30T11:08:05.364Z",
            "sortdate": 1498820885364
        },
        {
            "_id": "db1fe2e2403f8acd8655a3a65cf4b36c",
            "_rev": "1-ef51370ef1ddc7215512b4644d095634",
            "aqi": 25,
            "coordinates": [
                18.497484,
                73.81349
            ],
            "so2": {
                "avg": 9,
                "aqi": 11
            },
            "pm10": {
                "avg": 25,
                "aqi": 25
            },
            "pm25": {
                "avg": 14,
                "aqi": 23
            },
            "date": "2017-06-30T09:42:40.284Z",
            "sortdate": 1498815760284
        },
        {
            "_id": "e226e828bce5e31534db87f44f98efae",
            "_rev": "1-2a238373a47575158866c56019d75fbe",
            "aqi": 25,
            "coordinates": [
                18.497484,
                73.81349
            ],
            "so2": {
                "avg": 9,
                "aqi": 11
            },
            "pm10": {
                "avg": 25,
                "aqi": 25
            },
            "pm25": {
                "avg": 14,
                "aqi": 23
            },
            "date": "2017-06-30T09:43:18.894Z",
            "sortdate": 1498815798894
        },
        {
            "_id": "e38663621c6148952fd84e3ab54195c0",
            "_rev": "1-fa45393376d7dc8677ebd48bd2804d70",
            "aqi": 26,
            "coordinates": [
                18.497484,
                73.81349
            ],
            "so2": {
                "avg": 10,
                "aqi": 12
            },
            "pm10": {
                "avg": 26,
                "aqi": 26
            },
            "pm25": {
                "avg": 14,
                "aqi": 23
            },
            "date": "2017-06-30T10:25:17.277Z",
            "sortdate": 1498818317277
        },
        {
            "_id": "e435e43de6bcb01c1596874afacef581",
            "_rev": "1-072be28b4128118e443c500494f456a1",
            "aqi": 26,
            "coordinates": [
                18.497484,
                73.81349
            ],
            "so2": {
                "avg": 10,
                "aqi": 12
            },
            "pm10": {
                "avg": 26,
                "aqi": 26
            },
            "pm25": {
                "avg": 13,
                "aqi": 21
            },
            "date": "2017-06-30T11:59:21.235Z",
            "sortdate": 1498823961235
        },
        {
            "_id": "f195832354b6fc816e1039dacf41546f",
            "_rev": "1-52fa322d3c034ddf70259991ac7c7021",
            "aqi": 26,
            "coordinates": [
                18.497484,
                73.81349
            ],
            "so2": {
                "avg": 10,
                "aqi": 12
            },
            "pm10": {
                "avg": 26,
                "aqi": 26
            },
            "pm25": {
                "avg": 14,
                "aqi": 23
            },
            "date": "2017-06-30T10:24:01.539Z",
            "sortdate": 1498818241539
        }
    ]
}
正如您所看到的,这些记录并没有按照sortdate字段进行排序


我不明白这里有什么不对。

当您指示Cloudant从字段“sortdate”、“coordinates”创建索引时,它会在磁盘上创建一个按
sortdate
coordinates
排序的数据结构。如果您随后执行一个可以使用此索引优化的查询,那么您的查询将获得性能提升

不幸的是,您正在进行的查询没有得到您创建的索引的帮助。通过排序日期和坐标上的索引,可以帮助自己通过
坐标进行查询

您的查询可以通过
坐标上的索引来增强,例如

{
  "index": {
    "fields": [

        "sortdate","coordinates"
            ]
      },
    "type": "json"
}

请提供一些上下文,例如您尝试使用的节点。您的索引似乎未用于查询:
“未找到匹配的索引,请创建索引以优化查询时间”
@chughts:我使用第一个请求创建索引,结果成功。您是否知道我是如何调试这个的。@ChrisSnow:我使用http节点发送http请求,使用函数节点修改或添加头参数。Http响应节点将响应发送回客户端。@Anil,您看过这里的教程了吗: