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.

    Bundle multiple search queries in a single API request. Use this endpoint to search through multiple indexes at once.

    POST/multi-search

    Body

    NameTypeDescription
    queriesArray of objectsContains the list of search queries to perform. The indexUid search parameter is required, all other parameters are optional
    WARNING

    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.

    Search parameters

    Search parameterTypeDefault valueDescription
    indexUidStringN/Auid of the requested index
    qString""Query string
    offsetInteger0Number of documents to skip
    limitInteger20Maximum number of documents returned
    hitsPerPageInteger1Maximum number of documents returned for a page
    pageInteger1Request a specific page of results
    filterStringnullFilter queries by an attribute's value
    facetsArray of stringsnullDisplay the count of matches per facet
    attributesToRetrieveArray of strings["*"]Attributes to display in the returned documents
    attributesToCropArray of stringsnullAttributes whose values have to be cropped
    cropLengthInteger10Maximum length of cropped value in words
    cropMarkerString"…"String marking crop boundaries
    attributesToHighlightArray of stringsnullHighlight matching terms contained in an attribute
    highlightPreTagString"<em>"String inserted at the start of a highlighted term
    highlightPostTagString"</em>"String inserted at the end of a highlighted term
    showMatchesPositionBooleanfalseReturn matching terms location
    sortArray of stringsnullSort search results by an attribute's value
    matchingStrategyStringlastStrategy used to match query terms within documents
    showRankingScoreBooleanfalseDisplay the global ranking score of a document
    attributesToSearchOnArray of strings["*"]Restrict search to the specified attributes

    Learn more about how to use each search parameter.

    Response

    NameTypeDescription
    resultsArray of objectsResults of the search queries in the same order they were requested in

    Each search result object is composed of the following fields:

    NameTypeDescription
    indexUidStringuid of the requested index
    hitsArray of objectsResults of the query
    offsetNumberNumber of documents skipped
    limitNumberNumber of documents to take
    estimatedTotalHitsNumberEstimated total number of matches
    totalHitsNumberExhaustive total number of matches
    totalPagesNumberExhaustive total number of search result pages
    hitsPerPageNumberNumber of results on each page
    pageNumberCurrent search results page
    facetDistributionObjectDistribution of the given facets
    facetStatsObjectThe numeric min and max values per facet
    processingTimeMsNumberProcessing time of the query
    queryStringQuery 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
        }
      ]
    }