Modifying documents in CouchDB river's script


(Petri Lehtinen) #1

It's currently possible to modify the document in the CouchDB river's
script. From documentation:

{
"type" : "couchdb",
"couchdb" : {
"script" : "ctx.doc.field1 = 'value1'"
}
}

This works fine as long as the assigned value is a string. Trying to assign
an array:

{
"type" : "couchdb",
"couchdb" : {
"script" : "ctx.doc.field1 = ['value1', 'value2']"
}
}

In this case, field1 is assigned an obscure string representation of the
array. I didn't try objects, but I'm assuming that all values are coerced to
strings.

Is there any chance this could be fixed? If not, this should at least be
documented.


(Shay Banon) #2

This is a bug of not converting the resulting computation from the native
javascript objects. Opened an issue:
https://github.com/elasticsearch/elasticsearch/issues/1225.

On Wed, Aug 10, 2011 at 1:17 PM, Petri Lehtinen petri@digip.org wrote:

It's currently possible to modify the document in the CouchDB river's
script. From documentation:

{
"type" : "couchdb",
"couchdb" : {
"script" : "ctx.doc.field1 = 'value1'"
}
}

This works fine as long as the assigned value is a string. Trying to assign
an array:

{
"type" : "couchdb",
"couchdb" : {
"script" : "ctx.doc.field1 = ['value1', 'value2']"
}
}

In this case, field1 is assigned an obscure string representation of the
array. I didn't try objects, but I'm assuming that all values are coerced to
strings.

Is there any chance this could be fixed? If not, this should at least be
documented.


(Petri Lehtinen) #3

Thanks for a fast fix.


(system) #4