Mastodon
  • Mastodonの使い方
    • Signing up for an account
    • Setting up your profile
    • Posting toots
    • Using the network features
    • Dealing with unwanted content
    • Promoting yourself and others
    • Set your preferences
    • その他の設定
    • Using Mastodon externally
    • Moving or leaving accounts
  • Mastodonの構築
    • マシンの準備
    • ソースからインストール
    • 環境設定
    • オプションのインストール
      • 全文検索
      • 秘匿サービス
      • シングルサインオン
    • セットアップを完了する
    • 開発者向けコマンドラインを利用する
    • 新しいバージョンへアップグレード
    • サーバのバックアップ
    • 新しいマシンへの移行
    • サーバーのスケールアップ
    • モデレーション
    • トラブルシューティング
  • アプリケーションの開発
    • Getting started with the API
    • Playing with public data
    • Obtaining client app access
    • ログイン
    • ガイドラインとベストプラクティス
    • ライブラリ等
  • コントリビューション
    • 技術的情報
    • 開発環境のセットアップ
    • ソースコードの構造
    • ルーティング
  • スペック
    • ActivityPub
    • WebFinger
    • Security
    • Microformats
    • OAuth
  • REST API
    • OAuthスコープ
  • API一覧
    • apps
      • oauth
    • accounts
      • bookmarks
      • favourites
      • mutes
      • blocks
      • domain_blocks
      • filters
      • reports
      • follow_requests
      • endorsements
      • featured_tags
      • preferences
      • suggestions
    • statuses
      • media
      • polls
      • scheduled_statuses
      • streaming
    • timelines
      • conversations
      • lists
      • markers
    • notifications
      • push
    • search
    • instance
      • trends
      • directory
      • custom_emojis
    • admin
    • proofs
    • oembed
  • APIエンティティ
    • Account
    • Activity
    • Admin::Account
    • Admin::Report
    • Application
    • Attachment
    • Card
    • Context
    • Conversation
    • Emoji
    • Error
    • FeaturedTag
    • Field
    • Filter
    • History
    • IdentityProof
    • Instance
    • List
    • Marker
    • Mention
    • Notification
    • Poll
    • Preferences
    • PushSubscription
    • Relationship
    • Report
    • Results
    • ScheduledStatus
    • Source
    • Status
    • Tag
    • Token

全文検索

Elasticsearchを設定すると、自分の投稿や、自分がお気に入り登録した投稿、メンションされた投稿を検索できます。

Elasticsearchが有効な場合、Mastodonは全文検索をサポートします。Mastodonの全文検索はログインしているユーザーに、そのユーザーの投稿や、お気に入り登録した投稿、メンションされた投稿を検索できます。データベース全体で任意の文字列を検索することはできません。

Elasticsearchのインストール

Elasticsearchを使用するためにはJavaランタイムが必要です。インストールしていない場合は行います。rootでログインしている場合以下のように実行します。

apt install openjdk-8-jre-headless

aptにElasticsearchの公式リポジトリを登録します。

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -
echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | tee -a /etc/apt/sources.list.d/elastic-6.x.list
apt update

そして、Elasticsearchをインストールします。

apt install elasticsearch
セキュリティ上の警告 標準では、Elasticsearchはlocalhostだけにバインドできます。つまり、外部ネットワークからはアクセスできないと言うことです。/etc/elasticsearch/elasticsearch.yml内のnetwork.hostでElasticsearchがバインドされているアドレスをチェックできます。ElasticsearchにアクセスできるユーザはElasticsearch内のいかなるデータにもアクセスでき、変更できるということに注意してください。従って、アクセス制御をセキュアな状態に保っておくことは非常に重要です。これはインストールガイドでも推奨されていますが、22, 80, 443ポート以外のポートはファイアウォールで閉じておくことをおすすめします。もしマルチホストでセットアップする場合、内部のトラフィックのセキュリティについて熟知しておく必要があります。

Elasticsearchの開始:

systemctl enable elasticsearch
systemctl start elasticsearch

Mastodonの設定

以下の変数を.env.productionに追加してください。

ES_ENABLED=true
ES_HOST=localhost
ES_PORT=9200

もし同じマシンに複数のMastodonサーバが存在する場合、そしてその全てに同一のElasticsearchサービスを使用しようとしている場合、インデックスを区別するためにREDIS_NAMESPACEの値を各々別のものにしておいてください。もしElasticsearchのインデックスのプレフィクスを上書きしないと行けない場合、ES_PREFIXを直接指定することもできます。

新しい設定を保存した後、Elasticsearchにインデックスを作成します。

RAILS_ENV=production bundle exec rake chewy:upgrade

そして、設定を適用するためにMastodonプロセスを再起動します。

systemctl restart mastodon-sidekiq
systemctl reload mastodon-web

これで新しい投稿は全てElasticsearchにインデックスされます。最後に、古いデータも同様にインデックスすれば完了です。以下のように実行します。

RAILS_ENV=production bundle exec rake chewy:sync

時間がかかります。

互換性に関する情報 Ruby 2.6.0には上記のタスクが実行できないというバグがあります。2.6.0以外のRubyにそのようなバグはありません。

最終更新 March 4, 2020 · このページを改善する
他の言語: English

Merch

Tシャツとステッカー(英語)

Mastodonに参加しよう · ブログ · ·

ソースコード · CC BY-SA 4.0 · インプリント