我有一个ElasticSearch实例(AWS),其中包含大约200,000个文档。这些文件包含各种信息,但最值得注意的是每种类型的信息都有一个'名称' - 我主要试图搜索。
通过下面粘贴的设置(和搜索),我可以相对成功地搜索大多数查询,前提是这些查询不涉及复数形式。我现在的情况是,使用'丝袜' (如在长袜填料中)作为一个例子:
搜索"放养" - 接收源(名称)包含"库存"但不是"丝袜"
搜索"丝袜" - 接收源(名称)包含"库存"但不是"丝袜"
搜索"放养*" - 接收源(名称)包含"库存"和"丝袜"
我相信我将该字段映射到分析器有问题 - 但我无法弄清楚它是什么。非常感谢任何帮助。
$params = [
'index' => SEARCH2_NORMAL_INDEX,
'body' => [
'settings' => [
"analysis" => [
"filter" => [
"english_stop" => [
"type" => "stop",
"stopwords" => "_english_"
],
"light_english_stemmer" => [
"type" => "stemmer",
"language" => "light_english"
]
],
"analyzer" => [
"english" => [
"tokenizer" => "standard",
"filter" => [
"lowercase",
"english_stop",
"light_english_stemmer",
"asciifolding"
]
]
]
]
],
'mappings' => [
'component' => [
'properties' => [
'name' => [
'type' => 'string',
'analyzer' => 'english'
]
]
]
]
]
];
并搜索:
$params = [
'index' => $indexes,
//'index' => SEARCH2_NORMAL_INDEX,
'body' => [
'from' => 0,
'size' => 200,
'query' => [
'query_string' => [
'query' => $final_search,
'analyzer' => 'english',
'default_operator' => 'AND'
]
],
'indices_boost' => [
SEARCH2_ORDERS_INDEX => 0.5
]
]
];