# Elasticsearch output does not support parent-child indexing

**URL:** <https://discuss.elastic.co/t/elasticsearch-output-does-not-support-parent-child-indexing/1669>\
**Category:** Logstash\
**Created:** [June 1, 2015, 10:13pm UTC](https://discuss.elastic.co/t/elasticsearch-output-does-not-support-parent-child-indexing/1669 "2015-06-01T22:13:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sumithub](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sumithub/32/461_2.png) [@sumithub](https://discuss.elastic.co/u/sumithub)\
**Post date:** [June 1, 2015, 10:13pm UTC](https://discuss.elastic.co/t/elasticsearch-output-does-not-support-parent-child-indexing/1669/1 "2015-06-01T22:13:10Z")

</div>

Hello,

This issue is already opened in git [https://github.com/logstash-plugins/logstash-output-elasticsearch/issues/129](https://github.com/logstash-plugins/logstash-output-elasticsearch/issues/129)

I'm facing the issue while indexing child docs. I tried the code as mentioned by Vordoom in above link, but didn't make it to work. Would appreciate if someone from the community could help in this regard.

Here's the mapping and code change suggested in the issue

Elasticsearch Version: 1.50  
Logstash Version: 1.5.0

Added below line of code inside elasticsearch.rb at line 426

parent = @parent ? event.sprintf(@parent) : nil  
buffer\_receive([event.sprintf(@action), { :\_id =\> document\_id, :\_index =\> index, :\_type =\> type, :\_routing =\> routing, :\_parent =\> parent }, event])

Installed the plugin after gem build inside standalone logstash

./bin/plugin install /home/vagrant/logstash-output-elasticsearch/logstash-output-elasticsearch-0.2.7-java.gem

Logstash configuration looks like below:

input {  
elasticsearch {  
hosts =\> ["localhost:9200"]  
index =\> "shop"  
size =\> 500  
scroll =\> "5m"  
docinfo =\> true  
}  
}

filter {  
mutate {  
remove\_field =\> ["@version"]  
remove\_field =\> ["@timestamp"]  
}  
}

output {  
elasticsearch {  
index =\> "shop\_logstash"  
host =\> "localhost"  
protocol =\> "http"  
index\_type =\> "%{[@metadata][\_type]}"  
document\_id =\> "%{[@metadata][\_id]}"  
workers =\> 1  
manage\_template =\> false  
}  
stdout { codec =\> rubydebug }  
}

Index Structure : Shop is parent and variation is child type

PUT /shop/cloth/\_mapping -d  
{  
"cloth" : {  
"properties" : {  
"name" : {"type" : "string"}  
}  
}  
}

PUT /shop/variation/\_mapping  
{  
"variation" : {  
"\_parent" : { "type" : "cloth" },  
"properties" : {  
"size" : {"type" : "string", "index" : "not\_analyzed"},  
"color" : {"type" : "string", "index" : "not\_analyzed"}  
}  
}  
}

Logstash debug output

Logstash startup completed  
output received {:event=\>{"name"=\>"Test shirt"}, :level=\>:debug, :file=\>"(eval)", :line=\>"50", :method=\>"output\_func"}  
{  
"name" =\> "Test shirt"  
}  
output received {:event=\>{"color"=\>"red", "size"=\>"XXL"}, :level=\>:debug, :file=\>"(eval)", :line=\>"50", :method=\>"output\_func"}  
{  
"color" =\> "red",  
"size" =\> "XXL"  
}  
output received {:event=\>{"color"=\>"black", "size"=\>"XL"}, :level=\>:debug, :file=\>"(eval)", :line=\>"50", :method=\>"output\_func"}  
{  
"color" =\> "black",  
"size" =\> "XL"  
}

Flushing output {:outgoing\_count=\>3, :time\_since\_last\_flush=\>0.049, :outgoing\_events=\>{nil=\>[["index", {:\_id=\>"1", :\_index=\>"shop\_logstash", :\_type=\>"cloth", :\_routing=\>nil, :parent=\>nil}, #"shop", "\_type"=\>"cloth", "\_id"=\>"1", "retry\_count"=\>0}, @lut={"[\_type]"=\>[{"\_index"=\>"shop", "\_type"=\>"cloth", "\_id"=\>"1", "retry\_count"=\>0}, "\_type"], "[\_id]"=\>[{"\_index"=\>"shop", "\_type"=\>"cloth", "\_id"=\>"1", "retry\_count"=\>0}, "\_id"]}\>, @cancelled=false, @data={"name"=\>"Test shirt"}, @metadata={"\_index"=\>"shop", "\_type"=\>"cloth", "\_id"=\>"1", "retry\_count"=\>0}, @accessors=#"Test shirt"}, @lut={"@version"=\>[{"name"=\>"Test shirt"}, "@version"], "@timestamp"=\>[{"name"=\>"Test shirt"}, "@timestamp"]}\>\>], ["index", {:\_id=\>"1000", :\_index=\>"shop\_logstash", :\_type=\>"variation", :\_routing=\>nil, :parent=\>nil}, #"shop", "\_type"=\>"variation", "\_id"=\>"1000", "retry\_count"=\>0}, @lut={"[\_type]"=\>[{"\_index"=\>"shop", "\_type"=\>"variation", "\_id"=\>"1000", "retry\_count"=\>0}, "\_type"], "[\_id]"=\>[{"\_index"=\>"shop", "\_type"=\>"variation", "\_id"=\>"1000", "retry\_count"=\>0}, "\_id"]}\>, @cancelled=false, @data={"color"=\>"red", "size"=\>"XXL"}, @metadata={"\_index"=\>"shop", "\_type"=\>"variation", "\_id"=\>"1000", "retry\_count"=\>0}, @accessors=#"red", "size"=\>"XXL"}, @lut={"@version"=\>[{"color"=\>"red", "size"=\>"XXL"}, "@version"], "@timestamp"=\>[{"color"=\>"red", "size"=\>"XXL"}, "@timestamp"]}\>\>], ["index", {:\_id=\>"1001", :\_index=\>"shop\_logstash", :\_type=\>"variation", :\_routing=\>nil, :parent=\>nil}, #"shop", "\_type"=\>"variation", "\_id"=\>"1001", "retry\_count"=\>0}, @lut={"[\_type]"=\>[{"\_index"=\>"shop", "\_type"=\>"variation", "\_id"=\>"1001", "retry\_count"=\>0}, "\_type"], "[\_id]"=\>[{"\_index"=\>"shop", "\_type"=\>"variation", "\_id"=\>"1001", "retry\_count"=\>0}, "\_id"]}\>, @cancelled=false, @data={"color"=\>"black", "size"=\>"XL"}, @metadata={"\_index"=\>"shop", "\_type"=\>"variation", "\_id"=\>"1001", "retry\_count"=\>0}, @accessors=#"black", "size"=\>"XL"}, @lut={"@version"=\>[{"color"=\>"black", "size"=\>"XL"}, "@version"], "@timestamp"=\>[{"color"=\>"black", "size"=\>"XL"}, "@timestamp"]}\>\>]]}, :batch\_timeout=\>1, :force=\>true, :final=\>true, :level=\>:debug, :file=\>"stud/buffer.rb", :line=\>"207", :method=\>"buffer\_flush"}  
failed action with response of 400, dropping action: ["index", {:\_id=\>"1000", :\_index=\>"shop\_logstash", :\_type=\>"variation", :\_routing=\>nil, :parent=\>nil}, #"shop", "\_type"=\>"variation", "\_id"=\>"1000", "retry\_count"=\>0}, @lut={"[\_type]"=\>[{"\_index"=\>"shop", "\_type"=\>"variation", "\_id"=\>"1000", "retry\_count"=\>0}, "\_type"], "[\_id]"=\>[{"\_index"=\>"shop", "\_type"=\>"variation", "\_id"=\>"1000", "retry\_count"=\>0}, "\_id"]}\>, @cancelled=false, @data={"color"=\>"red", "size"=\>"XXL"}, @metadata={"\_index"=\>"shop", "\_type"=\>"variation", "\_id"=\>"1000", "retry\_count"=\>0}, @accessors=#"red", "size"=\>"XXL"}, @lut={"@version"=\>[{"color"=\>"red", "size"=\>"XXL"}, "@version"], "@timestamp"=\>[{"color"=\>"red", "size"=\>"XXL"}, "@timestamp"]}\>\>] {:level=\>:warn, :file=\>"logstash/outputs/elasticsearch.rb", :line=\>"451", :method=\>"submit"}

failed action with response of 400, dropping action: ["index", {:\_id=\>"1001", :\_index=\>"shop\_logstash", :\_type=\>"variation", :\_routing=\>nil, :parent=\>nil}, #"shop", "\_type"=\>"variation", "\_id"=\>"1001", "retry\_count"=\>0}, @lut={"[\_type]"=\>[{"\_index"=\>"shop", "\_type"=\>"variation", "\_id"=\>"1001", "retry\_count"=\>0}, "\_type"], "[\_id]"=\>[{"\_index"=\>"shop", "\_type"=\>"variation", "\_id"=\>"1001", "retry\_count"=\>0}, "\_id"]}\>, @cancelled=false, @data={"color"=\>"black", "size"=\>"XL"}, @metadata={"\_index"=\>"shop", "\_type"=\>"variation", "\_id"=\>"1001", "retry\_count"=\>0}, @accessors=#"black", "size"=\>"XL"}, @lut={"@version"=\>[{"color"=\>"black", "size"=\>"XL"}, "@version"], "@timestamp"=\>[{"color"=\>"black", "size"=\>"XL"}, "@timestamp"]}\>\>] {:level=\>:warn, :file=\>"logstash/outputs/elasticsearch.rb", :line=\>"451", :method=\>"submit"}  
Shifting current elasticsearch client {:level=\>:debug, :file=\>"logstash/outputs/elasticsearch.rb", :line=\>"469", :method=\>"flush"}  
Switched current elasticsearch client to #0 at localhost {:level=\>:debug, :file=\>"logstash/outputs/elasticsearch.rb", :line=\>"519", :method=\>"shift\_client"}  
Plugin is finished {:plugin=\>, :level=\>:info, :file=\>"logstash/plugin.rb", :line=\>"61", :method=\>"finished"}  
Pipeline shutdown complete. {:level=\>:info, :file=\>"logstash/pipeline.rb", :line=\>"100", :method=\>"run"}  
Logstash shutdown completed

Just wondering if this issue is planned to be fixed in upcoming release? Thanks

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 2, 2015, 11:16am UTC](https://discuss.elastic.co/t/elasticsearch-output-does-not-support-parent-child-indexing/1669/2 "2015-06-02T11:16:24Z")

</div>

You'll likely get a better response on the GH issue 🙂

---

<div class="post-metadata">

**Author:** ![sumithub](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sumithub/32/461_2.png) [@sumithub](https://discuss.elastic.co/u/sumithub)\
**Post date:** [June 24, 2015, 8:54pm UTC](https://discuss.elastic.co/t/elasticsearch-output-does-not-support-parent-child-indexing/1669/3 "2015-06-24T20:54:39Z")

</div>

The issue is resolved and could be tracked here

> <https://github.com/logstash-plugins/logstash-output-elasticsearch/issues/129>

---

<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, 5:36am UTC](https://discuss.elastic.co/t/elasticsearch-output-does-not-support-parent-child-indexing/1669/4 "2017-07-06T05:36:35Z")

</div>


