How can i get auto increment id by using elasticsearch.js API?

The JS create API must set id, and how can i do like follow?Is there any other API I can use?

The JS create API:
client.create({
index: 'myindex',
type: 'mytype',
id: '1',
body: {
title: 'Test 1',
tags: ['y', 'z'],
published: true,
published_at: '2013-01-01',
counter: 1
}
}, function (error, response) {
// ...
});

which i want to do:
POST twitter/_doc/
{
"user" : "kimchy",
"post_date" : "2009-11-15T14:12:12",
"message" : "trying out Elasticsearch"
}

Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.
Please update your post.

I wonder if this would work:

client.index({
  index: 'myindex',
  type: 'doc',
  // id: '1',
  body: {
    title: 'Test 1',
    tags: ['y', 'z'],
    published: true,
  }
}, function (error, response) {

});

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.