从solr 4.5中的multiValue字段中删除单个值

时间:2015-12-07 10:48:07

标签: python solr solr4

我是solr.solr查询的新手,我得到的数据如

{
  "responseHeader": {
    "status": 0,
    "QTime": 0,
    "params": {
      "indent": "true",
      "q": "*:*",
      "_": "1449483445811",
      "wt": "json",
      "fq": "id:0553573403"
    }
  },
  "response": {
    "numFound": 1,
    "start": 0,
    "docs": [
      {
        "id": "0553573403",
        "cat": [
          "book",
          "book1"
        ],
        "name": "Cyberpunk",
        "price": 7.99,
        "price_c": "7.99,USD",
        "inStock": true,
        "author": "George R.R. Martin",
        "author_s": "George R.R. Martin",
        "series_t": "A Song of Ice and Fire",
        "sequence_i": 1,
        "genre_s": "fantasy1111",
        "labelRequest_j_12536_matching_profile": "1",
        "_version_": 1519893543721631700
      }
    ]
  }
}

schema.xml是

   <field name="cat" type="string" indexed="true" stored="true" multiValued="true"/>

然后我试图用postman,post方法和内容类型json删除数据

url-http://localhost:8983/solr/collection1/update/json?commit=true
    {
      "id"       : "0553573403",
      "cat"      : {"remove":"book1"}
     }

然后回复

{"responseHeader":{"status":0,"QTime":616}}

但它并没有删除数据..

1 个答案:

答案 0 :(得分:0)

我猜id是您的uniqueKey字段。

在Solr 4.9之前,remove更新选项不可用,请参阅 https://issues.apache.org/jira/browse/SOLR-3862

我想你必须像这样覆盖整个字段值列表:

{
    "id"       : "0553573403",
    "cat"      : {"set":["book1"]}
}