Redisearch 前缀搜索总是 returns 多个字段索引的总数最多为 200

Redisearch prefix search always returns max 200 for total for multiple fields index

使用 python RediSearch 客户端连接到 RediSearch 并进行前缀搜索,它应该匹配 300 个文档,它只 returns 200 如果索引中有另一个 TagField:

from redisearch import Client, Query, TextField, TagField

client = Client('myindex')
client.create_index([TextField('username'), TagField('age')])

# add 300 documents
for i in range(300):
    client.add_document(i, username='user%s' % i, age=i)

res = client.search(Query("@username:user*"))

assert res.total == 300 # this is always 200 no matter how many documents you add.

参见 Search Query Syntax: Prefix matching

A few notes on prefix searches: As prefixes can be expanded into many many terms, use them with caution. There is no magic going on, the expansion will create a Union operation of all suffixes.

As a protective measure to avoid selecting too many terms, and block redis, which is single threaded, there are two limitations on prefix matching:

Prefixes are limited to 2 letters or more. You can change this number by using the MINPREFIX setting on the module command line.

Expansion is limited to 200 terms or less. You can change this number by using the MAXEXPANSIONS setting on the module command line.

有关如何配置,请参阅 Run-time configuration: MAXEXPANSIONS