使用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"
]
]
]
]
搜索查询:
[
"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
];
在sysnonyms.txt具有滑雪=>黄原。
我想要得到与“滑雪”的所有项目(因为它是输入字),“滑雪”(由porter_stem标记生成器),然后在“黄原”(由同义词文件)。但只有用词“xanthic”才能得到结果。
请告诉我为什么?我如何配置索引?