# Multisearch query problems

**URL:** https://discuss.elastic.co/t/multisearch-query-problems/8049
**Category:** Elasticsearch
**Created:** [June 11, 2012, 11:48pm UTC](https://discuss.elastic.co/t/multisearch-query-problems/8049 "2012-06-11T23:48:10Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Yorubawarrior](https://avatars.discourse-cdn.com/v4/letter/y/f1d935/32.png) [@Yorubawarrior](https://discuss.elastic.co/u/Yorubawarrior)
#### Post date: [June 11, 2012, 11:48pm UTC](https://discuss.elastic.co/t/multisearch-query-problems/8049/1 "2012-06-11T23:48:10Z")

</div>

Hi:  
I am attempting to do multisearch with Elasticsearch and it is causing  
me problems. I generate my queries using php and also use php curl to  
interface with my server which is running Elasticsearch 0.19.4. There are  
a couple of issues I am encountering:

1. the first is, I am trying to do a count with a multi search query, so my  
generated url eventually looks like this:

[http://localhost:9200/profile/user/\_msearch?search\_type=count](http://localhost:9200/profile/user/_msearch?search_type=count)

> 

with this setup, i expect that when I run my multi search query, it will  
return to me a responses array with just the count. But my the behavior is  
inconsistent. it returns my entire document for one of my queries and the  
normal results for my other queries.

1. multisearch does not return responses to all my queries. For example, I  
sent six queries seperated by a newline to multisearch and I get back in my  
reponses array three responses with inconsistent results.

has anybody successfully used multisearch with php?

BTW..this works just fine with individual searches..its only when i try to  
do multisearch that i run into problems.

Thxs

>

---

<div class="post-metadata">

### Author: ![Yorubawarrior](https://avatars.discourse-cdn.com/v4/letter/y/f1d935/32.png) [@Yorubawarrior](https://discuss.elastic.co/u/Yorubawarrior)
#### Post date: [June 12, 2012, 6:45am UTC](https://discuss.elastic.co/t/multisearch-query-problems/8049/2 "2012-06-12T06:45:02Z")

</div>

So, I got it working. The trick was to put the search type as the header  
for each individual query. i was trying to be economical and put it once in  
the url like you can do for individual requests, but that does not work.

On Monday, June 11, 2012 4:48:10 PM UTC-7, Yorubawarrior wrote:

> Hi:  
> I am attempting to do multisearch with Elasticsearch and it is causing  
> me problems. I generate my queries using php and also use php curl to  
> interface with my server which is running Elasticsearch 0.19.4. There are  
> a couple of issues I am encountering:
> 
> 1. the first is, I am trying to do a count with a multi search query, so  
> my generated url eventually looks like this:
> 
> [http://localhost:9200/profile/user/\_msearch?search\_type=count](http://localhost:9200/profile/user/_msearch?search_type=count)
> 
> > 
> 
> with this setup, i expect that when I run my multi search query, it will  
> return to me a responses array with just the count. But my the behavior is  
> inconsistent. it returns my entire document for one of my queries and the  
> normal results for my other queries.
> 
> 1. multisearch does not return responses to all my queries. For example, I  
> sent six queries seperated by a newline to multisearch and I get back in my  
> reponses array three responses with inconsistent results.
> 
> has anybody successfully used multisearch with php?
> 
> BTW..this works just fine with individual searches..its only when i try to  
> do multisearch that i run into problems.
> 
> Thxs
> 
> >

---

<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: [June 12, 2012, 8:17am UTC](https://discuss.elastic.co/t/multisearch-query-problems/8049/3 "2012-06-12T08:17:04Z")

</div>

On Mon, 2012-06-11 at 23:45 -0700, Yorubawarrior wrote:

> So, I got it working. The trick was to put the search type as the  
> header for each individual query. i was trying to be economical and  
> put it once in the url like you can do for individual requests, but  
> that does not work.

Could you open an issue for this? I think it should be supported

clint

> On Monday, June 11, 2012 4:48:10 PM UTC-7, Yorubawarrior wrote:  
> Hi:  
> I am attempting to do multisearch with Elasticsearch and  
> it is causing me problems. I generate my queries using php and  
> also use php curl to interface with my server which is running  
> Elasticsearch 0.19.4. There are a couple of issues I am  
> encountering:
> 
> ```
> 1. the first is, I am trying to do a count with a multi search
> query, so my generated url eventually looks like this:
>     
> http://localhost:9200/profile/user/_msearch?search_type=count
>     
> with this setup, i expect that when I run my multi search
> query, it will return to me a responses array with just the
> count. But my the behavior is inconsistent. it returns my
> entire document for one of my queries and the normal results
> for my other queries.
>     
> 2. multisearch does not return responses to all my queries.
> For example, I sent six queries seperated by a newline to
> multisearch and I get back in my reponses array three
> responses with inconsistent results. 
>     
> has anybody successfully used multisearch with php? 
>     
> BTW..this works just fine with individual searches..its only
> when i try to do multisearch that i run into problems.
>     
> Thxs
> 
> ```

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [June 13, 2012, 6:47pm UTC](https://discuss.elastic.co/t/multisearch-query-problems/8049/4 "2012-06-13T18:47:03Z")

</div>

Opened an issue: [Multi Search API: Allow to set search\_type on REST endpoint URI to apply to all search requests · Issue #2023 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/2023).

On Tue, Jun 12, 2012 at 10:17 AM, Clinton Gormley [clint@traveljury.com](mailto:clint@traveljury.com)wrote:

> On Mon, 2012-06-11 at 23:45 -0700, Yorubawarrior wrote:
> 
> > So, I got it working. The trick was to put the search type as the  
> > header for each individual query. i was trying to be economical and  
> > put it once in the url like you can do for individual requests, but  
> > that does not work.
> 
> Could you open an issue for this? I think it should be supported
> 
> clint
> 
> > On Monday, June 11, 2012 4:48:10 PM UTC-7, Yorubawarrior wrote:  
> > Hi:  
> > I am attempting to do multisearch with Elasticsearch and  
> > it is causing me problems. I generate my queries using php and  
> > also use php curl to interface with my server which is running  
> > Elasticsearch 0.19.4. There are a couple of issues I am  
> > encountering:
> > 
> > ```
> > 1. the first is, I am trying to do a count with a multi search
> > query, so my generated url eventually looks like this:
> > 
> > ```
> 
> [http://localhost:9200/profile/user/\_msearch?search\_type=count](http://localhost:9200/profile/user/_msearch?search_type=count)
> 
> > ```
> > with this setup, i expect that when I run my multi search
> > query, it will return to me a responses array with just the
> > count. But my the behavior is inconsistent. it returns my
> > entire document for one of my queries and the normal results
> > for my other queries.
> > 
> > 2. multisearch does not return responses to all my queries.
> > For example, I sent six queries seperated by a newline to
> > multisearch and I get back in my reponses array three
> > responses with inconsistent results.
> > 
> > has anybody successfully used multisearch with php?
> > 
> > BTW..this works just fine with individual searches..its only
> > when i try to do multisearch that i run into problems.
> > 
> > Thxs
> > 
> > ```

---

<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:24am UTC](https://discuss.elastic.co/t/multisearch-query-problems/8049/5 "2017-07-06T03:24:26Z")

</div>


