gpt4 book ai didi

java - Solr 索引时搜索

转载 作者:行者123 更新时间:2023-12-01 15:52:49 25 4
gpt4 key购买 nike

我在优化以下伪代码时遇到问题,感谢任何帮助

for every term 
open new index searcher
do search
if found
skip and search for next term
else
add it to index
commit
close searcher

在上面的代码中,在向索引添加新文档/术语时,我必须提交更改以仅添加新文档(我觉得成本很高),以便下次打开新索引搜索器时看到新更改。

有什么方法可以提高性能吗?仅供引用:我有 3600 万个术语需要编制索引。

最佳答案

您可以创建一个 HashSet 来删除内存中重复的术语列表,然后仅对这些术语建立索引。伪代码如下:

set := new HashSetfor each term  if set contains term    skip to next iteration  else    add term to setendopen indexfor each term in set  add term to indexendclose index

关于java - Solr 索引时搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5681168/

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