gpt4 book ai didi

java - 无法在 SolrCloud 中使用 CloudSolrServer 提交文档

转载 作者:行者123 更新时间:2023-12-01 04:20:00 24 4
gpt4 key购买 nike

我最近开始探索 SolrCloud 并尝试建立索引使用 CloudSolrServer 客户端的文档。我看到的问题是如果我不这样做在 CloudSolrServer 对象上触发显式提交,文档不是被索引。这是我的代码片段:

code>CloudSolrServer server = new CloudSolrServer("localhost:2181"); server.setDefaultCollection("collection1"); SolrInputDocument doc = new SolrInputDocument(); doc.addField("id", "http://test.com/akn/test6.html"); doc.addField("Source2", "aknsource"); doc.addField("url", "http://test.com/akn/test6.html"); doc.addField("title", "SolrCloud rocks"); doc.addField("text", "This is a sample text"); UpdateResponse resp = server.add(doc); //UpdateResponse res = server.commit(); 

I've 2 shards with 1 replica each and a single zookeeper instance.

Once I run this test code, I'm able to see the request hitting the nodes. Here's the output from the log :


INFO - 2013-09-26 03:19:04.981;
org.apache.solr.update.processor.LogUpdateProcessor; [collection1]
webapp=/solr path=/update params={distrib.from=
http://ec2-1-2-3-4.us-west-1.compute.amazonaws.com:8983/solr/collection1/&update.distrib=TOLEADER&wt=javabin&version=2}
{add=[http://test.com/akn/test6.html (1447223565945405440)]} 0 42
INFO - 2013-09-26 03:19:19.943;
org.apache.solr.update.DirectUpdateHandler2; start
commit{,optimize=false,openSearcher=false,waitSearcher=true,expungeDeletes=false,softCommit=false,prepareCommit=false}
INFO - 2013-09-26 03:19:20.249; org.apache.solr.core.SolrDeletionPolicy;
SolrDeletionPolicy.onCommit: commits: num=2

commit{dir=NRTCachingDirectory(org.apache.lucene.store.MMapDirectory@/mnt/ebs2/TestSolr44/solr/collection1/data/index
lockFactory=org.apache.lucene.store.NativeFSLockFactory@36ddc581;
maxCacheMB=48.0 maxMergeSizeMB=4.0),segFN=segments_7,generation=7}

commit{dir=NRTCachingDirectory(org.apache.lucene.store.MMapDirectory@/mnt/ebs2/Testolr44/solr/collection1/data/index
lockFactory=org.apache.lucene.store.NativeFSLockFactory@36ddc581;
maxCacheMB=48.0 maxMergeSizeMB=4.0),segFN=segments_8,generation=8}
INFO - 2013-09-26 03:19:20.250; org.apache.solr.core.SolrDeletionPolicy;
newest commit generation = 8
INFO - 2013-09-26 03:19:20.252; org.apache.solr.search.SolrIndexSearcher;
Opening Searcher@c324b85 realtime
INFO - 2013-09-26 03:19:20.254;
org.apache.solr.update.DirectUpdateHandler2; end_commit_flush

从日志来看,提交已成功完成。但是,如果我查询服务器,则不会显示任何条目。

现在,如果我打开


UpdateResponse res = server.commit();

我确实看到了索引的数据。这是日志:


INFO - 2013-09-26 03:41:24.433;
org.apache.solr.update.processor.LogUpdateProcessor; [collection1]
webapp=/solr path=/update params={wt=javabin&version=2} {add=[
<a href="http://test.com/akn/test6.html" rel="noreferrer noopener nofollow">http://test.com/akn/test6.html</a> (1447224970494083072)]} 0 12
INFO - 2013-09-26 03:41:24.490;
org.apache.solr.update.DirectUpdateHandler2; start
commit{,optimize=false,openSearcher=true,waitSearcher=true,expungeDeletes=false,softCommit=false,prepareCommit=false}
INFO - 2013-09-26 03:41:24.788; org.apache.solr.core.SolrDeletionPolicy;
SolrDeletionPolicy.onCommit: commits: num=2 <p></p>

<p>commit{dir=NRTCachingDirectory(org.apache.lucene.store.MMapDirectory@/mnt/ebs2/TestSolr44/solr/collection1/data/index
lockFactory=org.apache.lucene.store.NativeFSLockFactory@36ddc581;
maxCacheMB=48.0 maxMergeSizeMB=4.0),segFN=segments_8,generation=8} </p>

<p>commit{dir=NRTCachingDirectory(org.apache.lucene.store.MMapDirectory@/mnt/ebs2/TestSolr44/solr/collection1/data/index
lockFactory=org.apache.lucene.store.NativeFSLockFactory@36ddc581;
maxCacheMB=48.0 maxMergeSizeMB=4.0),segFN=segments_9,generation=9}
INFO - 2013-09-26 03:41:24.788; org.apache.solr.core.SolrDeletionPolicy;
newest commit generation = 9
INFO - 2013-09-26 03:41:24.792; org.apache.solr.search.SolrIndexSearcher;
Opening Searcher@138ba593 main
INFO - 2013-09-26 03:41:24.794;
org.apache.solr.update.DirectUpdateHandler2; end_commit_flush
INFO - 2013-09-26 03:41:24.794; org.apache.solr.core.QuerySenderListener;
QuerySenderListener sending requests to
Searcher@138ba593main{StandardDirectoryReader(segments_9:21:nrt
_0(4.4):C1 _1(4.4):C1
_3(4.4):C1 _4(4.4):C1 _5(4.4):C1 _7(4.4):C1)}
INFO - 2013-09-26 03:41:24.795; org.apache.solr.core.QuerySenderListener;
QuerySenderListener done.
INFO - 2013-09-26 03:41:24.798; org.apache.solr.core.SolrCore;
[collection1] Registered new searcher
Searcher@138ba593main{StandardDirectoryReader(segments_9:21:nrt
_0(4.4):C1 _1(4.4):C1
_3(4.4):C1 _4(4.4):C1 _5(4.4):C1 _7(4.4):C1)}
INFO - 2013-09-26 03:41:24.798;
org.apache.solr.update.processor.LogUpdateProcessor; [collection1]
webapp=/solr path=/update
params={waitSearcher=true&commit=true&wt=javabin&expungeDeletes=false&commit_end_point=true&version=2&softCommit=false}
{commit=} 0 308
</p>
这是提交配置:

<autoCommit>
<maxTime>30000</maxTime>
<openSearcher>false</openSearcher>
</autoCommit> <p></p>

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

不确定我在这里缺少什么,任何指针都会被赞赏。

谢谢

最佳答案

在您包含的第一个日志中,它仅显示 openSearcher=false 的提交。这确保了数据被正确刷新,但不能使其可搜索。这可能是由于配置的 autoCommit 部分而发生的。

您粘贴的配置片段显示 autoSoftCommit 也存在, maxTime 为一秒,但日志没有显示任何软提交。如果没有看到整个配置,就不可能判断它是否实际上处于 Activity 状态。它可能被注释掉了。

关于java - 无法在 SolrCloud 中使用 CloudSolrServer 提交文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19032280/

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