Elasticsearch の bulk リクエストにおいて、 join データのために routing を指定する方法
Published: 2021/12/15
例えば、現状最新版である 7.16 の Elasticsearch ドキュメントの bulk についての説明 において、 join
フィールドを利用する際、子供側に指定が必要な routing パラメータをどう指定したら良いか分からなかったので、それについてのメモ。
Why doesn't routing work with ElasticSearch Bulk API?
I am setting a Bulk request to ElasticSearch and specifying the shard to route to. But when I run it, the documents get sent to different shards. Is this a bug in ElasticSEarch bulk? it works whe...
stackoverflow.com

上記の Stack Overflow のスレッドにあるように、
- 6.1 より前:
{"index":{"_index":"index-name", "_id":"id-name", "_routing":"parent-id"}}
- 6.1 以降:
{"index":{"_index":"index-name", "_id":"id-name", "routing":"parent-id"}}
のように、 "_index"
や "_id"
の隣に "routing"
を付与することで、 routing の指定が可能。
Tags: elasticsearch
関連記事
Elasticsearch で join フィールドの値でフィルタする方法
2022/1/10
Elasticsearch-rails で接続先情報を設定する方法
2021/12/18