[
https://issues.apache.org/jira/browse/SOLR-3862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13954853#comment-13954853
]
Erick Erickson edited comment on SOLR-3862 at 4/2/14 12:45 PM:
---------------------------------------------------------------
Right, it would look something like this:
{code}
Regular expressions can also be used to remove values by specifying
removeregex, as:
"activity" : {"removeregex" : "run.+"}
Given a document with a field having values
[run, running, runs runner], the above would leave only [run].
Multiple regexes can be specified, as
"activity" : {"removeregex" : ["run.+", "ran.*"] }
So a document with field values [run runner ran ransack] would be reduced to
[run]
There are two new commands, "replace" and "replaceregex"
"activity" : {"replace" : {"pat1" : "replacement1"} }
A document with "activity" of ["pat", "pat1", "pat1more"] would result in
["pat", "replacement1", "pat1more"]
Note that order is preserved. That is, if the pattern being replaced is the
third value in a multivalued field with 6 values, the replacement will also be
in the third position.
Multiple patterns and replacements can be specified, as
"activity" : {"replace" : [ {"pat1" : "replacement1"}, {"pat2" :
"replacement2"} ] }
replaceregex is similar, but all the "pat*" examples above may be regular
expressions, as
"activity" : {"replaceregex" : {"pat.+" : "replacement1"} }
and
"activity" : {"replaceregex" : [ {"pat.+" : "replacement1"}, {"part.*" :
"replacement2"} ] }
Currently, back references are _not_ supported.
Patterns and replacements are _not_ chained. That is, the following
"activity" : {"replaceregex" : [ {"pat.+" : "replacement1"}, {"repl.+" :
"replacement2"} ] }
applied to a field containing
["patterns"]
would yield ["replacement1"] rather than ["replacement2"]
{code}
Hmmmm, altogether I'm not sure how I feel about allowing multiple
replaceregex's to be specified, the syntax is kinda ugly.
I'm not particularly wedded to the regex stuff but I can imagine it to be
useful. I'd also be fine if the replace were left out.
was (Author: erickerickson):
Right, it would look something like this:
{code}
Regular expressions can also be used to remove values by specifying
removeregex, as:
"activity" : {"removeregex" : "run.+"}
Given a document with a field having values
[run, running, runs runner], the above would leave only [run].
Multiple regexes can be specified, as
"activity" : {"removeregex" : ["run.+", "ran.*"] }
So a document with field values [run runner ran ransack] would be reduced to
[run]
There are two new commands, "replace" and "replaceregex"
"activity" : {"replace" : {"pat1" : "replacement1"} }
A document with "activity" of ["pat", "pat1", "pat1more"] would result in
["pat", "replacement1", "pat1more"]
Note that order is preserved. That is, if the pattern being replaced is the
third value in a multivalued field with 6 values, the replacement will also be
in the third position.
Multiple patterns and replacements can be specified, as
"activity" : {"replace" : [ {"pat1" : "replacement1"}, {"pat2" :
"replacement2"} ] }
replaceregex is similar, but all the "pat*" examples above may be regular
expressions, as
"activity" : {"replaceregex" : {"pat.+" : "replacement1"} }
and
"activity" : {"replaceregex" : [ {"pat.+" : "replacement1"}, {"part.*" :
{replacement2"} ] }
Currently, back references are _not_ supported.
Patterns and replacements are _not_ chained. That is, the following
"activity" : {"replaceregex" : [ {"pat.+" : "replacement1"}, {"repl.+" :
{replacement2"} ] }
applied to a field containing
["patterns"]
would yield ["replacement1"] rather than ["replacement2"]
{code}
Hmmmm, altogether I'm not sure how I feel about allowing multiple
replaceregex's to be specified, the syntax is kinda ugly.
I'm not particularly wedded to the regex stuff but I can imagine it to be
useful. I'd also be fine if the replace were left out.
> 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]