nicolasff / webdis

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

RediSearch `FT.INFO` response is parsed incorrectly #188

Closed nicolasff closed 3 years ago

nicolasff commented 3 years ago

Using the index definition from the RediSearch tutorial, I noticed that calling FT.INFO via Webdis produces a pretty broken response.

Using redis-cli:

127.0.0.1:6379> FT.INFO idx:movie
 1) index_name
 2) idx:movie
 3) index_options
 4) (empty array)
 5) index_definition
 6)  1) key_type
     2) HASH
     3) prefixes
     4) 1) movie:
     5) language_field
     6) __language
     7) default_score
     8) "1"
     9) score_field
    10) __score
    11) payload_field
    12) __payload
...

There's a lot more, with 46 fields in total.

Through Webdis:

$ curl -s 'http://localhost:7379/FT.INFO/idx:movie'
{"FT.INFO":[null,null,null,[],null,[null,null,null,[null],null,null,null,"1",null,null,null,null],null,
[[null,null,null,null,"1",null],[null,null,null,null],[null,null,null,null],[null,null,null,null,null,null],
[null,null,null,null,"1",null]],null,"5",null,"5",null,"22",null,"52",null,"0.000255584716796875",null,
"31",null,"2.6702880859375e-05",null,"0.00044345855712890625",null,"0.00072479248046875",null,
"0.000152587890625",null,"10.399999618530273",null,"5.153846263885498",null,"0.53846156597137451",null,"8",
null,"0",null,"0",null,"1",null,[null,"0",null,"0",null,"0",null,"-nan",null,"0",null,"0",null,"0"],
null,[null,0,null,0,null,128,null,0]]}

Not quite the same. There was a great PR a few months ago that added support for nested data structures for the GIS commands like GEORADIUS and a few others, so I was expecting it to help with this but clearly something is still missing.

@jessie-murray do you want to take a shot at this? It's not clear to me how much work this involves, hopefully it's just a small fix since the whole recursive parsing logic was added in that PR.

nicolasff commented 3 years ago

Ah, this might just be that the strings are returned as REDIS_REPLY_STATUS instead of REDIS_REPLY_STRING, which is not supported by json_expand_array.