【发布时间】:2013-08-02 22:03:38
【问题描述】:
我正在使用 Solr 4.3
我设置了两个 Solr 核心:userCore 和 mainCore
userCore 拥有自己的 schema.xml 和 solrconfig.xml,并托管在 localhost:8983 上。
mainCore 有自己不同的schema 和solrconfig,并设置了一个SolrCloud,一个分片在localhost:8080,另一个在localhost:7574
我将文档发布到userCore 中定义的userToMain 更新链,该更新链为文档编制索引,然后将其转发到mainCore 中的另一个更新链。文档在这里处理并索引到mainCore,然后我们就完成了。
在涉及分布式搜索之前,这一切都运作良好:
我可以通过 Luke 查询不同核心和分片的索引来判断文档已成功编入索引。但是,分布式 Solr 查询不适用于此设置,因为当它变成 otu 时,我的 mainCore(即设置了 SolrCloud 的那个)没有定义 uniqueKey。
所以我试图解决这个问题。我已经在 mainCore 架构中有以下字段:
<field name="doc-id" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
我希望通过在架构中指定将其用作 uniqueKey:
<uniqueKey>doc-id</uniqueKey>
现在当我通过 userCore 发布文档时
`java -Durl=http://localhost:8983/solr/userCore/update?update.chain=userToCoref -jar \
$(SOLR_HOME)/example/exampledocs/post.jar example/examplesdocs/test_doc0.xml`
我收到错误消息
Document is missing mandatory uniqueKey field: doc-id
不仅在mainCore 中,实际上定义了uniqueKey 的架构,而且在 userCore 的架构中甚至没有提及 uniqueKey!
具体来说,这是错误的一部分 mainCore:
127578 [qtp1733460569-16] INFO org.apache.solr.update.processor.LogUpdateProcessor – [corefCore] webapp=/solr path=/update params={wt=javabin&version=2} {} 0 619
127579 [qtp1733460569-16] ERROR org.apache.solr.core.SolrCore – org.apache.solr.common.SolrException: Document is missing mandatory uniqueKey field: doc-id
at org.apache.solr.update.AddUpdateCommand.getHashableId(AddUpdateCommand.java:132)
at org.apache.solr.update.processor.DistributedUpdateProcessor.processAdd(DistributedUpdateProcessor.java:389)
at org.apache.solr.update.processor.LogUpdateProcessor.processAdd(LogUpdateProcessorFactory.java:100)
at org.apache.solr.update.processor.UpdateRequestProcessor.processAdd(UpdateRequestProcessor.java:51)
userCore 的部分错误:
135506 [qtp1733460569-19] INFO org.apache.solr.update.processor.LogUpdateProcessor – [userCore] webapp=/solr path=/update params={update.chain=userToCoref} {} 0 628
135507 [qtp1733460569-19] ERROR org.apache.solr.core.SolrCore – org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: Document is missing mandatory uniqueKey field: doc-id
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:402)
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:180)
at org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:117)
at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:116)
at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:102)
总之,让我感到困惑的是两方面:
1) 为什么,当我实际上在 mainCore 架构中定义了 doc-id 字段时,当我将 uniqueKey 指向它时,并且当它在所有其他情况下确实被索引时,Solr 是否抱怨Document is missing mandatory uniqueKey field:doc-id???
2) 即使 mainCore 在这个领域确实有问题,为什么 userCore 似乎也在抱怨这个?它们位于完全不同的服务器上,具有完全不同的配置。 userCore 所做的只是将它接收到的文档发布到 mainCore,由该 mainCore 的 URL 指定。
任何帮助将不胜感激!
编辑:我想为 cmets 提供一些答案。
发布到userCore的原始文档test_doc0.xml是这样的:
<add><doc>
<field name="docid">docid0</field>
<field name="coref_input">Bill Clinton was the 42nd president. Clinton's wife Hillary is
currently Secretary of State. Hillary Clinton ran for president
unsuccessfully.</field>
</doc></add>
在它被索引到userCore 之后,它被发送到mainCore 以通过相关updateRequestProcessor 中的这个特定逻辑进行处理,userToMainUpdateRequestProcessor.java:
public void processAdd(AddUpdateCommand cmd) throws IOException {
SolrInputDocument userDoc = cmd.getSolrInputDocument();
SolrInputField userInputField = userDoc.getField(inputField);
if (userInputField != null) {
SolrInputField userDocIdField = userDoc.getField(docIdField);
if (userDocIdField == null || userDocIdField.getValueCount() > 1) {
throw new RuntimeException(docIdField + " must be present and single-valued");
}
}
SolrResponse response;
try {
mainServer.add(userDoc);
mainServer.commit();
} catch (SolrServerException e) {
throw new RuntimeException(e);
}
super.processAdd(cmd);
}
其中mainServer 在UserToMainUpdateRequestProcessorFactory.java 中定义为:
mainServer = new HttpServer("http://localhost:8080/solr/mainCore");
因此userCore 向mainCore 发布了一个文档,mainCore 进行了一系列处理以生成更多这样的字段(我不能包含完整的文档):
姓名_数据:希拉里·克林顿
Name_FullnameOverrides:enghillary 克林顿
Name_CompletedData:希拉里·克林顿
名称令牌计数:2
文档 ID:docid0
文档语言:eng
indoc 链 ID:5
最长提及:希拉里克林顿
置信度:0.9443013649773926
【问题讨论】:
-
您能否添加您的文档 (test_doc0.xml) 的外观,因为它可能是由于这个原因
-
userCore 从 mainCore 记录 REMOTE 异常,这并不奇怪。您提到您在 userCore 上进行处理,而不是在主核心上进行转发处理。你如何做到这一点?您确定将相同的文档传递给 mainCore 吗?我认为值得在 mainCore 中调试更新处理器以查看输入的内容。