gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 09:13:11 25 4
gpt4 key购买 nike

使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com