Hiredis: Support for redisearch? almost out of the box

Created on 19 Mar 2020  路  5Comments  路  Source: redis/hiredis

Hello, great module :)

Redisearch command works but some of the results are marked as 'undef'.

https://oss.redislabs.com/redisearch/Quick_Start.html

git clone --recursive https://github.com/RediSearch/RediSearch.git
cd RediSearch
make build
make run
use Redis::hiredis;
use Data::Dumper;

my $redis = Redis::hiredis->new();
   $redis->connect('127.0.0.1', 6379);

# create index
$redis->command("FT.CREATE my_index SCHEMA title TEXT body TEXT");

# add documents
$redis->command("FT.ADD my_index doc1 1.0 FIELDS title foo body bar");
$redis->command("FT.ADD my_index doc2 1.0 FIELDS title foo_2 body bar_2");

# search
my $search = $redis->command("FT.SEARCH my_index foo");

print Dumper(\$search);

$VAR1 = \[
            1,
            'doc1',
            undef
          ];

On redis-cli I get.

1) (integer) 1
2) "doc1"
3) 1) "title"
   2) "foo"
   3) "body"
   4) "bar"

Looks like some array are not getting parsed. Redisearch is pretty great and we have 0 perl client, a fix would be appreciated.

Most helpful comment

Hi, I put together a quick and dirty program to query Redisearch in hiredis

Gist is here

I tested it against the current version of hiredis (v0.14.0) and an older one (v0.11.0) and they both work.

All 5 comments

Hi, I think you have the wrong repository.

You are looking for the perl wrapper around hiredis. This repository is the C library :smile:

I don't know enough about perl to direct you to the repo.

Perhaps this one?

Oh my :) thanks.
I hope the issue is not with the C library.

Hi, I put together a quick and dirty program to query Redisearch in hiredis

Gist is here

I tested it against the current version of hiredis (v0.14.0) and an older one (v0.11.0) and they both work.

Thank you for taking the time to check.

Then the problem is from the wrapper itself, it is using a very old version, could not figure which one from those files, maybe you can figure it out.

https://metacpan.org/source/NEOPHENIX/Redis-hiredis-0.11.0

This is a C wrapper (perl can run C inside of it) for perl, I guess the culprit is there then? :)

https://metacpan.org/source/NEOPHENIX/Redis-hiredis-0.11.0/Redis-hiredis.xs

Looks like they're using 0.11.0, which is one of the versions I tested.

So it does appear this is in the wrapper but I don't know where. Good luck! :)

Was this page helpful?
0 / 5 - 0 ratings