【问题标题】:Solr searching while indexingSolr在索引时搜索
【发布时间】:2011-04-15 18:59:01
【问题描述】:

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

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 万个术语要编入索引。

【问题讨论】:

    标签: java optimization indexing lucene solr


    【解决方案1】:

    您可以创建一个 HashSet 来对内存中的术语列表进行重复数据删除,然后仅索引这些术语。伪代码是这样的:

    设置 := 新的 HashSet 每学期 如果集合包含术语 跳到下一次迭代 别的 添加术语以设置 结尾 开放索引 对于集合中的每个术语 将术语添加到索引 结尾 收盘指数

    【讨论】:

    • 感谢您的快速回复。我提到的术语并不完全意味着字符串。在搜索或将其添加到索引之前,我必须对每个术语进行大量预处理。但是在阅读了您的评论后,我了解到我可以在对新索引进行预处理后将它们编入索引,并从新索引中提取独特的术语以供我进一步工作。再次感谢。
    【解决方案2】:

    我建议您简单地创建第二个索引(在 RAMDirectory 或临时位置的 FSDirectory 中)。将所有未找到的术语/文档添加到第二个(临时)索引中,并在最后合并两个索引。

    open index for searching
    for every term
      open new index searcher
      do search
      if found 
        skip and search for next term
      else
        add it to the second index
    end
    close searcher
    commit temp index
    merge temp index into primary index 
    commit primary index
    

    【讨论】:

      猜你喜欢
      • 2011-03-21
      • 2012-07-03
      • 1970-01-01
      • 1970-01-01
      • 2011-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多