我正在尝试通过在 4.4.0 版中发布 RAW JSON 数据来更新 SOLR 索引。
它的更新字段很好,但在多值字段的情况下,它不存储多个值而只存储最后一个。
例如-
一世。这是我的架构结构-
<dynamicField name="amenity_*" type="text_general" indexed="true" stored="true" multiValued="true"/>
Run Code Online (Sandbox Code Playgroud)
ii. 这是 POST json 数据-
{"add":{ "doc":{"id":"7986","amenity_GENERAL":{"set":"Overnight Parking"}},"boost":1.0,"overwrite":true,"commitWithin":1000},
"add":{ "doc":{"id":"7986","amenity_GENERAL":{"set":"Pumps"}},"boost":1.0,"overwrite":true,"commitWithin":1000},
"add":{ "doc":{"id":"7986","amenity_GENERAL":{"set":"Parking Spaces"}},"boost":1.0,"overwrite":true,"commitWithin":1000}}
Run Code Online (Sandbox Code Playgroud)
成功发布后,此 id 的更新索引是-
{
"id": "7986",
"amenity_GENERAL": [
"Parking Spaces"
],
"_version_": 1446999052093751300
},
Run Code Online (Sandbox Code Playgroud)
- 它存储最后一个值 - 来自 JSON 请求的“amenity_GENERAL”。
我不确定是否需要更改该多值字段的 POST JSON 结构。
提前致谢。
编辑:此脚本将运行到 CRON,因此每次都需要对索引进行更新。在多值字段的情况下,需要避免重复值。
参考:http: //yonik.com/solr/atomic-updates/
set – 设置或替换特定值,或者如果将 null 指定为新值,则删除该值
add – 向列表添加附加值
即尝试
"amenity_GENERAL":{"add":"Parking Spaces"}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4915 次 |
| 最近记录: |