# How to use multi search

**URL:** <https://discuss.elastic.co/t/how-to-use-multi-search/9801>\
**Category:** Elasticsearch\
**Created:** [November 23, 2012, 9:41am UTC](https://discuss.elastic.co/t/how-to-use-multi-search/9801 "2012-11-23T09:41:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hdvyas007](https://avatars.discourse-cdn.com/v4/letter/h/a6a055/32.png) [@hdvyas007](https://discuss.elastic.co/u/hdvyas007)\
**Post date:** [November 23, 2012, 9:41am UTC](https://discuss.elastic.co/t/how-to-use-multi-search/9801/1 "2012-11-23T09:41:03Z")

</div>

Hi,

I can not get how to use multi search API in elastic search.

I am creating following HttpGet request.

URL : [http://localhost:9200/\_msearch](http://localhost:9200/_msearch)

Body of HttpGet Request

{"index" : "test"}  
{"query" : {"match\_all" : {}}, "from" : 0, "size" : 10}  
{"index" : "test", "search\_type" : "count"}  
{"query" : {"match\_all" : {}}}  
{}  
{"query" : {"match\_all" : {}}}

{"query" : {"match\_all" : {}}}  
{"search\_type" : "count"}  
{"query" : {"match\_all" : {}}}

After executing above request through REST client it's giving following  
error.

{"error":"Failed to derive xcontent from  
org.elasticsearch.common.bytes.BytesArray@0"}

I do not know what I am doing wrong? can somebody help me?

Thank you  
Hemang

--

---

<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 23, 2012, 10:46am UTC](https://discuss.elastic.co/t/how-to-use-multi-search/9801/2 "2012-11-23T10:46:15Z")

</div>

Hiya

> {"index" : "test"}  
> {"query" : {"match\_all" : {}}, "from" : 0, "size" : 10}  
> {"index" : "test", "search\_type" : "count"}  
> {"query" : {"match\_all" : {}}}  
> {}  
> {"query" : {"match\_all" : {}}}
> 
> {"query" : {"match\_all" : {}}}  
> {"search\_type" : "count"}  
> {"query" : {"match\_all" : {}}}

What are those blank lines doing there? And you're missing a {} before  
the second last {"query" : {"match\_all" : {}}}

This works for me:

curl -XGET localhost:9200/\_msearch -d '  
{"index" : "test"}  
{"query" : {"match\_all" : {}}, "from" : 0, "size" : 10}  
{"index" : "test", "search\_type" : "count"}  
{"query" : {"match\_all" : {}}}  
{}  
{"query" : {"match\_all" : {}}}  
{}  
{"query" : {"match\_all" : {}}}  
{"search\_type" : "count"}  
{"query" : {"match\_all" : {}}}  
'

clint

> After executing above request through REST client it's giving  
> following error.
> 
> {"error":"Failed to derive xcontent from  
> org.elasticsearch.common.bytes.BytesArray@0"}
> 
> I do not know what I am doing wrong? can somebody help me?
> 
> Thank you  
> Hemang
> 
> --

--

---

<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:03am UTC](https://discuss.elastic.co/t/how-to-use-multi-search/9801/3 "2017-07-06T03:03:10Z")

</div>


