Multi-search
The /multi-search route allows you to perform multiple search queries on one or more indexes by bundling them into a single HTTP request. Multi-search is also known as federated search.
POST route
POST/multi-search
Body
| Name | Type | Description | 
|---|---|---|
queries | Array of objects | Contains the list of search queries to perform. The indexUid search parameter is required, all other parameters are optional | 
Search parameters
| Search parameter | Type | Default value | Description | 
|---|---|---|---|
indexUid | String | N/A | uid of the requested index | 
q | String | "" | Query string | 
offset | Integer | 0 | Number of documents to skip | 
limit | Integer | 20 | Maximum number of documents returned | 
hitsPerPage | Integer | 1 | Maximum number of documents returned for a page | 
page | Integer | 1 | Request a specific page of results | 
filter | Array of strings | null | Filter queries by an attribute's value | 
facets | Array of strings | null | Display the count of matches per facet | 
attributesToRetrieve | Array of strings | ["*"] | Attributes to display in the returned documents | 
attributesToCrop | Array of strings | null | Attributes whose values have to be cropped | 
cropLength | Integer | 10 | Maximum length of cropped value in words | 
cropMarker | String | "…" | String marking crop boundaries | 
attributesToHighlight | Array of strings | null | Highlight matching terms contained in an attribute | 
highlightPreTag | String | "<em>" | String inserted at the start of a highlighted term | 
highlightPostTag | String | "</em>" | String inserted at the end of a highlighted term | 
showMatchesPosition | Boolean | false | Return matching terms location | 
sort | Array of strings | null | Sort search results by an attribute's value | 
matchingStrategy | String | last | Strategy used to match query terms within documents | 
Learn more about how to use each search parameter.
Response
| Name | Type | Description | 
|---|---|---|
results | Array of objects | Results of the search queries in the same order they were requested in | 
Each search result object is composed of the following fields:
| Name | Type | Description | 
|---|---|---|
indexUid | String | uid of the requested index | 
hits | Array of objects | Results of the query | 
offset | Number | Number of documents skipped | 
limit | Number | Number of documents to take | 
estimatedTotalHits | Number | Estimated total number of matches | 
totalHits | Number | Exhaustive total number of matches | 
totalPages | Number | Exhaustive total number of search result pages | 
hitsPerPage | Number | Number of results on each page | 
page | Number | Current search results page | 
facetDistribution | Object | Distribution of the given facets | 
facetStats | Object | The numeric min and max values per facet | 
processingTimeMs | Number | Processing time of the query | 
query | String | Query originating the response | 
Example
curl \
  -X POST 'http://localhost:7700/multi-search' \
  -H 'Content-Type: application/json' \
  --data-binary '{
    "queries": [
      {
        "indexUid": "movies",
        "q": "pooh",
        "limit": 5
      },
      {
        "indexUid": "movies",
        "q": "nemo",
        "limit": 5
      },
      {
        "indexUid": "movie_ratings",
        "q": "us"
      }
    ]
  }'Response: 200 Ok
{
  "results":[
    {
      "indexUid":"movies",
      "hits":[
        {
          "id":13682,
          "title":"Pooh's Heffalump Movie",
          …
        },
        …
      ],
      "query":"pooh",
      "processingTimeMs":26,
      "limit":5,
      "offset":0,
      "estimatedTotalHits":22
    },
    {
      "indexUid":"movies",
      "hits":[
        {
          "id":12,
          "title":"Finding Nemo",
          …
        },
        …
      ],
      "query":"nemo",
      "processingTimeMs":5,
      "limit":5,
      "offset":0,
      "estimatedTotalHits":11
    },
    {
      "indexUid":"movie_ratings",
      "hits":[
        {
          "id":"Us",
          "director": "Jordan Peele",
          …
        }
      ],
      "query":"Us",
      "processingTimeMs":0,
      "limit":20,
      "offset":0,
      "estimatedTotalHits":1
    }
  ]
}