How do you send bulk inserts with no ids to elasticsearch











up vote
0
down vote

favorite












I'm trying to use the bulk inset api for elastic search. I would like to insert documents with auto generated IDs but I'm just getting errors no matter what i try.



Here are a few example efforts:



http://localhost:9200/_bulk
{"create": {"_index": "test", "_type": "_doc"} }
{"user": "kimchy", "post_date": "2002-11-15T14:12:12", "message": "trying out Elasticsearch"}


Both put and post give the error:



{
"error": {
"root_cause": [
{
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: an id must be provided if version type or value are set;"
}
],
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: an id must be provided if version type or value are set;"
},
"status": 400
}


If i remove _type _doc i get the following error:



{
"error": {
"root_cause": [
{
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: type is missing;2: an id is required for a CREATE operation;3: an id must be provided if version type or value are set;"
}
],
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: type is missing;2: an id is required for a CREATE operation;3: an id must be provided if version type or value are set;"
},
"status": 400
}


I'm using elastic search 6.4.2 via docker



~ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
elasticsearch 6.4.2 e47ebd7ec3ee 7 weeks ago 828MB


Currently sending requests via postman










share|improve this question


























    up vote
    0
    down vote

    favorite












    I'm trying to use the bulk inset api for elastic search. I would like to insert documents with auto generated IDs but I'm just getting errors no matter what i try.



    Here are a few example efforts:



    http://localhost:9200/_bulk
    {"create": {"_index": "test", "_type": "_doc"} }
    {"user": "kimchy", "post_date": "2002-11-15T14:12:12", "message": "trying out Elasticsearch"}


    Both put and post give the error:



    {
    "error": {
    "root_cause": [
    {
    "type": "action_request_validation_exception",
    "reason": "Validation Failed: 1: an id must be provided if version type or value are set;"
    }
    ],
    "type": "action_request_validation_exception",
    "reason": "Validation Failed: 1: an id must be provided if version type or value are set;"
    },
    "status": 400
    }


    If i remove _type _doc i get the following error:



    {
    "error": {
    "root_cause": [
    {
    "type": "action_request_validation_exception",
    "reason": "Validation Failed: 1: type is missing;2: an id is required for a CREATE operation;3: an id must be provided if version type or value are set;"
    }
    ],
    "type": "action_request_validation_exception",
    "reason": "Validation Failed: 1: type is missing;2: an id is required for a CREATE operation;3: an id must be provided if version type or value are set;"
    },
    "status": 400
    }


    I'm using elastic search 6.4.2 via docker



    ~ docker images
    REPOSITORY TAG IMAGE ID CREATED SIZE
    elasticsearch 6.4.2 e47ebd7ec3ee 7 weeks ago 828MB


    Currently sending requests via postman










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm trying to use the bulk inset api for elastic search. I would like to insert documents with auto generated IDs but I'm just getting errors no matter what i try.



      Here are a few example efforts:



      http://localhost:9200/_bulk
      {"create": {"_index": "test", "_type": "_doc"} }
      {"user": "kimchy", "post_date": "2002-11-15T14:12:12", "message": "trying out Elasticsearch"}


      Both put and post give the error:



      {
      "error": {
      "root_cause": [
      {
      "type": "action_request_validation_exception",
      "reason": "Validation Failed: 1: an id must be provided if version type or value are set;"
      }
      ],
      "type": "action_request_validation_exception",
      "reason": "Validation Failed: 1: an id must be provided if version type or value are set;"
      },
      "status": 400
      }


      If i remove _type _doc i get the following error:



      {
      "error": {
      "root_cause": [
      {
      "type": "action_request_validation_exception",
      "reason": "Validation Failed: 1: type is missing;2: an id is required for a CREATE operation;3: an id must be provided if version type or value are set;"
      }
      ],
      "type": "action_request_validation_exception",
      "reason": "Validation Failed: 1: type is missing;2: an id is required for a CREATE operation;3: an id must be provided if version type or value are set;"
      },
      "status": 400
      }


      I'm using elastic search 6.4.2 via docker



      ~ docker images
      REPOSITORY TAG IMAGE ID CREATED SIZE
      elasticsearch 6.4.2 e47ebd7ec3ee 7 weeks ago 828MB


      Currently sending requests via postman










      share|improve this question













      I'm trying to use the bulk inset api for elastic search. I would like to insert documents with auto generated IDs but I'm just getting errors no matter what i try.



      Here are a few example efforts:



      http://localhost:9200/_bulk
      {"create": {"_index": "test", "_type": "_doc"} }
      {"user": "kimchy", "post_date": "2002-11-15T14:12:12", "message": "trying out Elasticsearch"}


      Both put and post give the error:



      {
      "error": {
      "root_cause": [
      {
      "type": "action_request_validation_exception",
      "reason": "Validation Failed: 1: an id must be provided if version type or value are set;"
      }
      ],
      "type": "action_request_validation_exception",
      "reason": "Validation Failed: 1: an id must be provided if version type or value are set;"
      },
      "status": 400
      }


      If i remove _type _doc i get the following error:



      {
      "error": {
      "root_cause": [
      {
      "type": "action_request_validation_exception",
      "reason": "Validation Failed: 1: type is missing;2: an id is required for a CREATE operation;3: an id must be provided if version type or value are set;"
      }
      ],
      "type": "action_request_validation_exception",
      "reason": "Validation Failed: 1: type is missing;2: an id is required for a CREATE operation;3: an id must be provided if version type or value are set;"
      },
      "status": 400
      }


      I'm using elastic search 6.4.2 via docker



      ~ docker images
      REPOSITORY TAG IMAGE ID CREATED SIZE
      elasticsearch 6.4.2 e47ebd7ec3ee 7 weeks ago 828MB


      Currently sending requests via postman







      elasticsearch






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 21 hours ago









      Damo

      627422




      627422
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          If you want automatic id creation simply use index instead of create:



          change this
          |
          v
          {"index": {"_index": "test", "_type": "_doc"} }
          {"user": "kimchy", "post_date": "2002-11-15T14:12:12", "message": "trying out Elasticsearch"}





          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371373%2fhow-do-you-send-bulk-inserts-with-no-ids-to-elasticsearch%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote



            accepted










            If you want automatic id creation simply use index instead of create:



            change this
            |
            v
            {"index": {"_index": "test", "_type": "_doc"} }
            {"user": "kimchy", "post_date": "2002-11-15T14:12:12", "message": "trying out Elasticsearch"}





            share|improve this answer

























              up vote
              1
              down vote



              accepted










              If you want automatic id creation simply use index instead of create:



              change this
              |
              v
              {"index": {"_index": "test", "_type": "_doc"} }
              {"user": "kimchy", "post_date": "2002-11-15T14:12:12", "message": "trying out Elasticsearch"}





              share|improve this answer























                up vote
                1
                down vote



                accepted







                up vote
                1
                down vote



                accepted






                If you want automatic id creation simply use index instead of create:



                change this
                |
                v
                {"index": {"_index": "test", "_type": "_doc"} }
                {"user": "kimchy", "post_date": "2002-11-15T14:12:12", "message": "trying out Elasticsearch"}





                share|improve this answer












                If you want automatic id creation simply use index instead of create:



                change this
                |
                v
                {"index": {"_index": "test", "_type": "_doc"} }
                {"user": "kimchy", "post_date": "2002-11-15T14:12:12", "message": "trying out Elasticsearch"}






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 20 hours ago









                Val

                97.8k6124163




                97.8k6124163






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371373%2fhow-do-you-send-bulk-inserts-with-no-ids-to-elasticsearch%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Wiesbaden

                    Marschland

                    Dieringhausen