【发布时间】:2015-12-22 17:56:30
【问题描述】:
我正在尝试在 filtered 查询上使用 filter,这就是我正在尝试使用 Sense:
GET myindex/catalog/_search
{
"query": {
"filtered": {
"query": {
"query_string": {
"analyze_wildcard": true,
"query": "test",
"fields": ["title^3.5", "contributions.authors.name^5", "publisher^2", "formats.productCode^0.5", "description^0.1"],
"use_dis_max": true
}
},
"filter": {
"term": {
"sku": "test-687"
}
}
}
}
}
此查询没有任何命中,但如果我删除 filter 属性,我会得到带有 sku = test-687 的项目。
我不明白为什么带有 filter 的查询没有给我相同的结果。
映射:
{
"myindex": {
"mappings": {
"catalog": {
"properties": {
"sku": {
"type": "string"
},
"title": {
"type": "string"
},
"updated_at": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
}
}
}
}
}
}
【问题讨论】:
-
字段
sku是精确的test-687。 -
术语是小写/大写敏感。您对“sku”字段的映射是什么?
-
我告诉过你,这正是
test-687,不可能是大小写问题。 -
你使用了什么映射?例如,在我的弹性索引中,我有一个以大写显示的字段,但在映射中它是小写的,我需要使用 term 搜索小写的值
-
字段名正好是
sku:"sku": {"type": "string"}
标签: elasticsearch filter