[ 
https://issues.apache.org/jira/browse/SOLR-3862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13954665#comment-13954665
 ] 

Yonik Seeley commented on SOLR-3862:
------------------------------------

bq. Could you please let me know where to update the API documentation and I 
will do that?

Updating actual documentation wouldn't be appropriate since nothing has been 
committed yet.

My API comment was because Erick indicated he was going to commit a patch, but 
I couldn't tell what the intent of the patch was.  It's hard to review a patch 
when you don't know what the patch is trying to do.  I took a quick look at the 
code, and was confused by seeing regular expressions, and apparently two 
commands: "replace" and "remove".

For something like this, implementation is easy to fix later, interface is much 
less so.  So lets take a minute to talk about what interface we want, and give 
examples.

Example of interface as I understand it (in JSON).  It's just like the other 
"atomic update" field modifiers:
{code}
A field like so will add a value (this is existing functionality):
 "cat"  : {"add":"Cyberpunk"}
A field like so will remove all values that match the given pattern "Cyberpunk" 
(this patch implements):
 "cat"  : {"remove":"Cyberpunk"}
Note that the specified value is a regular expression, so the following will 
remove all values starting with "Cyber"
 "cat"  : {"remove":"Cyber.*"}
The regular expression must match the whole value for that value to be removed.

Full command:
curl http://localhost:8983/solr/update -H 'Content-type:application/json' -d '
[
 {"id"    : "book1",
  "cat"   : {"remove":"Cyberpunk"}
 }
]'
{code}


Questions:
 - Do we want a way to specify the removal of multiple values?  
  Perhaps "remove" : [ "A","B","C" ]
 - What are the downsides to using regex?  Someone may not realize that the 
values being used are regular expressions until they are in production and 
values that accidentally have wildcards in them are used?  Or they may simply 
forget to do wildcard escaping code since everything would "just work" until 
they did encounter them?
 - Perhaps we want a separate way to specify "value" vs "regex".  I assume 
"value" will  be a much more common usecase than regex (although I do like the 
power that regex brings).




> add "remove" as update option for atomically removing a value from a 
> multivalued field
> --------------------------------------------------------------------------------------
>
>                 Key: SOLR-3862
>                 URL: https://issues.apache.org/jira/browse/SOLR-3862
>             Project: Solr
>          Issue Type: Improvement
>          Components: SolrCloud
>    Affects Versions: 4.0-BETA
>            Reporter: Jim Musil
>            Assignee: Erick Erickson
>         Attachments: SOLR-3862-2.patch, SOLR-3862-3.patch, SOLR-3862-4.patch, 
> SOLR-3862.patch, SOLR-3862.patch
>
>
> Currently you can atomically "add" a value to a multivalued field. It would 
> be useful to be able to "remove" a value from a multivalued field. 
> When you "set" a multivalued field to null, it destroys all values.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to