python - Redisearch 前缀搜索始终返回多个字段索引的总计最大值 200

标签 python redis redisearch

使用 python RediSearch 客户端连接到 RediSearch 并进行前缀搜索,该搜索应匹配 300 个文档,如果索引中存在另一个 TagField,则仅返回 200:

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了解如何配置。

关于python - Redisearch 前缀搜索始终返回多个字段索引的总计最大值 200,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59480755/

相关文章:

redis - 如何有效地联合redis中的非重叠集?

security - 清理 RediSearch 的查询

caching - 根据 3 个 hashKey 字段在 Redis Cache 中搜索

redis keep expireAt,会不会保证过期?

Redis SETEX 慢

Redisearch 相当于 MySQL 查询

python - Pandas 内存泄漏和数据帧排序

python - 使用单个 plt.bar() 函数设置条形图标签和值

Python:If 语句 "If not none"处理

python - 尝试从网页中提取一些数据(抓取初学者)