BULK API : Malformed action/metadata line [3], expected START_OBJECT but found [VALUE_STRING]

前端 未结 3 1836
北海茫月
北海茫月 2020-12-20 11:36

Using Elasticsearch 5.5,getting the following error while posting this bulk request, unable to figure out what is wrong with the request.

\"type\": \"illegal         


        
相关标签:
3条回答
  • 2020-12-20 12:27

    Your resource objects have to be specified on a single line like this

    post /test322/type/_bulk
    { "index": {} }
    { "name": "Test1", "data": "This is my test data" }
    { "index": {} }
    { "name": "Test2", "data": "This is my test data2" }
    

    Which seems really stupid and unintuitive I know since resources don't have to be on a single line when you create them using PUT or POST for non-bulk operations.

    0 讨论(0)
  • 2020-12-20 12:27

    The following lines' format worked for me very well: Action, metadata, resource

    Note: Action should be CREATE to add a resource to the dataset and resource should be written inline, NOT new line.

      POST http://localhost:9200/access_log_index/access_log/_bulk
      { "create" : { "_index" : "test", "_type" : "_doc", "_id" : "11" } }
      {  "id":11, "tenant_id":682 , ... }
    
    0 讨论(0)
  • 2020-12-20 12:37

    You need to follow bulk format to successfully execute this. it expects the following JSON structure:

    action_and_meta_data\n
    optional_source\n
    action_and_meta_data\n
    optional_source\n
    ....
    action_and_meta_data\n
    optional_source\n
    

    For further reference, see this link https://www.elastic.co/guide/en/elasticsearch/reference/6.2/docs-bulk.html

    0 讨论(0)
提交回复
热议问题