Meilisearch.Search (meilisearch v0.20.0) View Source

Collection of functions used to search for documents matching given query.

MeiliSearch Documentation - Search

Link to this section Summary

Functions

Search for documents matching a specific query in the given index.

Link to this section Functions

Link to this function

search(uid, search_query, opts \\ [])

View Source

Specs

Search for documents matching a specific query in the given index.

A search_query value of nil will send a placeholder query.

Options

  • offset Number of documents to skip. Defaults to 0
  • limit Maximum number of documents returned. Defaults to 20

Examples

iex> Meilisearch.Search.search("meilisearch_test", "where art thou")
{:ok,
%{
  "exhaustiveNbHits" => false,
  "hits" => [
    %{
      "id" => 2,
      "tagline" => "They have a plan but not a clue",
      "title" => "O' Brother Where Art Thou"
    }
  ],
  "limit" => 20,
  "nbHits" => 1,
  "offset" => 0,
  "processingTimeMs" => 17,
  "query" => "where art thou"
}}

iex> Meilisearch.Search.search("meilisearch_test", "nothing will match")
{:ok,
%{
  "exhaustiveNbHits" => false,
  "hits" => [],
  "limit" => 20,
  "nbHits" => 0,
  "offset" => 0,
  "processingTimeMs" => 27,
  "query" => "nothing will match"
}}