# Couchdb river can't know to insert parent param

**URL:** <https://discuss.elastic.co/t/couchdb-river-cant-know-to-insert-parent-param/7026>\
**Category:** Elasticsearch\
**Created:** [March 16, 2012, 11:05am UTC](https://discuss.elastic.co/t/couchdb-river-cant-know-to-insert-parent-param/7026 "2012-03-16T11:05:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![inlier\_2](https://avatars.discourse-cdn.com/v4/letter/i/cdc98d/32.png) [@inlier\_2](https://discuss.elastic.co/u/inlier_2)\
**Post date:** [March 16, 2012, 11:05am UTC](https://discuss.elastic.co/t/couchdb-river-cant-know-to-insert-parent-param/7026/1 "2012-03-16T11:05:09Z")

</div>

I query parent child like this

# Mapping

curl -XPOST "[http://localhost:9200/new\_index](http://localhost:9200/new_index)" -d '{  
"mappings": {  
"record": {  
"properties": {  
"num": {  
"type": "long"  
}  
}  
},  
"field": {  
"\_parent": {  
"type": "record"  
},  
"properties": {  
"content": {  
"type": "string",  
"index": "not\_analyzed",  
"store": "yes"  
}  
}  
}  
}  
}'

# Index data

curl -XPUT '[http://localhost:9200/new\_type/record/1](http://localhost:9200/new_type/record/1)' -d '{ //  
Please notice id=1  
"num" : "frank"  
}'  
curl -XPUT '[http://localhost:9200/submissions/field/1?parent=1](http://localhost:9200/submissions/field/1?parent=1)' -d  
'{ // Please notice insert parent param =1  
"content" : "noodles",  
"mnemonic" : "ndl"  
}'  
curl -XPUT '[http://localhost:9200/submissions/field/2?parent=1](http://localhost:9200/submissions/field/2?parent=1)' -d  
'{ // Please notice insert parent param =1  
"content" : "fish",  
"mnemonic" : "fsh"  
}'

I use the couchdb river to automatic tranfer data from database to  
Elasticsearch index. I got problem when must insert parent param ( I  
noticed above). How can I config the river to insert parent param.  
Maybe I think config in this script. Help me please.  
curl -XPUT '[http://localhost:9200/\_river/animal/\_meta](http://localhost:9200/_river/animal/_meta)' -d '{  
"type" : "couchdb",  
"couchdb" : {  
"host" : "localhost",  
"port" : 5984,  
"db" : "my\_couch\_db",  
"filter" : "Field/fieldfilters",  
},  
"index" : {  
"index" : "new\_index",  
"type" : "field",  
"bulk\_size" : "1000",  
"bulk\_timeout" : "10ms"  
}  
}'

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 17, 2012, 10:04am UTC](https://discuss.elastic.co/t/couchdb-river-cant-know-to-insert-parent-param/7026/2 "2012-03-17T10:04:28Z")

</div>

Yea, you can use a script and update ctx.\_parent field.

On Fri, Mar 16, 2012 at 1:05 PM, inlier [hiquocthang@gmail.com](mailto:hiquocthang@gmail.com) wrote:

> I query parent child like this
> 
> # Mapping
> 
> curl -XPOST "[http://localhost:9200/new\_index](http://localhost:9200/new_index)" -d '{  
> "mappings": {  
> "record": {  
> "properties": {  
> "num": {  
> "type": "long"  
> }  
> }  
> },  
> "field": {  
> "\_parent": {  
> "type": "record"  
> },  
> "properties": {  
> "content": {  
> "type": "string",  
> "index": "not\_analyzed",  
> "store": "yes"  
> }  
> }  
> }  
> }  
> }'
> 
> # Index data
> 
> curl -XPUT '[http://localhost:9200/new\_type/record/1](http://localhost:9200/new_type/record/1)' -d '{ //  
> Please notice id=1  
> "num" : "frank"  
> }'  
> curl -XPUT '[http://localhost:9200/submissions/field/1?parent=1](http://localhost:9200/submissions/field/1?parent=1)' -d  
> '{ // Please notice insert parent param =1  
> "content" : "noodles",  
> "mnemonic" : "ndl"  
> }'  
> curl -XPUT '[http://localhost:9200/submissions/field/2?parent=1](http://localhost:9200/submissions/field/2?parent=1)' -d  
> '{ // Please notice insert parent param =1  
> "content" : "fish",  
> "mnemonic" : "fsh"  
> }'
> 
> I use the couchdb river to automatic tranfer data from database to  
> Elasticsearch index. I got problem when must insert parent param ( I  
> noticed above). How can I config the river to insert parent param.  
> Maybe I think config in this script. Help me please.  
> curl -XPUT '[http://localhost:9200/\_river/animal/\_meta](http://localhost:9200/_river/animal/_meta)' -d '{  
> "type" : "couchdb",  
> "couchdb" : {  
> "host" : "localhost",  
> "port" : 5984,  
> "db" : "my\_couch\_db",  
> "filter" : "Field/fieldfilters",  
> },  
> "index" : {  
> "index" : "new\_index",  
> "type" : "field",  
> "bulk\_size" : "1000",  
> "bulk\_timeout" : "10ms"  
> }  
> }'

