Skip to content

MeiliSearchの検索ボックスが出なくなった

Posted on:2024-1-17 at 10:00

はじめに

いつの間にか、MeiliSearchの検索ボックスが出なくなったので対応。

状況

検索ボックスが表示されない。エラーを確認すると、

instantsearch.js@4:2 Uncaught Error: The searchClient must implement a search method.

修正

以下を参考に該当箇所を修正。
Error: The `searchClient` must implement a `search` method. · Issue #1268 · meilisearch/meilisearch-js-plugins · GitHub

components/MeiliSearch.astro

const { searchClient } = instantMeiliSearch(
  import.meta.env.PUBLIC_MEILISEARCH_HOST,
  import.meta.env.PUBLIC_MEILISEARCH_SEARCH_KEY,
  {
    placeholderSearch: false, // default: true.
  }
)
const instantsearchinstance = instantsearch({
  indexName: "MY_INDEX_NAME",
  searchClient,
  initialUiState: {
      frontpage: {
          query: ''
      }
  }
});
GitHub - meilisearch/meilisearch-js-plugins: The search client to use Meilisearch with InstantSearch.
The search client to use Meilisearch with InstantSearch. - GitHub - meilisearch/meilisearch-js-plugins: The search client to use Meilisearch with InstantSearch.
GitHub - meilisearch/meilisearch-js-plugins: The search client to use Meilisearch with InstantSearch. favicon https://github.com/meilisearch/meilisearch-js-plugins
GitHub - meilisearch/meilisearch-js-plugins: The search client to use Meilisearch with InstantSearch.