Skip to content

Latest commit

 

History

History
22 lines (16 loc) · 1000 Bytes

multisearch.md

File metadata and controls

22 lines (16 loc) · 1000 Bytes

Multi Search

The multisearch request type allows us to execute multiple searches in the a single request. The format is simple, pass a list of search requests into the client method.

Then to issue multiple search requests at once, we use

val resp = client.execute (
  search in "jtull" query "mylo", // note the trailing comma, we are invoking a var args method
  search in "jtull" query "viva"
)

The resp value is of type Future[MultiSearchResponse], the standard Java API response for multi searches.

Note, the scala client has no distinction in the syntax between multisearch and standard single search. You simply choose to either invoke with a single search and get back a Future[SearchResponse] or invoke with many searches and get back a Future[MultiSearchResponse].

This is the only multi* method that can be invoked directly. Others need a wrapping block, eg multiget. This is because the varargs method is desugered into a Seq[T] which becomes Seq[_] due to erasure.