Using python RediSearch client to connect to RediSearch and doing a prefix search which should match 300 documents it only returns 200 if there is another TagField in the index:
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.
See 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.
See Run-time configuration: MAXEXPANSIONS for how to configure.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.