更新solr中的多个文档每个文档需要更新指定字段

时间:2015-11-09 13:37:11

标签: solr solr4

我需要更新多个solr文档,每个文档只需要更新指定的字段。我尝试了底部格式,它抛出错误

例如:

[{"add":{"doc":{"cityId":{"set":1},"id":1}}},
{"add":{"doc":{"cityId":{"set":1},"id":10}}}]

错误:

{"responseHeader":{"status":400,"QTime":0},"error":{"msg":"Error parsing JSON field value. Unexpected OBJECT_START","code":400}}

如何解决此问题

1 个答案:

答案 0 :(得分:0)

Error parsing JSON field value. Unexpected OBJECT_START

这是因为您尝试将Array传递给solr预期的list

来自Atomic updates的文件;结帐

curl http://localhost:8983/solr/update/json -H 'Content-type:application/json' -d '
{
 "add": {"doc": {"id" : "TestDoc1", "title" : "test1"} },
 "add": {"doc": {"id" : "TestDoc2", "title" : "another test"} }
}'