如何在flask中设置redisearch配置?

问题描述

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

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`,

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)