You gave an XML example, so I assumed you were working with XML!

In JSON...

[{"id": "doc-id", "tags": {"add": ["a", "b"]}]

and

[{"id": "doc-id", "tags": {"set": null}}]

BTW, this kind of stuff is covered in the book, separate chapters for XML and JSON, each with dozens of examples like this.

-- Jack Krupansky

-----Original Message----- From: Dotan Cohen
Sent: Thursday, May 30, 2013 9:36 AM
To: solr-user@lucene.apache.org
Subject: Re: Removing a single value from a multiValue field

On Thu, May 30, 2013 at 3:42 PM, Jack Krupansky <j...@basetechnology.com> wrote:
First, you cannot do any internal editing of a multi-valued list, other
than:

1. Replace the entire list.
2. Add values on to the end of the list.


Thank you. I meant that I am actually editing the entire document.
Reading it, changing the values that I need, and then 'updating' it. I
will look into updating only the single multiValued field.


But you can do both of those operations on a single multivalued field with
"atomic update" without reading and writing the entire document.

Second, there is no "<arr>" element in the Solr Update XML format. Only
"<field>".

To simply replace the full, current value of one multi-valued field:

<add>
 <doc>
   <field name="id">doc-id</field>
   <field name="tags" update="set">a</field>
   <field name="tags" update="set">b</field>
 </doc>
</add>

If you simply want to append a couple of values:

<add>
 <doc>
   <field name="id">doc-id</field>
   <field name="tags" update="add">a</field>
   <field name="tags" update="add">b</field>
 </doc>
</add>

To empty out a multivalued field:

<add>
 <doc>
   <field name="id">doc-id</field>
   <field name="tags" update="set" null="true" />
 </doc>
</add>


Thank you. I will see about translating that into the JSON format that
I work with.

--
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

Reply via email to