【发布时间】:2022-11-29 14:48:36
【问题描述】:
我正在尝试在本地设置一个基本的 Elasticsearch 索引并使用 Kibana,当我进行 match_all 搜索时,我能够获得所有结果,但我已经尝试了简单匹配查询的多种变体,但都没有用。
我的映射:
{
"recipes-v1": {
"mappings": {
"dynamic": "false",
"properties": {
"description": {
"type": "keyword"
},
"ingredients": {
"type": "text"
},
"instructions": {
"type": "keyword"
},
"title": {
"type": "keyword"
}
}
}
}
}
match_all 查询的结果:
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "recipes-v1",
"_id": "0",
"_score": 1,
"_source": {
"Name": "Alfredo Sauce",
"Description": "Cheesy alfredo sauce that is delicious. Definitely not vegan",
"Ingredients": [
"1/2 cup butter",
"3 cloves garlic",
"3/4 cup heavy cream",
"1/2 cup parmesan cheese",
"1/2 cup romano cheese",
"salt",
"pepper",
"italian seasoning"
],
"Instructions": [
"Melt butter in a saucepan then add heavy cream and combine on medium low heat",
"Let the mixture simmer for 2 minutes then add garlic, salt, pepper, and italian seasoning to taste. Let simmer until fragrent (about 1 minute)",
"Lower heat and add both cheeses, stirring until relatively melted",
"Let simmer, stirring often to prevent getting stuck to the bottom"
]
}
},
{
"_index": "recipes-v1",
"_id": "1",
"_score": 1,
"_source": {
"Name": "Shrimp Scampi",
"Description": "Definitely not just Gordon Ramsay's shrimp scampi minus capers",
"Ingredients": [
"1 lb shrimp",
"2 lemons",
"Zest of lemons",
"3 cloves garlic"
],
"Instructions": [
"Do things",
"Do more things"
]
}
}
]
}
}
我试过删除索引并重新创建它以及 Alfredo、alfredo、alfredo sauce、AlfredoSauce 等的每个变体,但都没有用。请帮忙 这些查询的所有变体都不会产生任何命中:
POST recipes-v1/_search
{
"query": {
"match": {
"title": {
"query": "alfredo"
}
}
}
}
POST recipes-v1/_search
{
"query": {
"bool": {
"should": {
"match": {
"name": "alfredo"
}
}
}
}
}
【问题讨论】:
标签: elasticsearch elasticsearch-dsl