admin管理员组文章数量:1353289
I want to implement lexicographic search (range queries) in Redis as a way to do text search. This is for contexts where RediSearch is not available such as Upstash or Valkey (Redis fork) (edit: supported through valkey-search). I do not want to create a new Redis module or extend the Redis core, but rather implement the functionality in client side using existing Redis primitives.
I'm considering a naive approach using a secondary index (sorted set) where each word is added with the same score:
ZADD myindex 0 "apple" 0 "banana" 0 "kiwi"
Then to search for values starting with "bana":
ZRANGEBYLEX myindex "[bana" "[bana\xff"
Would this approach work for basic lexicographic searches? I'm also interested in implementing something more efficient like a suffix trie similar to what Redis Search uses with FT.CREATE, but I'm not sure what Redis primitives would be appropriate for that implementation.
Has anyone implemented something similar or can suggest the right approach for efficient lexicographic range queries in Redis?
Note that @upstash/query aims to achieve a similar functionality but lexicographic is not implemented and the project seems abandoned.
本文标签: Lexicographic search in Redis without RediSearchStack Overflow
版权声明:本文标题:Lexicographic search in Redis without RediSearch - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743926452a2563050.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论