我想使用npm install --save @types/<your package name>
&#39; Elasticsearch 5
api来查找搜索执行计划。
以下是我的两个不同的查询:
1:
profile
2:
"query": {
"bool": {
"should": [
{
"term": {
"field1": "f1"
}
},
{
"range": {
"field3": {
"gt": "1"
}
}
}
]
}
}
两个查询之间的区别仅在于"query": {
"bool": {
"filter": [
{
"term": {
"field1": "f1"
}
},
{
"range": {
"field3": {
"gt": "1"
}
}
}
]
}
}
使用query1
而should
使用query2
。
但是两个查询的filter
children
结果是相同的。
如:
profile
"children": [
{
"type": "BooleanQuery",
"description": "field1:f1 field3:[2 TO 9223372036854775807]",
"time": "0.06531500000ms",
"breakdown": {
"score": 0,
"build_scorer_count": 0,
"match_count": 0,
"create_weight": 65314,
"next_doc": 0,
"match": 0,
"create_weight_count": 1,
"next_doc_count": 0,
"score_count": 0,
"build_scorer": 0,
"advance": 0,
"advance_count": 0
},
"children": [
{
"type": "TermQuery",
"description": "field1:f1",
"time": "0.05287500000ms",
"breakdown": {
"score": 0,
"build_scorer_count": 0,
"match_count": 0,
"create_weight": 52874,
"next_doc": 0,
"match": 0,
"create_weight_count": 1,
"next_doc_count": 0,
"score_count": 0,
"build_scorer": 0,
"advance": 0,
"advance_count": 0
}
},
{
"type": "",
"description": "field3:[2 TO 9223372036854775807]",
"time": "0.001556000000ms",
"breakdown": {
"score": 0,
"build_scorer_count": 0,
"match_count": 0,
"create_weight": 1555,
"next_doc": 0,
"match": 0,
"create_weight_count": 1,
"next_doc_count": 0,
"score_count": 0,
"build_scorer": 0,
"advance": 0,
"advance_count": 0
}
}
]
}]
创建多个线程,然后每个线程执行一个ElasticSearch
项,然后结果合并到最后?
但在我看来,我认为filter
将使用es
,逐个执行filter pipeline
个项目。例如elasticsearch-order-of-filters-for-best-performance说
在案例1中,执行速度会变慢,因为过去一个月的所有文档都需要首先通过过滤器A,而不是高速缓存。
在案例2中,您首先过滤掉所有没有XYZ类型的文档,这很快,因为过滤器B被缓存。然后,通过过滤器B的文档可以通过过滤器A.因此,即使过滤器A没有被缓存,执行仍然会更快,因为过滤器管道中剩余的文档较少。
如何执行多个过滤器项?