# Bulk API

**URL:** <https://discuss.elastic.co/t/bulk-api/3569>\
**Category:** Elasticsearch\
**Created:** [November 14, 2010, 2:06pm UTC](https://discuss.elastic.co/t/bulk-api/3569 "2010-11-14T14:06:44Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Degtiariov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrew_degtiariov/32/3223_2.png) [@Andrew\_Degtiariov](https://discuss.elastic.co/u/Andrew_Degtiariov)\
**Post date:** [November 14, 2010, 2:06pm UTC](https://discuss.elastic.co/t/bulk-api/3569/1 "2010-11-14T14:06:44Z")

</div>

Hello!  
I'm trying to use Bulk API to search but got error [\_bulk] Invalid index  
name [_bulk], must not start with '_'

Example:

$ curl -XPOST '[http://localhost:9200/\_bulk](http://localhost:9200/_bulk)' -d '  
{ "search" : { "\_index" : "test\_contacts", "\_type" : "contact"} }  
{"query": {"query\_string": {"query":  
"fields.first\_name:\u042f\u0440\u0438\u043a"}}}  
{ "search" : { "\_index" : "test\_contacts", "\_type" : "contact"} }  
{"query": {"query\_string": {"query": "fields.first\_name:Gorovoy"}}}  
'  
{"error":"[\_bulk] Invalid index name [_bulk], must not start with '_'"}

Were I'm wrong?

--  
Andrew Degtiariov  
DA-RIPE

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [November 14, 2010, 2:17pm UTC](https://discuss.elastic.co/t/bulk-api/3569/2 "2010-11-14T14:17:34Z")

</div>

Hi Andrew

> I'm trying to use Bulk API to search but got error [\_bulk] Invalid  
> index name [_bulk], must not start with '_'
> 
> Example:
> 
> $ curl -XPOST '[http://localhost:9200/\_bulk](http://localhost:9200/_bulk)' -d '  
> { "search" : { "\_index" : "test\_contacts", "\_type" : "contact"} }  
> {"query": {"query\_string": {"query": "fields.first\_name:\u042f\u0440  
> \u0438\u043a"}}}

The bulk interface is for index|create|delete statements, not for  
searches (at least not yet - who knows what the future holds)

clint

---

<div class="post-metadata">

**Author:** ![Andrew\_Degtiariov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrew_degtiariov/32/3223_2.png) [@Andrew\_Degtiariov](https://discuss.elastic.co/u/Andrew_Degtiariov)\
**Post date:** [November 14, 2010, 2:22pm UTC](https://discuss.elastic.co/t/bulk-api/3569/3 "2010-11-14T14:22:56Z")

</div>

On Sun, Nov 14, 2010 at 4:17 PM, Clinton Gormley [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk)wrote:

> Hi Andrew
> 
> > I'm trying to use Bulk API to search but got error [\_bulk] Invalid  
> > index name [_bulk], must not start with '_'
> > 
> > Example:
> > 
> > $ curl -XPOST '[http://localhost:9200/\_bulk](http://localhost:9200/_bulk)' -d '  
> > { "search" : { "\_index" : "test\_contacts", "\_type" : "contact"} }  
> > {"query": {"query\_string": {"query": "fields.first\_name:\u042f\u0440  
> > \u0438\u043a"}}}
> 
> The bulk interface is for index|create|delete statements, not for  
> searches (at least not yet - who knows what the future holds)
> 
> clint

I see, thank you for the fast reply

--  
Andrew Degtiariov  
DA-RIPE

---

<div class="post-metadata">

**Author:** ![michaelvalasanyan](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@michaelvalasanyan](https://discuss.elastic.co/u/michaelvalasanyan)\
**Post date:** [July 14, 2011, 12:42pm UTC](https://discuss.elastic.co/t/bulk-api/3569/4 "2011-07-14T12:42:42Z")

</div>

I had the similar problem so did you find the solution? 🙂

---

<div class="post-metadata">

**Author:** ![Akita](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@Akita](https://discuss.elastic.co/u/Akita)\
**Post date:** [June 9, 2016, 2:58pm UTC](https://discuss.elastic.co/t/bulk-api/3569/5 "2016-06-09T14:58:34Z")

</div>

I was trying to use the Java API to do bulk search, and this is the info I didn't hope for but that I expected : I can't do Java API-based bulk searches. 😢

But I think I DID a bulk search using Sense, and another time with an ajax call from a web page (messy as hell, I know).

In Sense, for example:  
`POST elasticsearch/_msearch {"index":"index1","search_type":"count","ignore_unavailable":true} \n {"size":0,"timeout":0,"aggs":{"2":{"date_range":{"field":"field1","ranges":[{"from":"2016-05-01","to":"now"},{"to":"2016-05-01","from":"2016-01-01"},{"from":"1970-01-01" ,"to":"2016-01-01"}]},"aggs":{"1":{"sum":{"field":"field2"}}}}},"query":{"filtered":{"query":{"query_string":{"query":"my_query_string","analyze_wildcard":true}}}}} \n {"index":"index1","search_type":"count","ignore_unavailable":true} \n {"size":0,"timeout":0,"aggs":{"2":{"date_range":{"field":"field1","ranges":[{"from":"2016-05-01","to":"now"},{"to":"2016-05-01","from":"2016-01-01"},{"from":"1970-01-01" ,"to":"2016-01-01"}]},"aggs":{"1":{"sum":{"field":"field2"}}}}},"query":{"filtered":{"query":{"query_string":{"query":"my_other_query_string","analyze_wildcard":true}}}}} \n`

It returns an array of 2 responses, with 3 buckets each and a sum in each, as expected.

I don't know if it's a regular usage since:

1. "elasticsearch" is the name of my cluster, not an index
2. I found the trick by putting an iframe of a Kibana dashboard on my web page (dev), and listening to network traffic when the iframe was called
3. The bulk API is not supposed to perform searches...

I'm not sure if what I did was really a bulk search or something else!

I'm interested to know if there is a solution for Java bulk search though, because surprisingly my REST search is way faster than my JAVA API search, but that's another matter....

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [June 9, 2016, 3:22pm UTC](https://discuss.elastic.co/t/bulk-api/3569/6 "2016-06-09T15:22:31Z")

</div>

I think you want the `prepareMultiSearch` method in the transport client?

---

<div class="post-metadata">

**Author:** ![Akita](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@Akita](https://discuss.elastic.co/u/Akita)\
**Post date:** [June 9, 2016, 3:41pm UTC](https://discuss.elastic.co/t/bulk-api/3569/7 "2016-06-09T15:41:07Z")

</div>

Yes, you're right! I think I found the solution with the REST bulk-like call, and then try to stick to it without thinking enough.... Thank you very much!

And now I realise that my "bulk-like" call is simply the multi\_search API.  
I think I just need to reread the docs and stop spaming the forum...

Thanks again!

---

<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 5, 2017, 10:44pm UTC](https://discuss.elastic.co/t/bulk-api/3569/8 "2017-07-05T22:44:58Z")

</div>


