使用 RediSearch 请求特定字段(不是所有字段)

mah*_*off 2 performance search redis redisearch

这是 RediSearch 查询的官方示例

127.0.0.1:6379> FT.SEARCH myIdx "hello world" LIMIT 0 10
1) (integer) 1
2) "doc1"
3) 1) "title"
   2) "hello world"
   3) "body"
   4) "lorem ipsum"
   5) "url"
   6) "http://redis.io"
Run Code Online (Sandbox Code Playgroud)

我的问题是,我如何只请求一两个字段,例如只是返回“标题”值(“hello world”)或“ID”和“标题”字段([1,“hello world”] )。主要是出于性能原因。

Not*_*fer 5

是的,它通过选项支持它RETURN

127.0.0.1:6379> FT.SEARCH myIdx "hello world" LIMIT 0 10 RETURN 2 title url
Run Code Online (Sandbox Code Playgroud)

请参阅: https: //oss.redislabs.com/redisearch/Commands/#ftsearch