Responses from the _index and _bulk APIs contain quite a bit of information. This information can be useful for troubleshooting requests or for implementing retry logic but can use considerable bandwidth. In this example, indexing a 32-byte document results in a 339-byte response (including headers):
If we update/index a document like below,
PUT elasticsearch_domain/more-movies/_doc/1
{"title": "Back to the Future"}
It'll return a response like below,
{
"_index": "more-movies",
"_type": "_doc",
"_id": "1",
"_version": 4,
"result": "updated",
"_shards": {
"total": 2,
"successful": 2,
"failed": 0
},
"_seq_no": 3,
"_primary_term": 1
}
Now if we use filter_path with our existing indexing process using _bulk
API
PUT elasticsearch_domain/more-movies/_doc/1?filter_path=result,_shards.total
{"title": "Back to the Future"}
Then Response will be like,
{
"result": "updated",
"_shards": {
"total": 2
}
}
So my question is how to use filter_path to filter out the response with Elasticsearch-python bulk API or streaming bulk API?
The same way as with the search function. Try it out like this:
elasticsearch.helpers.bulk(client, actions, stats_only=False, filter_path=["hits.hits.result","hits.hits._shards.total"])