Watch 17 Star 26 Fork 11

bboss / elasticsearchdemoJavaApache-2.0

Sign up for free
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
bboss elastic开发demo spread retract

Clone or download
ESTracesMapper.xml 15.66 KB
Copy Edit Web IDE Raw Blame History
bboss authored 2018-03-18 20:11 . 增加suggest测试用例
<!--es
https://www.elastic.co/guide/en/elasticsearch/reference/5.5/query-dsl-term-query.html
https://www.elastic.co/guide/en/elasticsearch/reference/5.5/query-dsl-range-query.html
-->
<properties>
<property name="testaaa">
<![CDATA[
{
"sort": [
{"startTime": "desc"},
{"_uid": "desc"}
],
"_source": [ "startTime", "elapsed","err" ],
"size":10000,
"query": {
"bool": {
"filter": [
{
"term": {
"applicationName.keyword": "pdp"
}
},
{
"range": {
"startTime": {
"gte": 1520407911063,
"lt": 1520409111063
}
}
}
]
}
}
}
]]>
</property>
<property name="queryTracesByCriteria">
<![CDATA[{
"sort": [
{"startTime": "desc"},
{"_uid": "desc"}
],
"_source": [ "startTime", "elapsed","err" ],
#if($lastStartTime && $lastStartTime > 0)
"search_after": [$lastStartTime,"trace#$lastId"],
#end
"size":10000,
"query": {
"bool": {
"filter": [
{
"term": {
"applicationName.keyword": "$application"
}
},
{
"range": {
"startTime": {
"gte": $startTime,
"lt": $endTime
}
}
}
]
}
}
}]]>
</property>
<!--
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html
select rpc, avg(elapsed) avg_elapsed, count(1) count from traces where start_time >= #{startTime} and start_time <= #{endTime} GROUP by rpc order by avg_elapsed desc
-->
<property name="queryServiceTracesAvgElapsed">
<![CDATA[
{
"query": {
"bool": {
"filter": [
{
"term": {
"applicationName.keyword": "$application"
}
},
{"range": {
"startTime": {
"gte": $startTime,
"lt": $endTime
}
}
}
]
}
},
"size":0,
"aggs": {
"traces": {
"terms": {
"field": "rpc.keyword",
"size":100,
"order": {"elapsed_stats.avg": "desc"}
},
"aggs":{
"elapsed_stats":{
"stats":{
"field":"elapsed"
}
},
"success_stats": {
"terms": { "field": "err" }
}
}
}
}
}
]]>
</property>
<!--
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-range-aggregation.html
{
"aggregations": {
"elapsed_ranges" : {
"buckets": [
{
"to": 50,
"doc_count": 2,
"elapsed_stats": {
"count": 2,
"min": 20,
"max": 47,
"avg": 33.5,
"sum": 67
}
},
{
"from": 50,
"to": 100,
"doc_count": 4,
"elapsed_stats": {
"count": 4,
"min": 60,
"max": 98,
"avg": 82.5,
"sum": 330
}
},
{
"from": 100,
"doc_count": 4,
"elapsed_stats": {
"count": 4,
"min": 134,
"max": 367,
"avg": 216,
"sum": 864
}
}
]
}
}
}
-->
<property name="queryPeriodsTopN">
<![CDATA[
{
"query": {
"bool": {
"filter": [
{
"term": {
"applicationName.keyword": "$application"
}
},
{
"range": {
"startTime": {
"gte": $startTime,
"lt": $endTime
}
}
}
]
}
},
"size": 0,
"aggs" : {
"elapsed_ranges" : {
"range" : {
"field" : "elapsed",
"keyed" : true,
"ranges" : [
{ "key" : "1秒", "to" : 1000 },
{ "key" : "3秒", "from" : 1000, "to" : 3000 },
{ "key" : "5秒", "from" : 3000, "to" : 5000 },
{ "key" : "5秒以上", "from" : 5000 }
]
},
"aggs" : {
"elapsed_stats" : {
"stats" : { "field" : "elapsed"}
}
}
}
}
}
]]>
</property>
<!--
分页查询和按日期分钟统计片段
应用:链路检索和统计查询,rpc时间段统计查询
{ "_score":"desc" },
-->
<property name="searchAfterAggs">
<![CDATA[
#if($traceScore)
#if($lastStartTime && $lastStartTime > 0)
#if($orderBy && $orderBy.equals("elapsed"))
"search_after": [$lastScore,$lastElapsed,$lastStartTime,"trace#$lastId"],
#else
"search_after": [$lastScore,$lastStartTime,"trace#$lastId"],
#end
#end
"size": $pageSize,
"sort": [
{"_score": "desc"},
#if($orderBy && $orderBy.equals("elapsed")){"elapsed": "desc"},#end
{"startTime": "desc"},
{"_uid": "desc"}
],
#else
#if($lastStartTime && $lastStartTime > 0)
#if($orderBy && $orderBy.equals("elapsed"))
"search_after": [$lastElapsed,$lastStartTime,"trace#$lastId"],
#else
"search_after": [$lastStartTime,"trace#$lastId"],
#end
#end
"size": $pageSize,
"sort": [
#if($orderBy && $orderBy.equals("elapsed")){"elapsed": "desc"},#end
{"startTime": "desc"},
{"_uid": "desc"}
],
#end
"aggs": {
"traces_date_histogram": {
"date_histogram": {
"field": "starttimeDate",
"interval": "1m",
"time_zone": "Asia/Shanghai",
"min_doc_count": 0
}
}
},]]>
</property>
<!--
全文检索查询条件
-->
<property name="qcondition">
<![CDATA[
"bool": {
"filter": [
{"range": {
"startTime": {
"gte": #[startTime],
"lt": #[endTime],
"format": "epoch_millis"
}
}}
#if($application && !$application.equals("_all"))
,
{"term": {
"applicationName.keyword": #[application]
}}
#end
#if($queryStatus.equals("success"))
,
{"term": {
"err": 0
}}
#elseif($queryStatus.equals("error"))
,
{"term": {
"err": 1
}}
#end
]
#if($queryCondition && !$queryCondition.equals(""))
,
"must": [
{
"query_string": {
"query": #[queryCondition],
"analyze_wildcard": true,
#if(!$searchFields)
"fields": ["rpc","params","agentId","applicationName","endPoint","remoteAddr"]
#else
"fields":[
#foreach($field in $searchFields)
#if($velocityCount > 0),#end "$field"
#end
]
#end
}
}
]
#end
}]]>
</property>
<!--
全文检索链路query dsl
-->
<property name="queryServiceByCondition">
<![CDATA[{
@{searchAfterAggs}
"query": {
@{qcondition}
},
"highlight": {
"pre_tags": [
"<mark>"
],
"post_tags": [
"</mark>"
],
"fields": {
"*": {}
},
"fragment_size": 2147483647
}
}]]></property>
<!--
精确查询条件
-->
<property name="exactQcondition">
<![CDATA[
"bool": {
"filter":[
{"range": {
"startTime": {
"gte": #[startTime],
"lt": #[endTime],
"format": "epoch_millis"
}
}}
#if($application && !$application.equals("_all"))
,
{"term": {
"applicationName.keyword": #[application]
}}
#end
#if($queryStatus.equals("success"))
,
{"term": {
"err": 0
}}
#elseif($queryStatus.equals("error"))
,
{"term": {
"err": 1
}}
#end
#if($queryCondition && !$queryCondition.equals(""))
,
{
"bool":{
"should":[
#if(!$searchFields)
{"term": {"rpc.keyword": "$queryCondition"}},
{"term": {"params.keyword": "$queryCondition"}},
{"term": {"agentId.keyword": "$queryCondition"}},
{"term": {"applicationName.keyword": "$queryCondition"}},
{"term": {"endPoint.keyword": "$queryCondition"}},
{"term": {"remoteAddr.keyword": "$queryCondition"}}
#else
#foreach($field in $searchFields)
#if($velocityCount > 0),#end {"term": {"${field}.keyword": "$queryCondition"}}
#end
#end
]
}
}
#end
]
}]]>
</property>
<!--
精确查找
分页查询和按日期分钟统计片段
应用:链路检索和统计查询,rpc时间段统计查询
{ "_score":"desc" },
-->
<property name="exactSearchAfterAggs">
<![CDATA[
#if($lastStartTime && $lastStartTime > 0)
#if($orderBy && $orderBy.equals("elapsed"))
"search_after": [$lastElapsed,$lastStartTime,"trace#$lastId"],
#else
"search_after": [$lastStartTime,"trace#$lastId"],
#end
#end
"size": $pageSize,
"sort": [
#if($orderBy && $orderBy.equals("elapsed")){"elapsed": "desc"},#end
{"startTime": "desc"},
{"_uid": "desc"}
],
"aggs": {
"traces_date_histogram": {
"date_histogram": {
"field": "starttimeDate",
"interval": "1m",
"time_zone": "Asia/Shanghai",
"min_doc_count": 0
}
}
},]]>
</property>
<property name="exactQueryServiceByCondition">
<![CDATA[{
@{exactSearchAfterAggs}
"query": {
@{exactQcondition}
}
}]]></property>
<property name="queryServiceDetailByRpc">
<![CDATA[{
@{exactSearchAfterAggs}
"query": {
"bool": {
"filter": [
{"term": {
"applicationName.keyword": "$application"
}},
{"term": {
"rpc.keyword": "$rpc"
}},
{"range": {
"startTime": {
"gte": $startTime,
"lt": $endTime
}}
}
]
}
}
}]]>
</property>
<property name="querySlowTraceTopN">
<![CDATA[{
"version": true,
"size": 100,
"sort": [
{"elapsed": "desc"}
],
"query": {
"bool": {
"filter": [
{"term": {
"applicationName.keyword": #[application]
}},
{"range": {
"startTime": {
"gte": #[startTime],
"lt": #[endTime]
}
}}
]
}
}
}]]></property>
<property name="createDemoDocument">
<![CDATA[{"applicationName" : #[applicationName],"agentStarttime" : #[agentStarttime],"contentbody" : #[contentbody]}]]>
</property>
</properties>

Comment ( 0 )

You need to Sign in for post a comment

Help Search

183227_9af5e6a8_1826025 111910_4d91f001_1826025