更新时间:2023-02-05 12:57:30
如果尚未显式定义任何映射,则需要将.keyword添加到 title
字段.这将使用关键字分析器而不是标准分析器(请注意标题字段后的".keyword").
If you have not explicitly defined any mapping then you need to add .keyword to the title
field. This uses the keyword analyzer instead of the standard analyzer (notice the ".keyword" after title field).
添加包含索引数据,搜索查询和搜索结果的工作示例
Adding a working example with index data, search query and search result
索引数据:
{
"title": "This is test product"
}
{
"title": "test product"
}
搜索查询:
{
"query": {
"query_string": {
"fields": [
"title.keyword"
],
"query": "test product"
}
}
}
搜索结果:
"hits": [
{
"_index": "67107104",
"_type": "_doc",
"_id": "1",
"_score": 0.6931471,
"_source": {
"title": "test product"
}
}
]
使用匹配查询的搜索查询:
{
"query": {
"match": {
"title.keyword": "test product"
}
}
}
使用词条查询的搜索查询
{
"query": {
"term": {
"title.keyword": "test product"
}
}
}