Elasticsearch Plugin
検索用に使っている「Elasticsearch」をメインのサーバーから専用のサーバーへ移行するのと同時に解析プラグインを「analysis-kuromoji」から「analysis-sudachi」へ変更したのは「分離」と「設定」で説明した通り。今回はその「analysis-sudachi」を使う上での「ElasticPress」設定について。
return array( 'settings' => array( 'index.mapping.total_fields.limit' => apply_filters( 'ep_total_field_limit', 5000 ), 'index.max_result_window' => apply_filters( 'ep_max_result_window', 1000000 ), 'analysis' => array( 'analyzer' => array( 'default' => array( // 'tokenizer' => 'standard', 'tokenizer' => 'sudachi_tokenizer', 'filter' => array( 'part_of_speech', 'baseform', 'ja_stop', 'normalizedform', 'standard', 'ewp_word_delimiter', 'lowercase', 'stop', 'ewp_snowball' ), 'char_filter' => array( 'html_strip', 'icu_normalizer', 'kuromoji_iteration_mark' ),
「tokenizer」の設定は前回説明した通り。今回追加した「filter」の設定は以下のようにした。
'filter' => array( 'part_of_speech' => array( 'type' => 'sudachi_part_of_speech', 'stoptags' => array( '助詞', '助動詞', '補助記号,句点', '補助記号,読点' ), ), 'baseform' => array( 'type' => 'sudachi_baseform', ), 'ja_stop' => array( 'type' => 'sudachi_ja_stop', 'stoptags' => array( '_japansese_', 'は', 'です' ), ), 'normalizedform' => array( 'type' => 'sudachi_normalizedform', ),
「Elasticsearch」の既定値では「number_of_replicas=1」となるので、明示的にレプリカを作成しない設定を追加する。「settings」の配列の最後に以下の設定を追加する。
), 'number_of_replicas' => 0, ),
この設定が無いとレプリカを作成しない場合、「health」が常に「yellow」表示となる。実害は無いのだがステータスは常に「green」がモットーなのでw
$ curl localhost:9200/_cat/indices?v health status index uuid pri rep docs.count docs.deleted store.size pri.store.size green open arigatoes-1 SNVauYZ4Qs2FaTFSjocAew 5 0 570 4 7.4mb 7.4mb green open mw_cirrus_metastore_first ea9-gowkQ6KXc9BMf5Agfg 1 0 22 2 17.3kb 17.3kb green open setakinokoes-tbp__content_first 6yGx9B2DQMOxFH1p4FdveQ 4 0 1995 0 12.8mb 12.8mb green open setakinokoes-tbp__general_first dUaMkKgORFG9y-sX1_QNJQ 4 0 1566 0 6.2mb 6.2mb
※「mediawiki」の「CirrusSearch」は「kuromoji」を使う設定です。