---

<div class="post-metadata">

**Author:** ![inlier\_2](https://avatars.discourse-cdn.com/v4/letter/i/cdc98d/32.png) [@inlier\_2](https://discuss.elastic.co/u/inlier_2)\
**Post date:** [March 19, 2012, 6:58am UTC](https://discuss.elastic.co/t/couchdb-river-cant-know-to-insert-parent-param/7026/3 "2012-03-19T06:58:34Z")

</div>

have any one the ideas? please say clearly !

On Mar 17, 5:04 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> Yea, you can use a script and update ctx.\_parent field.
> 
> On Fri, Mar 16, 2012 at 1:05 PM, inlier [hiquocth...@gmail.com](mailto:hiquocth...@gmail.com) wrote:
> 
> > I query parent child like this
> > 
> > # Mapping
> > 
> > curl -XPOST "[http://localhost:9200/new\_index](http://localhost:9200/new_index)" -d '{  
> > "mappings": {  
> > "record": {  
> > "properties": {  
> > "num": {  
> > "type": "long"  
> > }  
> > }  
> > },  
> > "field": {  
> > "\_parent": {  
> > "type": "record"  
> > },  
> > "properties": {  
> > "content": {  
> > "type": "string",  
> > "index": "not\_analyzed",  
> > "store": "yes"  
> > }  
> > }  
> > }  
> > }  
> > }'
> 
> > # Index data
> > 
> > curl -XPUT '[http://localhost:9200/new\_type/record/1'-d](http://localhost:9200/new_type/record/1'-d) '{ //  
> > Please notice id=1  
> > "num" : "frank"  
> > }'  
> > curl -XPUT '[http://localhost:9200/submissions/field/1?parent=1'-d](http://localhost:9200/submissions/field/1?parent=1'-d)  
> > '{ // Please notice insert parent param =1  
> > "content" : "noodles",  
> > "mnemonic" : "ndl"  
> > }'  
> > curl -XPUT '[http://localhost:9200/submissions/field/2?parent=1'-d](http://localhost:9200/submissions/field/2?parent=1'-d)  
> > '{ // Please notice insert parent param =1  
> > "content" : "fish",  
> > "mnemonic" : "fsh"  
> > }'
> 
> > I use the couchdb river to automatic tranfer data from database to  
> > Elasticsearch index. I got problem when must insert parent param ( I  
> > noticed above). How can I config the river to insert parent param.  
> > Maybe I think config in this script. Help me please.  
> > curl -XPUT '[http://localhost:9200/\_river/animal/\_meta'-d](http://localhost:9200/_river/animal/_meta'-d) '{  
> > "type" : "couchdb",  
> > "couchdb" : {  
> > "host" : "localhost",  
> > "port" : 5984,  
> > "db" : "my\_couch\_db",  
> > "filter" : "Field/fieldfilters",  
> > },  
> > "index" : {  
> > "index" : "new\_index",  
> > "type" : "field",  
> > "bulk\_size" : "1000",  
> > "bulk\_timeout" : "10ms"  
> > }  
> > }'

---

<div class="post-metadata">

