dragonflydb / dragonflydb/dragonfly

Implement FT.SUGADD, FT.SUGGET, FT.SUGDEL, FT.SUGLEN for autocomplete functionality

Open
#5,960 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
31.5k
Forks
1.3k
Avg merge
1d 10h
Merged PRs (30d)
127

Description

Implement autocomplete/suggestion commands using sorted sets as storage.

`FT.SUGADD` {key} {string} {score} [INCR] [PAYLOAD {payload}]
Store suggestion in sorted set: ft:sug:{key}
Execute: ZADD ft:sug:{key} {score} {string} (or ZINCRBY if INCR)
Return: size of the suggestion dictionary

`FT.SUGGET` {key} {prefix} [FUZZY] [MAX {count}] [WITHSCORES] [WITHPAYLOADS]
Get suggestions from: ft:sug:{key}
Execute: ZRANGE ft:sug:{key} ... with prefix filtering
Return: array of suggestions (with scores if WITHSCORES)

`FT.SUGDEL` {key} {string}
Execute: ZREM ft:sug:{key} {string}
Return: 1 if deleted, 0 if not found

`FT.SUGLEN` {key}
Execute: ZCARD ft:sug:{key}
Return: number of suggestions

Storage: Use sorted sets with key pattern ft:sug:{key} to store suggestions with scores.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.