I have a multivalue field called category(which is also a store field) in which i need to add only distinct values
<field name="category">value1</field>
<field name="category">value2</field>
If I do a update as follows<add>
<doc>
<field name="id">E02</field>
<field name="category" update="add">value2</field>
</doc>
</add>
I get the value2 stored twice <field name="category">value1</field>
<field name="category">value2</field>
<field name="category">value2</field>
I need to store/update only disctinct values in category fields which is a multivalue fields. How to do this solr?
Thanks in advance, Jagadesh.
This functionality has been added for Solr 7.3.
You can use the add-distinct atomic update action, instead of add
See the Jira issue (SOLR-11267) and the documentation in the Reference Guide:
add-distinct
Adds the specified values to a multiValued field, only if not already present. May be specified as a single value, or as a list.
One can "set" instead of "add", to recreate a stored field in partial document updates. So if it is the case where you have all the field values,just stick them in a Set
and then repopulate the field. You have all the data to recreate it because of stored field
requirement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With