Solr thinks an update is an add operation

一个人想着一个人 提交于 2019-12-25 07:27:40

问题


Solr version is 5.4.1

I posted this to http://localhost:8983/solr/default-collection/update and it treated it like I was adding a whole document, not a partial update:

{
    "id": "0be0daa1-a6ee-46d0-ba05-717a9c6ae283",
    "tags": {
        "add": [ "news article" ]
    }
}

In the logs, I found this:

2016-02-26 14:07:50.831 ERROR (qtp2096057945-17) [c:default-collection s:shard1_1 r:core_node21 x:default-collection] o.a.s.h.RequestHandlerBase org.apache.solr.common.SolrException: [doc=0be0daa1-a6ee-46d0-ba05-717a9c6ae283] missing required field: data_type
        at org.apache.solr.update.DocumentBuilder.toDocument(DocumentBuilder.java:198)
        at org.apache.solr.update.AddUpdateCommand.getLuceneDocument(AddUpdateCommand.java:83)
        at org.apache.solr.update.DirectUpdateHandler2.doNormalUpdate(DirectUpdateHandler2.java:273)
        at org.apache.solr.update.DirectUpdateHandler2.addDoc0(DirectUpdateHandler2.java:207)
        at org.apache.solr.update.DirectUpdateHandler2.addDoc(DirectUpdateHandler2.java:169)
        at org.apache.solr.update.processor.RunUpdateProcessor.processAdd(RunUpdateProcessorFactory.java:69)

Does this make any sense? I sent updates just fine a day or two ago like that, now it is acting like the update request is a whole new document.

UPDATE The answer I selected put me in the right direction. What I had to do to correct it was load all of the existing fields that are required fields and add them to the payload myself. It then worked for me. It was not automatic, which suggests that it might be a bug in Solr 5.4.1


回答1:


If I'm not wrong, an update request always ends up in add operation. The difference with partial update is that Solr initially get the document from the index, then overrides fields according to the request parameters, and finally performs a usual document indexing.

The document is rejected because required field data_type is missing: it should be defined as stored=true in schema.xml or added to the partial document fields every time a partial update occurs. Actually the same applies to all fields.

EDIT : This is not true anymore since Solr introduced In-Place Updates.



来源:https://stackoverflow.com/questions/35659768/solr-thinks-an-update-is-an-add-operation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!