I want to do Solr Delta Import, but I don't want to update the whole document. Is there a way I can instruct solr to update only certain field when do the delta import?
This feature is knows as in-place update. An in-place update is performed only when the field to be updated meet these conditions:
In other words this feature is based on a special data structure DocValues so you can not update non DocValues field without whole document reindexing. You can read more details about updatable DocValues in the following jira issues:
Here is an example via SolrJ:
HttpSolrClient client = new HttpSolrClient("http://localhost:8983/solr");
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id","1");
Map<String,Object> fields = new HashMap<>();
fields.put("inc", "-1");
doc.addField("count", fields);
client.add(doc);
client.close();
Or via CURL:
curl http://localhost:8983/solr/library/update -d '
[
{"id" : "1",
"count" : {"inc":"-1"}
}
]'
Where field count is declared as:
<field name="count" type="int" indexed="false" stored="false" docValues="true"/>
Please note in case of wrong field configuration an "Atomic Update" will be applied.
You can "update" any field in document without any restrictions by "Atomic Updates". Atomic Update does not actually do in-place update - it deletes the old document and then indexes a new document with the update applied to it in one shot. Under the hood it requires that all fields in your schema must be configured as stored and copy fields as not stored(keep in mind nested documents) and tries to reconstruct the whole document from the stored fields. In case of any misconfiguration you will lost a huge part of document without any notification. In general atomic update has the following drawbacks: