No handler found for uri [///] and method [PUT]

后端 未结 1 1674
感情败类
感情败类 2021-02-18 14:19

I\'m trying to make a raw NodeJS http request to my elasticsearch index using the insert document api\'s auto increment id feature.

So this works with curl:

1条回答
  •  清歌不尽
    2021-02-18 14:24

    The problem here is the way POST and PUT works, when you use POST, _id is optional, ES will generate a unique _id for you every time.

    Here you are using PUT so _id is required, ES will either create a new document with that id or it will update the document with that id if it exists. You can read more about this.

    Try indexing with POST request as you did with curl if you dont want to specify id

    var options = {
      protocol: 'http:',
      hostname: 'host',
      port: 3333,
      path: '/catalog/products/',
      method: 'POST'                  <--- specify method
    }
    

    Hope this helps!

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