View Source Meilisearch.MultiSearch (meilisearch_ex v1.1.2)

Search into your Meilisearch indexes. Multi-Search API

Link to this section Summary

Functions

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

Link to this section Types

@type search_params() :: %{required(String.t()) => single_search_params()}
Link to this type

single_search_params()

View Source
@type single_search_params() :: %{
  q: String.t(),
  offset: integer(),
  limit: integer(),
  hitsPerPage: integer(),
  page: integer(),
  filter: String.t() | [String.t()] | nil,
  facets: [String.t()] | nil,
  attributesToRetrieve: [String.t()],
  attributesToCrop: [String.t()] | nil,
  cropLength: integer(),
  cropMarker: String.t(),
  attributesToHighlight: [String.t()] | nil,
  highlightPreTag: String.t(),
  highlightPostTag: String.t(),
  showMatchesPosition: boolean(),
  sort: [String.t()] | nil,
  matchingStrategy: String.t() | :last | :all
}
@type t(item) :: %Meilisearch.MultiSearch{
  estimatedTotalHits: integer(),
  facetDistribution: map(),
  facetStats: map(),
  hits: [item],
  hitsPerPage: integer(),
  indexUid: String.t(),
  limit: integer(),
  offset: integer(),
  page: integer(),
  processingTimeMs: integer(),
  query: String.t(),
  totalHits: integer(),
  totalPages: integer()
}

Link to this section Functions

Link to this function

multi_search(client, params \\ %{})

View Source
@spec multi_search(
  Tesla.Client.t(),
  search_params()
) :: {:ok, t(Meilisearch.Document.t())} | {:error, Meilisearch.Client.error()}

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

examples

Examples

iex> client = Meilisearch.Client.new(endpoint: "http://localhost:7700", key: "master_key_test")
iex> Meilisearch.MultiSearch.multi_search(client, %{"movies" => [q: "space"], "books" => [q: "space]})
{:ok, [%{
  indexUid: "movies",
  offset: 0,
  limit: 20,
  estimatedTotalHits: 1,
  totalHits: 1,
  totalPages: 1,
  totalPages: 1,
  page: 1,
  facetDistribution: %{
    "genres" => %{
      "action" => 273,
      "animation" => 118,
      "adventure" => 132,
      "fantasy" => 67,
      "comedy" => 475,
      "mystery" => 70,
      "thriller" => 217
    }
  },
  processingTimeMs: 11,
  query: "space",
  hits: [%{
    "id" => 2001,
    "title" => "2001: A Space Odyssey"
  }]
}]}