Solr Atomic 更新更改字段名称

Solr Atomic update change field name

我是 Solr 新手。我尝试做原子更新,.json更新文件不仅改变字段值,而且字段名也变成了"fieldname.set",比如"price"变成了"price.set"。 任何帮助将不胜感激。

    # /usr/local/solr/bin/solr version
    8.5.1

    # curl http://localhost:8983/solr/books/select?q=id%3A0371558727
    "response":{"numFound":1,"start":0,"docs":[
      {
        "id":"0371558727",
        "price":19.0,
        "_version_":1667214802265571328}]
    }

    # cat test.json
    [
    {"id":"0371558727",
     "price":{"set":19.95}
    }
    ]

    # /usr/local/solr/bin/post -p 8983 -c books test.json

    # curl http://localhost:8983/solr/books/select?q=id%3A0371558727
    "response":{"numFound":1,"start":0,"docs":[
      {
        "id":"0371558727",
        "price.set":[19.95],
        "_version_":1667214933776924672}]
    }

post 工具正在 post 将 JSON 文件直接发送到 JSON 更新处理程序,它将 JSON 文档映射到内部结构- 其中 . 分隔层次结构的每个级别。

改为正确格式化更新并 post 将其 /update 使用 curl 的常规端点:

curl http://localhost:8983/solr/books/update -d '[
  {"id":"0371558727", "price":{"set":19.95}}
]'

您不必一次发出这些调用,您可以针对每个 HTTP 请求将它们分成多个更新:

curl http://localhost:8983/solr/books/update -d '[
  {"id":"0371558727", "price":{"set":19.95}},
  {"id":"0371558728", "price":{"set":14.95}},
  {"id":"0371558729", "price":{"set":12.95}},
  {"id":"0371558726", "price":{"set":16.95}}
]'

发布更新后,您可能必须提交提交 - 通过在提交时将 ?commit=true 包含在 URL 中,或者如果进行批量更新 - 在将所有更新提交到通过显式提交索引(例如,仅调用 URL 和 ?commit=true 而没有附加任何文件)。

一位 solr-user 邮件成员对此有一个很好的解决方案,将“-format solr”添加到 /bin/post

bin/post -format solr -p 8983 -c books test.json