首页 > 解决方案 > 记录没有被删除使用cloudsolrclient 中的功能

问题描述

我看到太阳能功能的奇怪行为。SolrConfig.xml 配置在我的本地和舞台实例中是相同的。

<autoCommit>
      <maxTime>${solr.autoCommit.maxTime:5000}</maxTime>
      <openSearcher>false</openSearcher>
</autoCommit>

<autoSoftCommit>
      <maxTime>${solr.autoSoftCommit.maxTime:-1}</maxTime>
 </autoSoftCommit>

在我的本地设置中,我使用以下代码

String urlString = "http://localhost:8983/solr/usersession"; 
 SolrClient Solr = new HttpSolrClient.Builder(urlString).build(); 
List<SolrInputDocument> doclist = new ArrayList<>();
        
          for(int i=0;i<100;i++){
              SolrInputDocument doc = new SolrInputDocument(); 
          doc.addField("id", "test"+i); 
          doc.addField("cecid", "test"+i); 
          doc.addField("name","34"+i); 
          doc.addField("time_to_live_s", "+30000SECONDS"); 
          doclist.add(doc);
                
          }
          
          Solr.add(doclist);  

自动提交行为按预期工作。5 秒后,我在 5 秒后看到 solr 管理 UI 中的记录。

但是在阶段我们使用 CloudSolrclient 和 zookeeper 设置,但 5 秒后在 solr 管理 UI 中看不到记录。我不确定为什么自动提交功能在阶段服务器中不起作用。谁能让我知道在相同配置设置下这种不一致行为的原因是什么。

标签: solr

解决方案


我最好的猜测是${solr.autoSoftCommit.maxTime}变量没有设置,-1 表示没有 autoSoftCommit。

尝试直接在中设置字段solrconfig.xml并再次构建索引。

<!-- Example Config -->

<autoSoftCommit>
    <maxTime>1000</maxTime>
</autoSoftCommit>

由于 Solr 在启动时编写文档,您只需重新启动 Solr 服务器即可快速检查${solr.autoSoftCommit.maxTime}问题是否存在。重新启动后,您的文档应该可供搜索。


推荐阅读