Skip to content

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

@vyavdoshenko

Description

@vyavdoshenko

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions