微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在flask中设置redisearch配置?

如何解决如何在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 举报,一经查实,本站将立刻删除。