1.使用过滤查询{
"query": {
"bool": {
"should": [
{"wildcard": {
"path": {
"value": "*h:\\\\案件文书*"
}
}},
{"wildcard": {
"uuid": {
"value": "*5515*"
}
}}
],
"filter": {
"bool": {
"must": [
{"term": {
"size": 504832
}}
],
"must_not": [
{"term": {
"source.father_md5": "c548f1029a83bd103f5b7d392bb8cf9d"
}}
] } } }}}
2.直接查询
{
"query": {
"bool": {
"should": [
{"wildcard": {
"path": {
"value": "*h:\\\\案件文书*"
}
}},{
"wildcard": {
"uuid": {
"value": "*5515*"
}
}
}
],
"must": [
{"term": {
"size": 504832
}}
],
"must_not": [
{"term": {
"source.father_md5": "c548f1029a83bd103f5b7d392bb8cf9d"
}}
]
}
}
}
两个查询结果是一样的,数据总量大概为一千三百万,网上说过滤会比直接查快一点,但是我这两个查询速度差不多,是我的数据比较少体现不出来吗
"query": {
"bool": {
"should": [
{"wildcard": {
"path": {
"value": "*h:\\\\案件文书*"
}
}},
{"wildcard": {
"uuid": {
"value": "*5515*"
}
}}
],
"filter": {
"bool": {
"must": [
{"term": {
"size": 504832
}}
],
"must_not": [
{"term": {
"source.father_md5": "c548f1029a83bd103f5b7d392bb8cf9d"
}}
] } } }}}
2.直接查询
{
"query": {
"bool": {
"should": [
{"wildcard": {
"path": {
"value": "*h:\\\\案件文书*"
}
}},{
"wildcard": {
"uuid": {
"value": "*5515*"
}
}
}
],
"must": [
{"term": {
"size": 504832
}}
],
"must_not": [
{"term": {
"source.father_md5": "c548f1029a83bd103f5b7d392bb8cf9d"
}}
]
}
}
}
两个查询结果是一样的,数据总量大概为一千三百万,网上说过滤会比直接查快一点,但是我这两个查询速度差不多,是我的数据比较少体现不出来吗
2 个回复
mfy - es初学者
赞同来自: hansongnan
hansongnan
赞同来自:
"query": {
"bool": {
"filter": {
"bool": {
"should": [
{"wildcard": {
"path": {
"value": "*h:\\\\案件文书*"
}
}},{
"wildcard": {
"uuid": {
"value": "*5515*"
}
}
}
],
"must": [
{"term": {
"size": 504832
}}
],
"must_not": [
{"term": {
"source.father_md5": "c548f1029a83bd103f5b7d392bb8cf9d"
}}
]
}
}}
}
}但是通过这种方法 查询的结果却变少了,正则查找是不能用 filter嘛