elasticsearchを使用して、すべての項目を「スキー」という単語で検索します。Elasticsearch入力単語とすべての類義語を検索
マイマッピング(PHPの配列):
"properties" => [
"title" => [
"type" => "string",
"boost" => 1.0,
"analyzer" => "autocomplete"
]
]
セッティング:
"settings"=> [
"analysis" => [
"analyzer" => [
"autocomplete" => [
"type" => "custom",
"tokenizer" => "standard",
"filter" => ["lowercase", "trim", "synonym", "porter_stem"],
"char_filter" => ["html_strip"]
]
],
"filter" => [
"synonym" => [
"type" => "synonym",
"synonyms_path" => "analysis/synonyms.txt"
]
]
]
]
検索クエリ:sysnonyms.txtで
[
"index" => "articles",
"body" => [
"query" => [
"filtered" => [
"query" => [
"bool" => [
"must" => [
"indices" => [
"indices" => ["articles"],
"query" => [
"bool" => [
"should" => [
"multi_match" => [
"query" => "skiing",
"fields" => ["title"]
]
]
]
]
]
]
]
]
]
],
"sort" => [
"_score" => [
"order" => "desc"
]
]
],
"size" => 10,
"from" => 0,
"search_type" => "dfs_query_then_fetch",
"explain" => true
];
はスキー=>キサントゲンを持っています。
私は(それが入力単語であるため)、「スキー」で、すべてのアイテムを取得したい(porter_stemトークナイザによる)、「スキー」と(同義語ファイルによって)、その後「キサンチン」。しかし、単語「キサント語」だけで結果を得る。
どうか教えてください。どのようにインデックスを設定する必要がありますか?