Experts,
I am able to search multiple indexes like -
http://elasticsearchbaseurl/shows,movies/all/_search
referring to two indexes - shows and movies.
Question: Is there a way to pass max hits for each index. I want only 2 records to be returned from each index.
We are working on the grouped autocomplete , so would like to be able to make one call and then group results on the index name.
Please help.
Regards,
Hemant
             
            
              
              
              
            
            
           
          
            
            
              Hi Hemant,
sounds like you're after the multi search API.
Daniel
             
            
              
              
              
            
            
           
          
            
            
              Thanks Daniel; tried this in request body of API-
{"index" : "shows","type":"all"}
{"query" : {"match_all" : {}}, "from" : 0, "size" : 2}
{"index" : "movies","type":"all"}
{"query" : {"match_all" : {}}, "from" : 0, "size" : 2}
We need 2 "shows" and 2 "movies" to be returned but it returns 2 "shows" and not returns "movies" - basically the first index is queried and 2nd one is ignored ("movies" in this example).
Can you, please, share what wrong I am doing here?
Regards,
Hemant
             
            
              
              
              
            
            
           
          
            
            
              Hi Hemant,
Your _msearch is fine. In fact, if I enter this example, it returns two movies and two shows:
DELETE /movies
DELETE /shows
POST /_bulk
{"index":{"_index":"movies","_type":"all"}}
{"title": "Back to the Future I"}
{"index":{"_index":"movies","_type":"all"}}
{"title": "Back to the Future II"}
{"index":{"_index":"movies","_type":"all"}}
{"title": "Back to the Future III"}
{"index":{"_index":"shows","_type":"all"}}
{"title": "Big Bang Theory"}
{"index":{"_index":"shows","_type":"all"}}
{"title": "IT Crowd"}
{"index":{"_index":"shows","_type":"all"}}
{"title": "Dr. Who"}
GET /_msearch
{"index" : "shows","type":"all"}
{"query" : {"match_all" : {}}, "from" : 0, "size" : 2}
{"index" : "movies","type":"all"}
{"query" : {"match_all" : {}}, "from" : 0, "size" : 2}
_msearch returns a response array. Did you check all responses?
Daniel
             
            
              
              
              
            
            
           
          
            
            
              Thanks Daniel, it is working fine.
Can you, please help with how to apply "wild card" in _msearch?
{"index" : "shows","type":"all"}
{"query" : {"match" : {"_all": "Future"}}, "from" : 0, "size" : 2}
{"index" : "movies","type":"all"}
{"query" : {"match" : {"_all": "Future"}}, "from" : 0, "size" : 2}
{"index" : "stars","type":"all"}
{"query" : {"match" : {"all": "Future"}}, "from" : 0, "size" : 2}
how to use the "widcard" option above?
Thanks again for your time and explanation.
Regards,
Hemant
             
            
              
              
              
            
            
           
          
            
            
              Below is working. Please advise if this is the optimized way or if there is a better way to achieve this
index" : "shows","type":"all"}
{"query" : {"wildcard" : {"_all": "Future"}}, "from" : 0, "size" : 2}
{"index" : "movies","type":"all"}
{"query" : {"wildcard" : {"_all": "Future"}}, "from" : 0, "size" : 2}
{"index" : "stars","type":"all"}
{"query" : {"wildcard" : {"title": "Future"}}, "from" : 0, "size" : 2}
Regards,
Hemant
             
            
              
              
              
            
            
           
          
            
            
              Hey @hemantsajnani,
I am having the same problem as you. Only, the index in the first row is being queried. All other indexes are ignored. How it started working for you ? What did you change inside request-body ?