# Bulk and IndexRequest constructor

**URL:** <https://discuss.elastic.co/t/bulk-and-indexrequest-constructor/9120>\
**Category:** Elasticsearch\
**Created:** [September 24, 2012, 4:13pm UTC](https://discuss.elastic.co/t/bulk-and-indexrequest-constructor/9120 "2012-09-24T16:13:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 24, 2012, 4:13pm UTC](https://discuss.elastic.co/t/bulk-and-indexrequest-constructor/9120/1 "2012-09-24T16:13:22Z")

</div>

Heya,

I'm looking at ES source code and here is what I can read in IndexRequest.java  
class:

/\*\*

- Constructs a new index request against the specific index. The {@link  
#type(String)},
- {@link #id(String)} and {@link #source(byte[])} must be set.  
\*/  
public IndexRequest(String index) {  
this.index = index;  
}

Is the Javadoc correct? I'm almost sure that id is not mandatory and will be  
generated by Elasticsearch.

Can someone confirm that?

Thanks  
David.

--  
David Pilato  
[http://www.scrutmydocs.org/](http://www.scrutmydocs.org/)  
[http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

---

<div class="post-metadata">

**Author:** ![ferhatsb](https://avatars.discourse-cdn.com/v4/letter/f/977dab/32.png) [@ferhatsb](https://discuss.elastic.co/u/ferhatsb)\
**Post date:** [September 25, 2012, 8:00am UTC](https://discuss.elastic.co/t/bulk-and-indexrequest-constructor/9120/2 "2012-09-25T08:00:52Z")

</div>

Hi David,

I have tested it via rest interface, and ES generates id if it is not  
provided.

KR,  
Ferhat

[http://searchbox.io](http://searchbox.io)  
[ferhat@searchbox.io](mailto:ferhat@searchbox.io)

On Monday, September 24, 2012 7:13:28 PM UTC+3, David Pilato wrote:

> Heya,
> 
> I'm looking at ES source code and here is what I can read  
> in IndexRequest.java class:
> 
> /\*\*
> 
> - Constructs a new index request against the specific index. The {@link  
> #type(String)},
> - {@link #id(String)} and {@link #source(byte)} must be set.  
> \*/  
> public IndexRequest(String index) {  
> this.index = index;  
> }
> 
> Is the Javadoc correct? I'm almost sure that id is not mandatory and will  
> be generated by Elasticsearch.
> 
> Can someone confirm that?  
> Thanks  
> David.
> 
> --  
> David Pilato  
> [http://www.scrutmydocs.org/](http://www.scrutmydocs.org/)  
> [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

---

<div class="post-metadata">

**Author:** ![ferhatsb](https://avatars.discourse-cdn.com/v4/letter/f/977dab/32.png) [@ferhatsb](https://discuss.elastic.co/u/ferhatsb)\
**Post date:** [September 25, 2012, 8:01am UTC](https://discuss.elastic.co/t/bulk-and-indexrequest-constructor/9120/3 "2012-09-25T08:01:49Z")

</div>

Hi David,

I have tested it via rest interface, and ES generates id if it is not  
provided.

KR,  
Ferhat

[http://searchbox.io](http://searchbox.io)

On Monday, September 24, 2012 7:13:28 PM UTC+3, David Pilato wrote:

> Heya,
> 
> I'm looking at ES source code and here is what I can read  
> in IndexRequest.java class:
> 
> /\*\*
> 
> - Constructs a new index request against the specific index. The {@link  
> #type(String)},
> - {@link #id(String)} and {@link #source(byte)} must be set.  
> \*/  
> public IndexRequest(String index) {  
> this.index = index;  
> }
> 
> Is the Javadoc correct? I'm almost sure that id is not mandatory and will  
> be generated by Elasticsearch.
> 
> Can someone confirm that?  
> Thanks  
> David.
> 
> --  
> David Pilato  
> [http://www.scrutmydocs.org/](http://www.scrutmydocs.org/)  
> [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 25, 2012, 8:18am UTC](https://discuss.elastic.co/t/bulk-and-indexrequest-constructor/9120/4 "2012-09-25T08:18:53Z")

</div>

Thanks Ferhat.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 25 sept. 2012 à 10:00, ferhatsb [ferhat.sobay@gmail.com](mailto:ferhat.sobay@gmail.com) a écrit :

> Hi David,
> 
> I have tested it via rest interface, and ES generates id if it is not provided.
> 
> KR,  
> Ferhat
> 
> [http://searchbox.io](http://searchbox.io)  
> [ferhat@searchbox.io](mailto:ferhat@searchbox.io)
> 
> On Monday, September 24, 2012 7:13:28 PM UTC+3, David Pilato wrote:  
> Heya,
> 
> I'm looking at ES source code and here is what I can read in IndexRequest.java class:  
> /\*\*
> 
> - Constructs a new index request against the specific index. The {@link #type(String)},
> - {@link #id(String)} and {@link #source(byte)} must be set.  
> \*/  
> public IndexRequest(String index) {  
> this.index = index;  
> }
> 
> Is the Javadoc correct? I'm almost sure that id is not mandatory and will be generated by Elasticsearch.
> 
> Can someone confirm that?
> 
> Thanks  
> David.
> 
> ## -- David Pilato [http://www.scrutmydocs.org/](http://www.scrutmydocs.org/) [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/) Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 25, 2012, 11:53am UTC](https://discuss.elastic.co/t/bulk-and-indexrequest-constructor/9120/5 "2012-09-25T11:53:30Z")

</div>

I sent a pull request to be able to do it in Java:  
[Add constructor IndexRequest(String index, String type) and fix javadoc by dadoonet · Pull Request #2287 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/pull/2287)  
[https://github.com/elasticsearch/elasticsearch/pull/2287](https://github.com/elasticsearch/elasticsearch/pull/2287)

Le 25 septembre 2012 à 10:18, David Pilato [david@pilato.fr](mailto:david@pilato.fr) a écrit :

> Thanks Ferhat.
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 25 sept. 2012 à 10:00, ferhatsb \< [ferhat.sobay@gmail.com](mailto:ferhat.sobay@gmail.com)  
> [mailto:ferhat.sobay@gmail.com](mailto:ferhat.sobay@gmail.com) \> a écrit :
> 
> ```
> > > Hi David,
> 
> ```
> 
> > ```
> > I have tested it via rest interface, and ES generates id if it is not
> > 
> > ```
> > 
> > provided.
> > 
> > ```
> > KR,
> > Ferhat
> > 
> > http://searchbox.io <http://searchbox.io>
> > ferhat@searchbox.io <mailto:ferhat@searchbox.io>
> > 
> > On Monday, September 24, 2012 7:13:28 PM UTC+3, David Pilato wrote:
> > > > > Heya,
> > 
> > ```
> > 
> > > ```
> > > I'm looking at ES source code and here is what I can read in
> > > 
> > > ```
> > > 
> > > IndexRequest.java class:
> > > 
> > > ```
> > > /**
> > > * Constructs a new index request against the specific index. The
> > > 
> > > ```
> > > 
> > > {@link #type(String)},  
> > > \* {@link #id(String)} and {@link #source(byte)} must be set.  
> > > \*/  
> > > public IndexRequest(String index) {  
> > > this.index = index;  
> > > }
> > > 
> > > ```
> > > Is the Javadoc correct? I'm almost sure that id is not mandatory
> > > 
> > > ```
> > > 
> > > and will be generated by Elasticsearch.
> > > 
> > > ```
> > > Can someone confirm that?
> > > 
> > > Thanks
> > > David.
> > > 
> > > --
> > > David Pilato
> > > http://www.scrutmydocs.org/ <http://www.scrutmydocs.org/>
> > > http://dev.david.pilato.fr/ <http://dev.david.pilato.fr/>
> > > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > > > > 
> > > 
> > > ```
> > 
> > ```
> > --
> > 
> > ```
> > 
> > >

--

--  
David Pilato  
[http://www.scrutmydocs.org/](http://www.scrutmydocs.org/)  
[http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:11am UTC](https://discuss.elastic.co/t/bulk-and-indexrequest-constructor/9120/6 "2017-07-06T03:11:30Z")

</div>

Closed on July 6, 2017, 3:11am UTC