**Author:** ![inlier\_2](https://avatars.discourse-cdn.com/v4/letter/i/cdc98d/32.png) [@inlier\_2](https://discuss.elastic.co/u/inlier_2)\
**Post date:** [March 19, 2012, 11:11am UTC](https://discuss.elastic.co/t/couchdb-river-cant-know-to-insert-parent-param/7026/4 "2012-03-19T11:11:39Z")

</div>

I set the script in river  
"script" : "if (ctx.\_source.parent\_field\_id) ctx.\_parent =  
ctx.\_source.parent\_field\_id" but it not run.

---

<div class="post-metadata">

**Author:** ![inlier\_2](https://avatars.discourse-cdn.com/v4/letter/i/cdc98d/32.png) [@inlier\_2](https://discuss.elastic.co/u/inlier_2)\
**Post date:** [March 20, 2012, 10:42am UTC](https://discuss.elastic.co/t/couchdb-river-cant-know-to-insert-parent-param/7026/5 "2012-03-20T10:42:32Z")

</div>

anyone answers?

---

<div class="post-metadata">

**Author:** ![ganican](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ganican/32/2435_2.png) [@ganican](https://discuss.elastic.co/u/ganican)\
**Post date:** [March 7, 2013, 10:37pm UTC](https://discuss.elastic.co/t/couchdb-river-cant-know-to-insert-parent-param/7026/6 "2013-03-07T22:37:31Z")

</div>

Hi Shay,

I used the following script to set parent for my couchdb doc with a field  
"parent":

_if(ctx.doc.parent) ctx.\_parent = ctx.doc.parent_

But some how I didnt see any field "\_parent" in the actual index. Is the  
above script right syntax?

Thanks.

On Saturday, March 17, 2012 5:04:28 AM UTC-5, kimchy wrote:

> Yea, you can use a script and update ctx.\_parent field.
> 
> On Fri, Mar 16, 2012 at 1:05 PM, inlier \<[hiquo...@gmail.com](mailto:hiquo...@gmail.com) \<javascript:\>\>wrote:
> 
> > I query parent child like this
> > 
> > # Mapping
> > 
> > curl -XPOST "[http://localhost:9200/new\_index](http://localhost:9200/new_index)" -d '{  
> > "mappings": {  
> > "record": {  
> > "properties": {  
> > "num": {  
> > "type": "long"  
> > }  
> > }  
> > },  
> > "field": {  
> > "\_parent": {  
> > "type": "record"  
> > },  
> > "properties": {  
> > "content": {  
> > "type": "string",  
> > "index": "not\_analyzed",  
> > "store": "yes"  
> > }  
> > }  
> > }  
> > }  
> > }'
> > 
> > # Index data
> > 
> > curl -XPUT '[http://localhost:9200/new\_type/record/1](http://localhost:9200/new_type/record/1)' -d '{ //  
> > Please notice id=1  
> > "num" : "frank"  
> > }'  
> > curl -XPUT '[http://localhost:9200/submissions/field/1?parent=1](http://localhost:9200/submissions/field/1?parent=1)' -d  
> > '{ // Please notice insert parent param =1  
> > "content" : "noodles",  
> > "mnemonic" : "ndl"  
> > }'  
> > curl -XPUT '[http://localhost:9200/submissions/field/2?parent=1](http://localhost:9200/submissions/field/2?parent=1)' -d  
> > '{ // Please notice insert parent param =1  
> > "content" : "fish",  
> > "mnemonic" : "fsh"  
> > }'
> > 
> > I use the couchdb river to automatic tranfer data from database to  
> > Elasticsearch index. I got problem when must insert parent param ( I  
> > noticed above). How can I config the river to insert parent param.  
> > Maybe I think config in this script. Help me please.  
> > curl -XPUT '[http://localhost:9200/\_river/animal/\_meta](http://localhost:9200/_river/animal/_meta)' -d '{  
> > "type" : "couchdb",  
> > "couchdb" : {  
> > "host" : "localhost",  
> > "port" : 5984,  
> > "db" : "my\_couch\_db",  
> > "filter" : "Field/fieldfilters",  
> > },  
> > "index" : {  
> > "index" : "new\_index",  
> > "type" : "field",  
> > "bulk\_size" : "1000",  
> > "bulk\_timeout" : "10ms"  
> > }  
> > }'

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![ganican](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ganican/32/2435_2.png) [@ganican](https://discuss.elastic.co/u/ganican)\
**Post date:** [March 18, 2013, 10:57pm UTC](https://discuss.elastic.co/t/couchdb-river-cant-know-to-insert-parent-param/7026/7 "2013-03-18T22:57:54Z")

</div>

Hello inlier,

Did you find an answer to this question?

Thanks

On Tuesday, March 20, 2012 5:42:32 AM UTC-5, inlier wrote:

> anyone answers?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:45am UTC](https://discuss.elastic.co/t/couchdb-river-cant-know-to-insert-parent-param/7026/8 "2017-07-06T02:45:59Z")

</div>


