0

我正在尝试使用下面的代码。但是这里还没有提到配置设置。搜索了很多博客,但没有找到。

from redisearch import Client, TextField, IndexDefinition, Query

# Creating a client with a given index name
client = Client("myIndex")

# IndexDefinition is available for RediSearch 2.0+
definition = IndexDefinition(prefix=['doc:', 'article:'])

# Creating the index definition and schema
client.create_index((TextField("title", weight=5.0), TextField("body")), definition=definition)

# Indexing a document for RediSearch 2.0+
client.redis.hset('doc:1',
                mapping={
                    'title': 'RediSearch',
                    'body': 'Redisearch impements a search engine on top of redis'
                })

# Indexing a document for RediSearch 1.x
client.add_document(
    "doc:2",
    title="RediSearch",
    body="Redisearch implements a search engine on top of redis",
)

# Simple search
res = client.search("search engine")

# the result has the total number of results, and a list of documents
print(res.total) # "2"
print(res.docs[0].title) # "RediSearch"

# Searching with complex parameters:
q = Query("search engine").verbatim().no_content().with_scores().paging(0, 5)
res = client.search(q)

我收到如下错误:

redis.exceptions.ResponseError
redis.exceptions.ResponseError: unknown command `FT.SEARCH`, with args beginning with: `myIndex`, `search engine`, `LIMIT`, `0`, `10`,
4

0 回答 0