当前位置: 首页 > elasticsearch, 搜索 > 正文

elasticsearch index.search.slowlog.query解释

1 星2 星3 星4 星5 星 (2 次投票, 评分: 5.00, 总分: 5)
Loading ... Loading ...
baidu_share

今天查看了一下elasticsearch的elasticsearch_index_search_slowlog.log日志。

[2013-11-27 13:02:51,436][TRACE][index.search.slowlog.query] [h35] [cms][2] took[1.1s], took_millis[1136], types[news], stats[], search_type[QUERY_THEN_FETCH], total_shards[10], source[{"from":250,"size":10,"query":{"custom_score":{"query":{"filtered":{"query":{"query_string":{"query":"尼日利亚","fields":["title","content"],"analyzer":"ik"}},"filter":{"bool":{"must":{"range":{"updatetime":{"from":1353992570,"to":1385528570,"include_lower":true,"include_upper":true}}}}}}},"script":"long x=Long.parseLong(doc['updatetime'].value);x=x/86400l;long nows=yy/86400l;int nowDay=(int)nows;int day=(int)x;if (day < nowDay) {int temp=nowDay-day;int delta=(int)temp/5+1;if(delta<32){_score=_score+6*pow(0.9,delta);}else{_score=_score+3*pow(0.9,31);}} else if (day > nowDay) {_score=_score+3*pow(0.9,31);} else{_score=_score+3;}","params":{"yy":1385528570}}},"fields":["id","channelid","catid","model","title","content","thumb","url","updatetime"],"sort":[{"_score":{"order":"desc"}},{"updatetime":{"order":"desc"}}],"highlight":{"pre_tags":["<em>"],"post_tags":["</em>"],"encoder":"UTF-8","fields":{"title":{},"content":{"fragment_size":72,"number_of_fragments":3}}}}], extra_source[]

查询慢日志,发现很多条相同的记录。查阅了一些资料,给出的解释是:

在分片(shard)水平上,该慢日志(slowlog)并不是指http请求,而是指查询。这就意味着,你查询的索引有5个分片(shard),你就有5条相同记录的日志。每一个分片(shard),有一个不同的分片(shard)id,它在索引名称之后显示。这样,你可以监控每个查询的执行每一个分片(shard).

获取行是获取的解析。默认情况下,query_then_fetch search type 是使用的。这意味着如果你查询一个5个分片(shard)的索引(让我们假设0副本,使其更简单),该查询将在每个分片(shard)执行,这将只返回像文档ID以及他们的得分(score)的相关信息。查询请求选中的节点将减少结果,以便只返回前几名。之后,减少的部分是确定哪些需要被返回的文档,只有那些相关的文档才从它们的分片取出。这就是你所看到的慢日志获取解析。

原英文原文:
The slowlog doesn’t refer to http requests but to queries, on the shard level. That means that if you query an index composed of 5 shards you’ll have in the log 5 entries for the same query, one per shard, with a different shard id, which is the number that appears right after the index name. That way you can monitor the execution of each query for each shard.

The fetch line refers to the fetch phase. By default the query_then_fetch search type is used, which means that if you query an index composed of 5 primary shards (let’s assume 0 replica to make it simpler), the query will be executed on each shard, which will return only the relevant information like the document ids and their scores. The node that you hit with your search request will then reduce those results in order to return only the top ones. After the reduce part that identifies which documents need to be returned, only those relevant documents are then fetched from their shard. That’s when you see the fetch phase in your slowlog.

参考文章:Elasticsearch log explanation

本文固定链接: http://www.chepoo.com/elasticsearch-index-search-slowlog-query-explanation.html | IT技术精华网

elasticsearch index.search.slowlog.query解释:等您坐沙发呢!

发表评论