【发布时间】:2019-05-08 17:13:11
【问题描述】:
我在使用 Elastic Search 时遇到了一些挑战。我想通过一些文本进行查询,然后根据类别进行过滤。我关注了Elastic Search 6.3 Documentation for Queries,但我对ES 的回复总是空的。我知道我至少有一个条目应该匹配请求。下面我已将我的查询发布到 Elastic Search,并且我知道的条目存在于我的 Elastic Search 索引中。很感谢任何形式的帮助。
查询
{
"from": 0,
"size": 300,
"query": {
"bool": {
"filter": {
"term": {"category": "Soups"}
},
"should": [
{"term": {"instructions": "Matt"}},
{"term": {"introduction": "Matt"}},
{"term": {"recipe_name": "Matt"}},
],
"minimum_should_match": 1,
"boost": 1.0
}
}
}
记录存在于 Elastic Search 中
{
"_index": "recipes",
"_type": "_doc",
"_id": "QMCScWoBkkkjW61rD81v",
"_score": 0.2876821,
"_source": {
"calories": 124,
"category": "Soups",
"cook_time": {
"hour": "2",
"min": "4"
},
"cooking_temp": "375",
"cooking_temp_units": "°F",
"creator_username": "virtualprodigy",
"ingredients": [
{
"majorQuantity": "1 ",
"measuring_units": "teaspoon",
"minorQuantity": " ",
"name": "mett"
}
],
"instructions": "instructions",
"introduction": "intro",
"prep_time": {
"hour": "1",
"min": "2"
},
"recipe_name": "Matt Test",
"servings": 1
}
}
【问题讨论】:
-
您正在使用术语查询来获取说明、介绍和食谱名称以全部匹配 Matt。词条查询与词条完全匹配 see docs,并且这些词条都没有完全匹配Matt。介绍=“介绍”,说明=“说明”和配方名称=“马特测试”。尝试使用多重匹配查询和分析器将查询和索引分解为简单的术语。您使用的过滤器似乎没有问题。
标签: elasticsearch aws-elasticsearch