The /multi-search route allows you to perform multiple search queries on one or more indexes.
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.
If present and not null, returns a single list merging all search results across all specified queries
queries
Array of objects
Contains the list of search queries to perform. The indexUid search parameter is required, all other parameters are optional
If Meilisearch encounters an error when handling any of the queries in a multi-search request, it immediately stops processing the request and returns an error message. The returned message will only address the first error encountered.
Use federation to receive a single list with all search results from all specified queries, in descending ranking score order. This is called federated search.federation may optionally contain the following parameters:
Display facet information for the specified indexes
If federation is missing or null, Meilisearch returns a list of multiple search result objects, with each item from the list corresponding to a search query in the request.
facetsByIndex
facetsByIndex must be an object. Its keys must correspond to indexes in your Meilisearch project. Each key must be associated with an array of attributes in the filterable attributes list of that index:
When you specify facetsByIndex, multi-search responses include an extra facetsByIndex field. The response’s facetsByIndex is an object with one field for each queried index:
mergeFacets must be an object and may contain the following fields:
maxValuesPerFacet: must be an integer. When specified, indicates the maximum number of returned values for a single facet. Defaults to the value assigned to the maxValuesPerFacet index setting
When both facetsByIndex and mergeFacets are present and not null, facet information included in multi-search responses is merged across all queried indexes. Instead of facetsByIndex, the response includes two extra fields: facetDistribution and facetStats:
Federated search’s merged results are returned in decreasing ranking score. To obtain the final list of results, Meilisearch compares with the following procedure:
Detailed ranking scores are normalized in the following way for both hits:
Consecutive relevancy scores (related to the rules words, typo, attribute, exactness or vector) are grouped in a single score for each hit
sort and geosort score details remain unchanged
Normalized detailed ranking scores are compared lexicographically for both hits:
If both hits have a relevancy score, then the bigger score wins. If it is a tie, move to next step
If one result has a relevancy score or a (geo)sort score, Meilisearch picks it
If both results have a sort or geosort score in the same sorting direction, then Meilisearch compares the values according to the common sort direction. The result with the value that must come first according to the common sort direction wins. If it is a tie, go to the next step
Compare the global ranking scores of both hits to determine which comes first, ignoring any sorting or geosorting
In the case of a perfect tie, documents from the query with the lowest rank in the queries array are preferred.
Meilisearch considers two documents the same if:
They come from the same index
And their primary key is the same
There is no way to specify that two documents should be treated as the same across multiple indexes.
These options are not compatible with federated searches.
federationOptions
federationOptions must be an object. It accepts the following parameters:
weight: serves as a multiplicative factor to ranking scores of search results in this specific query. If < 1.0, the hits from this query are less likely to appear in the final results list. If > 1.0, the hits from this query are more likely to appear in the final results list. Must be a positive floating-point number. Defaults to 1.0
remoteexperimental: indicates the remote instance where Meilisearch will perform the query. Must be a string corresponding to a remote object. Defaults to null