# Fumadocs (Framework Mode, Astro): Mixedbread
URL: /ja/docs/astro/search/mixedbread
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/(framework)/[framework]/search/mixedbread.ja.mdx

Fumadocs UI で Mixedbread を使用する方法

## セットアップ [#setup]

Mixedbread 検索はリクエスト時にサーバー上で実行されるため、静的サイトでは利用できません。

Fumadocs CLI を使えば、セットアップを自動で行えます。検索ダイアログ、検索ルート、`static.json` ルートに加え、ビルドのたびにストアを同期するスクリプトが作成されます。

```package-install
npx @fumadocs/cli feature search --provider mixedbread
```

または、手動で設定する場合:

1. [Mixedbread Search](/docs/headless/search/mixedbread) を統合します。

2. 検索ダイアログのコンポーネントを作成します。

   ```tsx title="components/search.tsx"
   'use client';

   import {
     SearchDialog,
     SearchDialogClose,
     SearchDialogContent,
     SearchDialogFooter,
     SearchDialogHeader,
     SearchDialogIcon,
     SearchDialogInput,
     SearchDialogList,
     SearchDialogOverlay,
     type SharedProps,
   } from 'fumadocs-ui/components/dialog/search';
   import { useFetchSearch } from 'fumadocs-core/search/client';
   import { useI18n } from 'fumadocs-ui/contexts/i18n';

   export default function CustomSearchDialog(props: SharedProps) {
     const { locale } = useI18n(); // (optional) for i18n
     const search = useFetchSearch({
       api: '/api/search',
       locale,
       // every search is a request to Mixedbread
       delayMs: 300,
     });

     return (
       <SearchDialog {...search} {...props}>
         <SearchDialogOverlay />
         <SearchDialogContent>
           <SearchDialogHeader>
             <SearchDialogIcon />
             <SearchDialogInput />
             <SearchDialogClose />
           </SearchDialogHeader>
           <SearchDialogList />
           <SearchDialogFooter>
             <a
               href="https://mixedbread.com"
               rel="noreferrer noopener"
               className="ms-auto text-xs text-fd-muted-foreground"
             >
               Search powered by Mixedbread
             </a>
           </SearchDialogFooter>
         </SearchDialogContent>
       </SearchDialog>
     );
   }
   ```

### 検索ダイアログを置き換える [#replace-search-dialog]

プロバイダーコンポーネントはすでに `src/components/search.tsx` を [`<RootProvider />`](/docs/ui/layouts/root-provider) に渡しているため、このファイルを置き換えるだけで済みます。

```tsx title="src/components/provider.tsx"
import { navigate } from 'astro:transitions/client';
import type { ReactNode } from 'react';
import { RootProvider } from 'fumadocs-ui/provider/astro';
import SearchDialog from '@/components/search';

export interface ProviderProps {
  pathname: string;
  params: Record<string, string | undefined>;
  children?: ReactNode;
}

export function Provider({ pathname, params, children }: ProviderProps) {
  return (
    <RootProvider
      pathname={pathname}
      params={params}
      navigate={navigate}
      // [!code highlight]
      search={{ SearchDialog }}
    >
      {children}
    </RootProvider>
  );
}
```

### タグフィルター [#tag-filter]

必要に応じて、検索結果をタグで絞り込むための UI を追加できます。検索サーバーで[タグフィルター](/docs/headless/search/mixedbread#tag-filter)を設定したうえで、以下を追加してください。

```tsx
'use client';

import {
  SearchDialog,
  SearchDialogContent,
  SearchDialogFooter,
  SearchDialogOverlay,
  type SharedProps,
  TagsList,
  TagsListItem,
} from 'fumadocs-ui/components/dialog/search';
import { useState } from 'react';
import { useFetchSearch } from 'fumadocs-core/search/client';

export default function CustomSearchDialog(props: SharedProps) {
  // [!code ++]
  const [tag, setTag] = useState<string | undefined>();
  const search = useFetchSearch({
    tag, // [!code ++]
  });

  return (
    <SearchDialog {...search} {...props}>
      <SearchDialogOverlay />
      <SearchDialogContent>
        ...
        <SearchDialogFooter className="flex flex-row">
          {/* [!code ++:3] */}
          <TagsList tag={tag} onTagChange={setTag}>
            <TagsListItem value="my-value">My Value</TagsListItem>
          </TagsList>
        </SearchDialogFooter>
      </SearchDialogContent>
    </SearchDialog>
  );
}
```