nicolasff / webdis

A Redis HTTP interface with JSON output
https://webd.is
BSD 2-Clause "Simplified" License
2.82k stars 307 forks source link

Null values on GEORADIUS using WITH* options #164

Closed shawnhwei closed 4 years ago

shawnhwei commented 4 years ago

Seems like the nested array cannot be handled?

GEOADD discovery 100 50 testing
GEOADD discovery 100 50 testing2
GEOADD discovery 100 50 testing3
curl -X GET \
  http://127.0.0.1:7379/GEORADIUS_RO/discovery/100/50/10/km

{
    "GEORADIUS_RO": [
        "testing",
        "testing2",
        "testing3"
    ]
}
curl -X GET \
  http://127.0.0.1:7379/GEORADIUS_RO/discovery/100/50/10/km/WITHDIST

{
    "GEORADIUS_RO": [
        null,
        null,
        null
    ]
}
redis-cli
127.0.0.1:6379> GEORADIUS_RO discovery 100 50 10 km WITHDIST
1) 1) "testing"
   2) "0.0002"
2) 1) "testing2"
   2) "0.0002"
3) 1) "testing3"
   2) "0.0002"
majklik commented 4 years ago

Webdis actually do not supports recursive arrays in the replies. There is patch for JSON output: https://github.com/nicolasff/webdis/issues/176#issue-639463065 Output ewith this patch: curl -X GET http://127.0.0.1:7379/5/GEORADIUS_RO/discovery/100/50/10/km/WITHDIST {"GEORADIUS_RO":[["testing","0.0002"],["testing2","0.0002"],["testing3","0.0002"]]}

nicolasff commented 4 years ago

This was fixed by @majklik's PR in #176, packaged as [release 0.1.11]() – also available as a Docker image to test locally with docker pull nicolas/webdis:0.1.11.

The code changed a little after his last comment, so here is the current output for the request that was producing null values:


curl -s http://127.0.0.1:7379/GEORADIUS_RO/discovery/100/50/10/km/WITHDIST | jq
{
  "GEORADIUS_RO": [
    {
      "dist": "0.0002",
      "name": "testing"
    },
    {
      "dist": "0.0002",
      "name": "testing2"
    },
    {
      "dist": "0.0002",
      "name": "testing3"
    }
  ]
}```