【发布时间】:2021-08-27 16:39:17
【问题描述】:
问题 我正在尝试编写一个匹配映射类型(MyFirstMappingType)的所有属性的 ElasticSearch 查询。如果一个属性不匹配,则不应返回该项目。他们不应该混合匹配来获得匹配。
映射
"mappings": {
"item": {
"_all": { "enabled": "false" },
"properties": {
"MyFirstMappingType": {
"properties": {
"field1": { "type": "keyword" },
"field2": { "type": "keyword" },
"field3": { "type": "text", "index": "false" }
}
}
}
}
}
当项目与这些字段中的每一个匹配时,此查询将返回项目。但是当一个项目有多个“MyFirstMappingType”时,它会混合搭配。例如,这个查询仍然会返回这个项目。
GET myfirst/item/_search
{
"from": 0,
"size": 38,
"_source": [
"MyFirstMappingType"
],
"query": {
"bool": {
"filter": [
{
"term": {
"field1": "foo"
}
},
{
"term": {
"field2": "bar"
}
},
{
"term": {
"field3": "world"
}
}
}
]
}
}
"MyFirstMappingType" : [
{
"field1" : "foo",
"field2" : "bar",
"field3" : "hello"
},
{
"field1" : "foo",
"field2" : "world",
"field3" : "foo"
},
{
"field1" : "foo",
"field2" : "foo",
"field3" : "world"
}
]
【问题讨论】:
标签: elasticsearch kibana elasticsearch-query