Elasticsearch bulk index api via rest endpoint

后端 未结 2 689
死守一世寂寞
死守一世寂寞 2020-12-11 02:59

Here is my request:

POST /_bulk
{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"1\" } }
{\"firstname\":\"first_name1\",\"lastname\"         


        
相关标签:
2条回答
  • 2020-12-11 03:44

    As Samyak says in his comment, "don't repeat yourself". This syntax is tidier.

    post /test/_type/_bulk
    { "index": {}}
    {"firstname":"first_name1","lastname":"last_name1"}
    { "index": { }}
    { "name": "Test2", "data": "This is my test data2" }
    
    0 讨论(0)
  • 2020-12-11 04:01

    You're simply missing an action line for the second and third documents, try like this:

    POST /_bulk
    { "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
    {"firstname":"first_name1","lastname":"last_name1"}
    { "index" : { "_index" : "test", "_type" : "type1", "_id" : "2" } }
    {"firstname":"first_name2","lastname":"last_name2"}
    { "index" : { "_index" : "test", "_type" : "type1", "_id" : "3" } }
    {"firstname":"first_name3","lastname":"last_name3"}
    
    0 讨论(0)
提交回复
热议问题