简体   繁体   中英

Update multivalued field, not getting multiple values in SOLR index

I am trying to update SOLR index by Posting RAW JSON data, in version 4.4.0.

Its updating fields fine, but in case of multivalued fields, its not storing multiple values but only the last one.

For eg-

i. Here is my schema structure-

<dynamicField name="amenity_*"  type="text_general"  indexed="true"  stored="true" multiValued="true"/>

ii. Here is the POST json data-

   {"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}}

After a successful post, the Updated index for this id is-

     {
        "id": "7986",
        "amenity_GENERAL": [
          "Parking Spaces"
        ],
        "_version_": 1446999052093751300
      },

-its storing the last value- "amenity_GENERAL" from the JSON request.

I am not sure, if I need to change the POST JSON structure for that multivalued field or not.

Thanks in advance.


EDIT: This script will run into a CRON, so each time need to do an Update of index. In case of multivalued field, need to avoid duplicate values.

Refer: http://yonik.com/solr/atomic-updates/

set – set or replace a particular value, or remove the value if null is specified as the new value

add – adds an additional value to a list

ie try

"amenity_GENERAL":{"add":"Parking Spaces"}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM