Profile API
The Profile API is used to locate abnormal query time problems. You can enable the Profile API by providing “Profile: True” at the top of the Query section.
GET /_search
{
"profile": true,
"query" : {
"match" : { "message" : "message number" }
}
}
Copy the code
The profile interface returns the following information:
{
"profile": {
"shards": [
{
"id": "[2aE02wS1R8q_QFnYu6vDVQ][twitter][1]",
"searches": [
{
"query": [...],
"rewrite_time": 51443,
"collector": [...]
}
],
"aggregations": [...]
}
]
}
}
Copy the code
Returns searches containing the shard ID, search process information, and aggregation information aggregations.
There are three other elements in searches:
- query
- rewrite_time
- collecotor
Aggregations contain specific execution information during the aggregation process.
Elements of meaning
Query
"query": [ { "type": "BooleanQuery", "description": "message:message message:number", "time": Breakdown: {"score": 51306, "score_count": 4, "build_scorer": 2935582, "build_scorer_count": 1, "match": 0, "match_count": 0, "create_weight": 919297, "create_weight_count": 1, "next_doc": 53876, "next_doc_count": 5, "advance": 0, "advance_count": 0 }, "children": [ { "type": "TermQuery", "description": "Message :message", "time": "0.3919430000ms", "breakdown": {"score": 28776, "score_count": 4, "build_scorer": 784451, "build_scorer_count": 1, "match": 0, "match_count": 0, "create_weight": 1669564, "create_weight_count": 1, "next_doc": 10111, "next_doc_count": 5, "advance": 0, "advance_count": 0 } }, { "type": "TermQuery", "description": "Message :number", "time":" 0.210680000MS ", "breakdown": {"score": 4552, "score_count": 4, "build_scorer": 42602, "build_scorer_count": 1, "match": 0, "match_count": 0, "create_weight": 89323, "create_weight_count": 1, "next_doc": 2852, "next_doc_count": 5, "advance": 0, "advance_count": 0 } } ] } ]Copy the code
- Type: displays what type of query is triggered. Common examples are BooleanQuery and TermQuery
- Time: time used to execute the query
- Breakdown: The more detailed details of the query, mainly related to the Lucene parameters
- Chidren: Boolean queries that have multiple keywords are split into corresponding terms
Rewrite Time
"rewrite_time": 51443
Copy the code
Because multiple keywords are decomposed to create individual queries, this process is bound to take some time. The time it takes to rewrite a query to one or more combined queries is called “rewrite time.”
Collectors
"Collector" : [{"name": "CancellableCollector", "reason": "search_cancelled", "time": "0.3043110000ms", "children": [{" name ":" SimpleTopScoreDocCollector ", "" reason" : "search_top_hits", "time" : "0.03227300000" ms}]}]Copy the code
In Lucene, the collector is responsible for collecting raw results, collecting and combining results, performing results ordering, and so on.
Kibana visual profile analysis
In addition to using the Profile API, using Kibana to visualize the Profile interface is more intuitive.
The interface is divided into query Profile and Aggregation Profile, and lists the time and proportion of the request process in detail. It is more intuitive and recommended.