gpt4 book ai didi

python - 慢速搜索

转载 作者:行者123 更新时间:2023-11-28 19:26:08 25 4
gpt4 key购买 nike

在使用简单架构创建快速索引并为 150 万条记录编制索引后,我在 15 秒内获得了近 1000 个搜索结果。

schema = Schema(tax_id=STORED, name=TEXT(stored=True))

MAIN*.seg 文件的大小约为 190 Mb。

我搜索的方式如下

 ix=open_dir("index")
with ix.searcher() as searcher:
query = QueryParser("name", ix.schema).parse(u'putrefaciens')
results = searcher.search(query)

我想知道这种性能是否符合预期,我们能否在给定索引大小的情况下使用 whoosh 进行更快的全文搜索。

最佳答案

不确定它是否对您的应用程序有帮助,但我只是想指出 TEXT 字段比 ID 字段做的事情更复杂。

在我的 whoosh 应用程序中,我有一个“名称”TEXT 字段,用于“已处理”索引/搜索。所以只要输入一些单词,如果它在名称中就会被找到。

如果我只想“按原样”进行精确索引/查找,我还有一个“name_exact”ID 字段。

如果后者对您的应用程序来说足够了,您可以尝试使用 ID 字段的性能。

正如 Steve K 已经指出的那样,使用最近的 whoosh(甚至 repo 提示)也可能有所帮助。

关于python - 慢速搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11875171/

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