dragonflydb / dragonflydb/dragonfly

FT.SEARCH Not Supported in Lua Scripts of DragonflyDB (Incompatible with Redis)

Open
#3,704 7 comments 1 reaction 0 assignees View on GitHub
bug minor
Dominant language
C++
Stars
31.6k
Forks
1.3k
Avg merge
1d 10h
Merged PRs (30d)
137

Description

Unfortunately FT.SEARCH (from within lua scripts) works in redis but not in dragonflydb.
Is there a setting in df that I need to enable manually first for it to work (f.e. some atomicity setting) or is it a bug?

### Steps to reproduce:
-Create test data index:
`FT.CREATE idx:testindex ON JSON PREFIX 1 testindex: SCHEMA $.pk AS pk TAG $.color AS color TAG`

-Insert test data (optional)
`JSON.SET testindex:abc1 . "{\"pk\":\"abc1\",\"color\":\"blue\"}" `

-Run search query **outside** lua script (works in redis + dragonflydb)
FT.SEARCH idx:testindex "(@color:{blue})"

-Run search query **from within lua script (works in redis, but fails in dragonfly)**:
`EVAL "return redis.call('FT.SEARCH', 'idx:testindex', '((@color:{blue}))', 'LIMIT', '0', '1')" 0`

### Error message:
**Error: "This Redis command is not allowed from script"**
Here is the full error message:
`"ERR Error running script (call to b051a0cdb6086107db75e8f9313672a0e21c6d82): @user_script:2: This Redis command is not allowed from script"`

Side note: For hierarchical data we rely heavily on this command to work from within lua scripts in order to traverse data directly on the server (avoiding network roundtrips).
Therefore it is crucial for us to work before we can migrate to dragonflydb and really appreciate your assistance.

Many thanks in advance for your efforts.

Contributor guide

Open the contributing guide

Research direction

Start by running the listed FT.CREATE, JSON.SET, FT.SEARCH, and EVAL commands to reproduce the script restriction. Trace how FT.SEARCH is classified when called through EVAL; no source file or test is named in the issue. Done means FT.SEARCH runs from a Lua script in DragonflyDB and returns results like Redis.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, lua, redis
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.