Description
The searches.query
part of the profile output is supposed to contain all the queries executed against one shard.
It's initiated at the createWeight() method of ContextIndexSearcher.
However, I am seeing multiple segment level queries being put alongside the shard level query.
Below is a minimal example. The query against shard is the BoostQuery. The shard here contains 2 segments, and we see 2 more BooleanQuery for each segment.
The BooleanQuery is written when supplying scorer per segment in AbstractMultiTermQueryConstantScoreWrapper. As you can, searcher.rewrite(q).createWeight()
is used and that calls createWeight() method of ContextIndexSearcher to profile this segment level query.
Minimal Example
Ingest first 1k documents from big5Query
curl "localhost:9200/big5/_search?pretty" -H 'Content-Type: application/json' -d '
{"profile":true,"query":{"bool":{"filter":{"terms":{"host.name":["bushsnake","butterseer"]}}}}}
'
Profile output
{
"shards": [{
"id": "[oypffhcuTduGlI36pifPmA][big5][0]",
"inbound_network_time_in_millis": 0,
"outbound_network_time_in_millis": 0,
"searches": [{
"query": [{
"type": "BoostQuery",
"description": "(ConstantScore(host.name:(bushsnake butterseer)))^0.0",
"time_in_nanos": 516582,
"breakdown": {
"set_min_competitive_score_count": 0,
"match_count": 0,
"shallow_advance_count": 0,
"next_doc": 24625,
"score_count": 20,
"compute_max_score_count": 0,
"advance": 0,
"advance_count": 0,
"score": 1041,
"shallow_advance": 0,
"create_weight_count": 1,
"build_scorer": 471250,
"set_min_competitive_score": 0,
"match": 0,
"next_doc_count": 22,
"compute_max_score": 0,
"build_scorer_count": 4,
"create_weight": 19666
},
"children": [{
"type": "MultiTermQueryConstantScoreBlendedWrapper",
"description": "host.name:(bushsnake butterseer)",
"time_in_nanos": 499124,
"breakdown": {
"set_min_competitive_score_count": 0,
"match_count": 0,
"shallow_advance_count": 0,
"next_doc": 20873,
"score_count": 0,
"compute_max_score_count": 0,
"advance": 0,
"advance_count": 0,
"score": 0,
"shallow_advance": 0,
"create_weight_count": 1,
"build_scorer": 463710,
"set_min_competitive_score": 0,
"match": 0,
"next_doc_count": 22,
"compute_max_score": 0,
"build_scorer_count": 4,
"create_weight": 14541
}
}]
},
{
"type": "BooleanQuery",
"description": "host.name:bushsnake host.name:butterseer",
"time_in_nanos": 163751,
"breakdown": {
"set_min_competitive_score_count": 0,
"match_count": 0,
"shallow_advance_count": 0,
"next_doc": 11044,
"score_count": 0,
"compute_max_score_count": 0,
"advance": 0,
"advance_count": 0,
"score": 0,
"shallow_advance": 0,
"create_weight_count": 1,
"build_scorer": 134791,
"set_min_competitive_score": 0,
"match": 0,
"next_doc_count": 18,
"compute_max_score": 0,
"build_scorer_count": 2,
"create_weight": 17916
},
"children": [{
"type": "TermQuery",
"description": "host.name:bushsnake",
"time_in_nanos": 65878,
"breakdown": {
"set_min_competitive_score_count": 0,
"match_count": 0,
"shallow_advance_count": 0,
"next_doc": 3420,
"score_count": 0,
"compute_max_score_count": 0,
"advance": 0,
"advance_count": 0,
"score": 0,
"shallow_advance": 0,
"create_weight_count": 1,
"build_scorer": 56083,
"set_min_competitive_score": 0,
"match": 0,
"next_doc_count": 9,
"compute_max_score": 0,
"build_scorer_count": 3,
"create_weight": 6375
}
},
{
"type": "TermQuery",
"description": "host.name:butterseer",
"time_in_nanos": 10957,
"breakdown": {
"set_min_competitive_score_count": 0,
"match_count": 0,
"shallow_advance_count": 0,
"next_doc": 915,
"score_count": 0,
"compute_max_score_count": 0,
"advance": 0,
"advance_count": 0,
"score": 0,
"shallow_advance": 0,
"create_weight_count": 1,
"build_scorer": 9292,
"set_min_competitive_score": 0,
"match": 0,
"next_doc_count": 10,
"compute_max_score": 0,
"build_scorer_count": 3,
"create_weight": 750
}
}
]
},
{
"type": "BooleanQuery",
"description": "host.name:bushsnake host.name:butterseer",
"time_in_nanos": 53708,
"breakdown": {
"set_min_competitive_score_count": 0,
"match_count": 0,
"shallow_advance_count": 0,
"next_doc": 4166,
"score_count": 0,
"compute_max_score_count": 0,
"advance": 0,
"advance_count": 0,
"score": 0,
"shallow_advance": 0,
"create_weight_count": 1,
"build_scorer": 41917,
"set_min_competitive_score": 0,
"match": 0,
"next_doc_count": 4,
"compute_max_score": 0,
"build_scorer_count": 2,
"create_weight": 7625
},
"children": [{
"type": "TermQuery",
"description": "host.name:bushsnake",
"time_in_nanos": 15419,
"breakdown": {
"set_min_competitive_score_count": 0,
"match_count": 0,
"shallow_advance_count": 0,
"next_doc": 1877,
"score_count": 0,
"compute_max_score_count": 0,
"advance": 0,
"advance_count": 0,
"score": 0,
"shallow_advance": 0,
"create_weight_count": 1,
"build_scorer": 11959,
"set_min_competitive_score": 0,
"match": 0,
"next_doc_count": 3,
"compute_max_score": 0,
"build_scorer_count": 3,
"create_weight": 1583
}
},
{
"type": "TermQuery",
"description": "host.name:butterseer",
"time_in_nanos": 6625,
"breakdown": {
"set_min_competitive_score_count": 0,
"match_count": 0,
"shallow_advance_count": 0,
"next_doc": 43,
"score_count": 0,
"compute_max_score_count": 0,
"advance": 0,
"advance_count": 0,
"score": 0,
"shallow_advance": 0,
"create_weight_count": 1,
"build_scorer": 5874,
"set_min_competitive_score": 0,
"match": 0,
"next_doc_count": 2,
"compute_max_score": 0,
"build_scorer_count": 3,
"create_weight": 708
}
}
]
}
],
"rewrite_time": 87708,
"collector": [{
"name": "TopScoreDocCollector",
"reason": "search_top_hits",
"time_in_nanos": 17040
}]
}],
"aggregations": []
}]
}
Expect
I think it's better to move the segment level Query under the shard level Query. And label those segment level Query with specific segment id. So here, the 2 BooleanQuery should be children of MultiTermQueryConstantScoreBlendedWrapper.
Metadata
Metadata
Assignees
Type
Projects
Status
Status