Mike Thomsen
Mike Thomsen

Reputation: 37506

Solr thinks an update is an add operation

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

Upvotes: 0

Views: 1387

Answers (1)

EricLavault
EricLavault

Reputation: 16035

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.

Upvotes: 3

Related Questions