​
I use add and remove both on a multivalue field (think of tags on a blog
post). For this, set null won't work because I want only one value (tag) to
be removed
​, ​
and set null neither remove one nor all of values (all tags here).

So I use some
​S
olr
​J
 code which would translate to something like this:

{
"id": "docId",
​"tagId": {"remove": "someTagId"}
}

After commit, there is still taId: someTagId in my document.

​Here is my schema part for tagId:
<field name="
​tagId
" type="int" indexed="true" stored="true" multiValued="true" />

Thanks,
Mohsen

On Wed, Jul 8, 2015 at 3:26 PM, Alessandro Benedetti <
benedetti.ale...@gmail.com> wrote:

> In this scenarios, Documentation is key :
>
> Modifier
>
> Usage
>
> set
>
> Set or replace the field value(s) with the specified value(s), or *remove
> the values if 'null' or empty list is specified as the new value.*
>
> May be specified as a single value, or as a list for multivalued fields
>
> add
>
> Adds the specified values to a multivalued field.
>
> May be specified as a single value, or as a list.
> remove
>
> Removes (all occurrences of) the specified values from a multivalued field.
>
> May be specified as a single value, or as a list.
> removeregex
>
> Removes all occurrences of the specified regex from a multiValued field.
>
> May be specified as a single value, or as a list.
>
> inc
>
> Increments a numeric value by a specific amount.
>
> Must be specified as a single numeric value.
>
> In my opinion "set" is the right direction to look into.
> Not sure what happens if you use the remove to remove only a single valued
> field value.
> Can you explain us what you noticed ? An empty value remain for that field
> ?
> It is kind of weird, I would expect the field to become null.
>
> Cheers
>
>
> 2015-07-08 10:34 GMT+01:00 Mohsen Saboorian <mohs...@gmail.com>:
>
> > In my code when operation is "add" it works correctly on a multivalue
> > field. But no multivalue field can be deleted with "remove" operation.
> > The add operation adds a value to a multivaled field. The remove
> operation
> > removes a value from a multivalued field.
> >
> > If you believe that something is not working, please state clearly why
> you
> > believe that something is not working. Start by describing the symptom.
> >
> >
> > -- Jack Krupansky
> >
> > On Mon, Jul 6, 2015 at 9:22 PM, Mohsen Saboorian <mohs...@gmail.com>
> > wrote:
> >
> > > I can partially 'add' fields to my Solr index, but 'remove' operation
> > seems
> > > not working. I'm on Solr 4.10. Here is my SolrJ snippet:
> > >
> > >             SolrInputDocument doc = new SolrInputDocument();
> > >             Map<String, Object> partialUpdate = new HashMap<>();
> > >             partialUpdate.put(operation, value); // value can be object
> > > (string, number, etc) or list. operation can be add, set or remove.
> > >             doc.addField("id", id); // document id
> > >             doc.addField(fieldName, partialUpdate);
> > >
> > >             getSolrServer().add(doc, commitWithin);
> > >
> > > Is there anything wrong with my code?
> > >
> >
>
>
>
> --
> --------------------------
>
> Benedetti Alessandro
> Visiting card : http://about.me/alessandro_benedetti
>
> "Tyger, tyger burning bright
> In the forests of the night,
> What immortal hand or eye
> Could frame thy fearful symmetry?"
>
> William Blake - Songs of Experience -1794 England
>

Reply via email to