Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
程序猿小郑
microservices-platform
提交
322fe40d
microservices-platform
项目概览
程序猿小郑
/
microservices-platform
与 Fork 源项目一致
Fork自
zlt2000 / microservices-platform
通知
4
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
microservices-platform
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
322fe40d
编写于
7月 12, 2020
作者:
zlt2000
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
升级search-center支持ES7.x,不支持6.x版本
上级
c3584a31
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
61 addition
and
66 deletion
+61
-66
pom.xml
pom.xml
+1
-1
zlt-business/search-center/search-server/src/main/java/com/central/admin/service/impl/IndexServiceImpl.java
...java/com/central/admin/service/impl/IndexServiceImpl.java
+24
-41
zlt-business/search-center/search-server/src/main/java/com/central/search/service/impl/AggregationServiceImpl.java
...m/central/search/service/impl/AggregationServiceImpl.java
+20
-17
zlt-commons/zlt-elasticsearch-spring-boot-starter/src/main/java/com/central/es/utils/SearchBuilder.java
...ter/src/main/java/com/central/es/utils/SearchBuilder.java
+16
-1
zlt-web/back-web/src/main/resources/static/pages/search/index_manager_form.html
...ain/resources/static/pages/search/index_manager_form.html
+0
-6
未找到文件。
pom.xml
浏览文件 @
322fe40d
...
@@ -49,7 +49,7 @@
...
@@ -49,7 +49,7 @@
<commons-io.version>
2.6
</commons-io.version>
<commons-io.version>
2.6
</commons-io.version>
<servlet-api.version>
4.0.1
</servlet-api.version>
<servlet-api.version>
4.0.1
</servlet-api.version>
<spring-data-elasticsearch.version>
3.2.7.RELEASE
</spring-data-elasticsearch.version>
<spring-data-elasticsearch.version>
3.2.7.RELEASE
</spring-data-elasticsearch.version>
<elasticsearch.version>
6.8.8
</elasticsearch.version>
<elasticsearch.version>
7.8.0
</elasticsearch.version>
<docker-maven-plugin.version>
1.2.2
</docker-maven-plugin.version>
<docker-maven-plugin.version>
1.2.2
</docker-maven-plugin.version>
<sonar.exclusions>
zlt-job/**/*, zlt-register/**/*, zlt-web/**/*
</sonar.exclusions>
<sonar.exclusions>
zlt-job/**/*, zlt-register/**/*, zlt-web/**/*
</sonar.exclusions>
<docker.baseImage>
openjdk:8-jre-alpine
</docker.baseImage>
<docker.baseImage>
openjdk:8-jre-alpine
</docker.baseImage>
...
...
zlt-business/search-center/search-server/src/main/java/com/central/admin/service/impl/IndexServiceImpl.java
浏览文件 @
322fe40d
...
@@ -2,50 +2,50 @@ package com.central.admin.service.impl;
...
@@ -2,50 +2,50 @@ package com.central.admin.service.impl;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.carrotsearch.hppc.cursors.ObjectCursor
;
import
com.central.admin.model.IndexDto
;
import
com.central.admin.model.IndexDto
;
import
com.central.admin.service.IIndexService
;
import
com.central.admin.service.IIndexService
;
import
com.central.common.model.PageResult
;
import
com.central.common.model.PageResult
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.apache.http.util.EntityUtils
;
import
org.apache.http.util.EntityUtils
;
import
org.elasticsearch.action.admin.indices.create.CreateIndexRequest
;
import
org.elasticsearch.client.indices.CreateIndexRequest
;
import
org.elasticsearch.action.admin.indices.create.CreateIndexResponse
;
import
org.elasticsearch.client.indices.CreateIndexResponse
;
import
org.elasticsearch.client.indices.GetIndexRequest
;
import
org.elasticsearch.client.indices.GetIndexResponse
;
import
org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest
;
import
org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest
;
import
org.elasticsearch.action.admin.indices.get.GetIndexRequest
;
import
org.elasticsearch.action.admin.indices.get.GetIndexResponse
;
import
org.elasticsearch.action.support.master.AcknowledgedResponse
;
import
org.elasticsearch.action.support.master.AcknowledgedResponse
;
import
org.elasticsearch.client.Request
;
import
org.elasticsearch.client.Request
;
import
org.elasticsearch.client.RequestOptions
;
import
org.elasticsearch.client.RequestOptions
;
import
org.elasticsearch.client.Response
;
import
org.elasticsearch.client.Response
;
import
org.elasticsearch.cluster.metadata.AliasMetaData
;
import
org.elasticsearch.cluster.metadata.AliasMetadata
;
import
org.elasticsearch.cluster.metadata.MappingMetaData
;
import
org.elasticsearch.cluster.metadata.MappingMetadata
;
import
org.elasticsearch.common.collect.ImmutableOpenMap
;
import
org.elasticsearch.common.settings.Settings
;
import
org.elasticsearch.common.settings.Settings
;
import
org.elasticsearch.common.xcontent.XContentType
;
import
org.elasticsearch.common.xcontent.XContentType
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate
;
import
org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* 索引
* 索引
*
*
* @author zlt
* @author zlt
* @date 2019/4/23
* @date 2019/4/23
* <p>
* Blog: https://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
*/
@Service
@Service
public
class
IndexServiceImpl
implements
IIndexService
{
public
class
IndexServiceImpl
implements
IIndexService
{
@Autowired
private
ElasticsearchRestTemplate
elasticsearchRestTemplate
;
private
ObjectMapper
mapper
=
new
ObjectMapper
();
private
ObjectMapper
mapper
=
new
ObjectMapper
();
private
final
ElasticsearchRestTemplate
elasticsearchRestTemplate
;
public
IndexServiceImpl
(
ElasticsearchRestTemplate
elasticsearchRestTemplate
)
{
this
.
elasticsearchRestTemplate
=
elasticsearchRestTemplate
;
}
@Override
@Override
public
boolean
create
(
IndexDto
indexDto
)
throws
IOException
{
public
boolean
create
(
IndexDto
indexDto
)
throws
IOException
{
CreateIndexRequest
request
=
new
CreateIndexRequest
(
indexDto
.
getIndexName
());
CreateIndexRequest
request
=
new
CreateIndexRequest
(
indexDto
.
getIndexName
());
...
@@ -53,9 +53,9 @@ public class IndexServiceImpl implements IIndexService {
...
@@ -53,9 +53,9 @@ public class IndexServiceImpl implements IIndexService {
.
put
(
"index.number_of_shards"
,
indexDto
.
getNumberOfShards
())
.
put
(
"index.number_of_shards"
,
indexDto
.
getNumberOfShards
())
.
put
(
"index.number_of_replicas"
,
indexDto
.
getNumberOfReplicas
())
.
put
(
"index.number_of_replicas"
,
indexDto
.
getNumberOfReplicas
())
);
);
if
(
StrUtil
.
isNotEmpty
(
indexDto
.
get
Type
())
&&
StrUtil
.
isNotEmpty
(
indexDto
.
get
MappingsSource
()))
{
if
(
StrUtil
.
isNotEmpty
(
indexDto
.
getMappingsSource
()))
{
//mappings
//mappings
request
.
mapping
(
indexDto
.
get
Type
(),
indexDto
.
get
MappingsSource
(),
XContentType
.
JSON
);
request
.
mapping
(
indexDto
.
getMappingsSource
(),
XContentType
.
JSON
);
}
}
CreateIndexResponse
response
=
elasticsearchRestTemplate
.
getClient
()
CreateIndexResponse
response
=
elasticsearchRestTemplate
.
getClient
()
.
indices
()
.
indices
()
...
@@ -87,24 +87,14 @@ public class IndexServiceImpl implements IIndexService {
...
@@ -87,24 +87,14 @@ public class IndexServiceImpl implements IIndexService {
return
PageResult
.<
Map
<
String
,
String
>>
builder
().
data
(
listOfIndicesFromEs
).
code
(
0
).
build
();
return
PageResult
.<
Map
<
String
,
String
>>
builder
().
data
(
listOfIndicesFromEs
).
code
(
0
).
build
();
}
}
/**
* bytes 转换为 kb
*/
private
Double
getKB
(
Long
bytes
)
{
if
(
bytes
==
null
)
{
return
0
D
;
}
return
bytes
/
1024
D
;
}
@Override
@Override
public
Map
<
String
,
Object
>
show
(
String
indexName
)
throws
IOException
{
public
Map
<
String
,
Object
>
show
(
String
indexName
)
throws
IOException
{
GetIndexRequest
request
=
new
GetIndexRequest
();
GetIndexRequest
request
=
new
GetIndexRequest
(
indexName
);
request
.
indices
(
indexName
);
GetIndexResponse
getIndexResponse
=
elasticsearchRestTemplate
.
getClient
()
GetIndexResponse
getIndexResponse
=
elasticsearchRestTemplate
.
getClient
()
.
indices
().
get
(
request
,
RequestOptions
.
DEFAULT
);
.
indices
().
get
(
request
,
RequestOptions
.
DEFAULT
);
ImmutableOpenMap
<
String
,
MappingMetaData
>
mappOpenMap
=
getIndexResponse
.
getMappings
().
get
(
indexName
);
MappingMetadata
mappingMetadata
=
getIndexResponse
.
getMappings
().
get
(
indexName
);
List
<
AliasMetaData
>
indexAliases
=
getIndexResponse
.
getAliases
().
get
(
indexName
);
Map
<
String
,
Object
>
mappOpenMap
=
mappingMetadata
.
getSourceAsMap
();
List
<
AliasMetadata
>
indexAliases
=
getIndexResponse
.
getAliases
().
get
(
indexName
);
String
settingsStr
=
getIndexResponse
.
getSettings
().
get
(
indexName
).
toString
();
String
settingsStr
=
getIndexResponse
.
getSettings
().
get
(
indexName
).
toString
();
Object
settingsObj
=
null
;
Object
settingsObj
=
null
;
...
@@ -113,20 +103,13 @@ public class IndexServiceImpl implements IIndexService {
...
@@ -113,20 +103,13 @@ public class IndexServiceImpl implements IIndexService {
}
}
Map
<
String
,
Object
>
result
=
new
HashMap
<>(
1
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>(
1
);
Map
<
String
,
Object
>
indexMap
=
new
HashMap
<>(
3
);
Map
<
String
,
Object
>
indexMap
=
new
HashMap
<>(
3
);
Map
<
String
,
Object
>
mappMap
=
new
HashMap
<>(
mappOpenMap
.
size
());
List
<
String
>
aliasesList
=
new
ArrayList
<>(
indexAliases
.
size
());
List
<
String
>
aliasesList
=
new
ArrayList
<>(
indexAliases
.
size
());
indexMap
.
put
(
"aliases"
,
aliasesList
);
indexMap
.
put
(
"aliases"
,
aliasesList
);
indexMap
.
put
(
"settings"
,
settingsObj
);
indexMap
.
put
(
"settings"
,
settingsObj
);
indexMap
.
put
(
"mappings"
,
mappMap
);
indexMap
.
put
(
"mappings"
,
mapp
Open
Map
);
result
.
put
(
indexName
,
indexMap
);
result
.
put
(
indexName
,
indexMap
);
//获取mappings数据
for
(
ObjectCursor
<
String
>
key
:
mappOpenMap
.
keys
())
{
MappingMetaData
data
=
mappOpenMap
.
get
(
key
.
value
);
Map
<
String
,
Object
>
dataMap
=
data
.
getSourceAsMap
();
mappMap
.
put
(
key
.
value
,
dataMap
);
}
//获取aliases数据
//获取aliases数据
for
(
AliasMeta
D
ata
aliases
:
indexAliases
)
{
for
(
AliasMeta
d
ata
aliases
:
indexAliases
)
{
aliasesList
.
add
(
aliases
.
getAlias
());
aliasesList
.
add
(
aliases
.
getAlias
());
}
}
return
result
;
return
result
;
...
...
zlt-business/search-center/search-server/src/main/java/com/central/search/service/impl/AggregationServiceImpl.java
浏览文件 @
322fe40d
...
@@ -14,16 +14,16 @@ import org.elasticsearch.search.aggregations.bucket.histogram.*;
...
@@ -14,16 +14,16 @@ import org.elasticsearch.search.aggregations.bucket.histogram.*;
import
org.elasticsearch.search.aggregations.bucket.range.ParsedDateRange
;
import
org.elasticsearch.search.aggregations.bucket.range.ParsedDateRange
;
import
org.elasticsearch.search.aggregations.bucket.range.Range
;
import
org.elasticsearch.search.aggregations.bucket.range.Range
;
import
org.elasticsearch.search.aggregations.bucket.terms.Terms
;
import
org.elasticsearch.search.aggregations.bucket.terms.Terms
;
import
org.elasticsearch.search.aggregations.metrics.
cardinality.
Cardinality
;
import
org.elasticsearch.search.aggregations.metrics.
Parsed
Cardinality
;
import
org.elasticsearch.search.builder.SearchSourceBuilder
;
import
org.elasticsearch.search.builder.SearchSourceBuilder
;
import
org.joda.time.DateTime
;
import
org.joda.time.DateTimeZone
;
import
org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate
;
import
org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.time.ZoneId
;
import
java.time.ZonedDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.DateTimeFormatter
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -35,6 +35,9 @@ import java.util.Map;
...
@@ -35,6 +35,9 @@ import java.util.Map;
*
*
* @author zlt
* @author zlt
* @date 2019/5/7
* @date 2019/5/7
* <p>
* Blog: https://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
*/
@Service
@Service
public
class
AggregationServiceImpl
implements
IAggregationService
{
public
class
AggregationServiceImpl
implements
IAggregationService
{
...
@@ -113,7 +116,7 @@ public class AggregationServiceImpl implements IAggregationService {
...
@@ -113,7 +116,7 @@ public class AggregationServiceImpl implements IAggregationService {
*/
*/
@Override
@Override
public
Map
<
String
,
Object
>
requestStatAgg
(
String
indexName
,
String
routing
)
throws
IOException
{
public
Map
<
String
,
Object
>
requestStatAgg
(
String
indexName
,
String
routing
)
throws
IOException
{
DateTime
currDt
=
DateTime
.
now
();
ZonedDateTime
zonedDateTime
=
Zoned
DateTime
.
now
();
LocalDate
localDate
=
LocalDate
.
now
();
LocalDate
localDate
=
LocalDate
.
now
();
LocalDateTime
curDateTime
=
LocalDateTime
.
now
();
LocalDateTime
curDateTime
=
LocalDateTime
.
now
();
...
@@ -126,7 +129,7 @@ public class AggregationServiceImpl implements IAggregationService {
...
@@ -126,7 +129,7 @@ public class AggregationServiceImpl implements IAggregationService {
.
dateRange
(
"currDate"
)
.
dateRange
(
"currDate"
)
.
field
(
"timestamp"
)
.
field
(
"timestamp"
)
.
addRange
(
.
addRange
(
currDt
.
withHourOfDay
(
0
).
withMinuteOfHour
(
0
).
withSecondOfMinute
(
0
).
withMillisOfSecond
(
0
),
currDt
.
plusDays
(
1
)
zonedDateTime
.
withHour
(
0
).
withMinute
(
0
).
withSecond
(
0
).
withNano
(
0
),
zonedDateTime
.
plusDays
(
1
)
)
)
.
subAggregation
(
.
subAggregation
(
AggregationBuilders
AggregationBuilders
...
@@ -138,16 +141,16 @@ public class AggregationServiceImpl implements IAggregationService {
...
@@ -138,16 +141,16 @@ public class AggregationServiceImpl implements IAggregationService {
AggregationBuilders
AggregationBuilders
.
dateRange
(
"curr24Hour"
)
.
dateRange
(
"curr24Hour"
)
.
field
(
"timestamp"
)
.
field
(
"timestamp"
)
.
addRange
(
currDt
.
minusDays
(
1
),
currDt
)
.
addRange
(
zonedDateTime
.
minusDays
(
1
),
zonedDateTime
)
.
subAggregation
(
.
subAggregation
(
//聚合并且按小时分组查询当天内的数据
//聚合并且按小时分组查询当天内的数据
AggregationBuilders
AggregationBuilders
.
dateHistogram
(
"statDate"
)
.
dateHistogram
(
"statDate"
)
.
field
(
"timestamp"
)
.
field
(
"timestamp"
)
.
dateHistogram
Interval
(
new
DateHistogramInterval
(
"90m"
))
.
fixed
Interval
(
new
DateHistogramInterval
(
"90m"
))
.
format
(
CommonConstant
.
DATETIME_FORMAT
)
.
format
(
CommonConstant
.
DATETIME_FORMAT
)
//时区相差8小时
//时区相差8小时
.
timeZone
(
DateTimeZone
.
forOffsetHours
(
8
))
.
timeZone
(
ZoneId
.
of
(
"GMT+8"
))
.
minDocCount
(
0L
)
.
minDocCount
(
0L
)
.
extendedBounds
(
new
ExtendedBounds
(
.
extendedBounds
(
new
ExtendedBounds
(
curDateTime
.
minusDays
(
1
).
format
(
DateTimeFormatter
.
ofPattern
(
CommonConstant
.
DATETIME_FORMAT
)),
curDateTime
.
minusDays
(
1
).
format
(
DateTimeFormatter
.
ofPattern
(
CommonConstant
.
DATETIME_FORMAT
)),
...
@@ -164,16 +167,16 @@ public class AggregationServiceImpl implements IAggregationService {
...
@@ -164,16 +167,16 @@ public class AggregationServiceImpl implements IAggregationService {
AggregationBuilders
AggregationBuilders
.
dateRange
(
"currWeek"
)
.
dateRange
(
"currWeek"
)
.
field
(
"timestamp"
)
.
field
(
"timestamp"
)
.
addRange
(
currDt
.
minusDays
(
7
),
currDt
)
.
addRange
(
zonedDateTime
.
minusDays
(
7
),
zonedDateTime
)
.
subAggregation
(
.
subAggregation
(
//聚合并且按日期分组查询7天内的数据
//聚合并且按日期分组查询7天内的数据
AggregationBuilders
AggregationBuilders
.
dateHistogram
(
"statWeek"
)
.
dateHistogram
(
"statWeek"
)
.
field
(
"timestamp"
)
.
field
(
"timestamp"
)
.
dateHistogram
Interval
(
DateHistogramInterval
.
DAY
)
.
calendar
Interval
(
DateHistogramInterval
.
DAY
)
.
format
(
CommonConstant
.
DATE_FORMAT
)
.
format
(
CommonConstant
.
DATE_FORMAT
)
//时区相差8小时
//时区相差8小时
.
timeZone
(
DateTimeZone
.
forOffsetHours
(
8
))
.
timeZone
(
ZoneId
.
of
(
"GMT+8"
))
.
minDocCount
(
0L
)
.
minDocCount
(
0L
)
.
extendedBounds
(
new
ExtendedBounds
(
.
extendedBounds
(
new
ExtendedBounds
(
localDate
.
minusDays
(
6
).
format
(
DateTimeFormatter
.
ofPattern
(
CommonConstant
.
DATE_FORMAT
)),
localDate
.
minusDays
(
6
).
format
(
DateTimeFormatter
.
ofPattern
(
CommonConstant
.
DATE_FORMAT
)),
...
@@ -190,7 +193,7 @@ public class AggregationServiceImpl implements IAggregationService {
...
@@ -190,7 +193,7 @@ public class AggregationServiceImpl implements IAggregationService {
AggregationBuilders
AggregationBuilders
.
dateRange
(
"currMonth"
)
.
dateRange
(
"currMonth"
)
.
field
(
"timestamp"
)
.
field
(
"timestamp"
)
.
addRange
(
currDt
.
minusDays
(
30
),
currDt
)
.
addRange
(
zonedDateTime
.
minusDays
(
30
),
zonedDateTime
)
).
aggregation
(
).
aggregation
(
//聚合查询浏览器的数据
//聚合查询浏览器的数据
AggregationBuilders
AggregationBuilders
...
@@ -207,7 +210,7 @@ public class AggregationServiceImpl implements IAggregationService {
...
@@ -207,7 +210,7 @@ public class AggregationServiceImpl implements IAggregationService {
.
dateRange
(
"currHour"
)
.
dateRange
(
"currHour"
)
.
field
(
"timestamp"
)
.
field
(
"timestamp"
)
.
addRange
(
.
addRange
(
currDt
.
minusHours
(
1
),
currDt
zonedDateTime
.
minusHours
(
1
),
zonedDateTime
)
)
.
subAggregation
(
.
subAggregation
(
AggregationBuilders
AggregationBuilders
...
@@ -237,7 +240,7 @@ public class AggregationServiceImpl implements IAggregationService {
...
@@ -237,7 +240,7 @@ public class AggregationServiceImpl implements IAggregationService {
private
void
setCurrDate
(
Map
<
String
,
Object
>
result
,
Aggregations
aggregations
)
{
private
void
setCurrDate
(
Map
<
String
,
Object
>
result
,
Aggregations
aggregations
)
{
ParsedDateRange
currDate
=
aggregations
.
get
(
"currDate"
);
ParsedDateRange
currDate
=
aggregations
.
get
(
"currDate"
);
Range
.
Bucket
bucket
=
currDate
.
getBuckets
().
get
(
0
);
Range
.
Bucket
bucket
=
currDate
.
getBuckets
().
get
(
0
);
Cardinality
cardinality
=
bucket
.
getAggregations
().
get
(
"uv"
);
Parsed
Cardinality
cardinality
=
bucket
.
getAggregations
().
get
(
"uv"
);
result
.
put
(
"currDate_pv"
,
bucket
.
getDocCount
());
result
.
put
(
"currDate_pv"
,
bucket
.
getDocCount
());
result
.
put
(
"currDate_uv"
,
cardinality
.
getValue
());
result
.
put
(
"currDate_uv"
,
cardinality
.
getValue
());
}
}
...
@@ -293,7 +296,7 @@ public class AggregationServiceImpl implements IAggregationService {
...
@@ -293,7 +296,7 @@ public class AggregationServiceImpl implements IAggregationService {
List
<
String
>
items
=
new
ArrayList
<>();
List
<
String
>
items
=
new
ArrayList
<>();
List
<
Long
>
uv
=
new
ArrayList
<>();
List
<
Long
>
uv
=
new
ArrayList
<>();
List
<
Long
>
pv
=
new
ArrayList
<>();
List
<
Long
>
pv
=
new
ArrayList
<>();
Cardinality
cardinality
;
Parsed
Cardinality
cardinality
;
for
(
Histogram
.
Bucket
bucket
:
agg
.
getBuckets
())
{
for
(
Histogram
.
Bucket
bucket
:
agg
.
getBuckets
())
{
items
.
add
(
bucket
.
getKeyAsString
());
items
.
add
(
bucket
.
getKeyAsString
());
pv
.
add
(
bucket
.
getDocCount
());
pv
.
add
(
bucket
.
getDocCount
());
...
@@ -311,7 +314,7 @@ public class AggregationServiceImpl implements IAggregationService {
...
@@ -311,7 +314,7 @@ public class AggregationServiceImpl implements IAggregationService {
private
void
setCurrHour
(
Map
<
String
,
Object
>
result
,
Aggregations
aggregations
)
{
private
void
setCurrHour
(
Map
<
String
,
Object
>
result
,
Aggregations
aggregations
)
{
ParsedDateRange
currDate
=
aggregations
.
get
(
"currHour"
);
ParsedDateRange
currDate
=
aggregations
.
get
(
"currHour"
);
Range
.
Bucket
bucket
=
currDate
.
getBuckets
().
get
(
0
);
Range
.
Bucket
bucket
=
currDate
.
getBuckets
().
get
(
0
);
Cardinality
cardinality
=
bucket
.
getAggregations
().
get
(
"uv"
);
Parsed
Cardinality
cardinality
=
bucket
.
getAggregations
().
get
(
"uv"
);
result
.
put
(
"currHour_uv"
,
cardinality
.
getValue
());
result
.
put
(
"currHour_uv"
,
cardinality
.
getValue
());
}
}
/**
/**
...
@@ -322,7 +325,7 @@ public class AggregationServiceImpl implements IAggregationService {
...
@@ -322,7 +325,7 @@ public class AggregationServiceImpl implements IAggregationService {
List
<
String
>
items
=
new
ArrayList
<>();
List
<
String
>
items
=
new
ArrayList
<>();
List
<
Long
>
uv
=
new
ArrayList
<>();
List
<
Long
>
uv
=
new
ArrayList
<>();
List
<
Long
>
pv
=
new
ArrayList
<>();
List
<
Long
>
pv
=
new
ArrayList
<>();
Cardinality
cardinality
;
Parsed
Cardinality
cardinality
;
for
(
Histogram
.
Bucket
bucket
:
agg
.
getBuckets
())
{
for
(
Histogram
.
Bucket
bucket
:
agg
.
getBuckets
())
{
items
.
add
(
getTimeByDatetimeStr
(
bucket
.
getKeyAsString
()));
items
.
add
(
getTimeByDatetimeStr
(
bucket
.
getKeyAsString
()));
pv
.
add
(
bucket
.
getDocCount
());
pv
.
add
(
bucket
.
getDocCount
());
...
...
zlt-commons/zlt-elasticsearch-spring-boot-starter/src/main/java/com/central/es/utils/SearchBuilder.java
浏览文件 @
322fe40d
...
@@ -119,9 +119,24 @@ public class SearchBuilder {
...
@@ -119,9 +119,24 @@ public class SearchBuilder {
* @param limit 每页显示数
* @param limit 每页显示数
*/
*/
public
SearchBuilder
setPage
(
Integer
page
,
Integer
limit
)
{
public
SearchBuilder
setPage
(
Integer
page
,
Integer
limit
)
{
setPage
(
page
,
limit
,
false
);
return
this
;
}
/**
* 设置分页
* @param page 当前页数
* @param limit 每页显示数
* @param trackTotalHits 分页总数是否显示所有条数,默认只显示10000
*/
public
SearchBuilder
setPage
(
Integer
page
,
Integer
limit
,
boolean
trackTotalHits
)
{
if
(
page
!=
null
&&
limit
!=
null
)
{
if
(
page
!=
null
&&
limit
!=
null
)
{
searchBuilder
.
from
((
page
-
1
)
*
limit
)
searchBuilder
.
from
((
page
-
1
)
*
limit
)
.
size
(
limit
);
.
size
(
limit
);
if
(
trackTotalHits
)
{
searchBuilder
.
trackTotalHits
(
trackTotalHits
);
}
}
}
return
this
;
return
this
;
}
}
...
@@ -207,7 +222,7 @@ public class SearchBuilder {
...
@@ -207,7 +222,7 @@ public class SearchBuilder {
this
.
setPage
(
page
,
limit
);
this
.
setPage
(
page
,
limit
);
SearchResponse
response
=
this
.
get
();
SearchResponse
response
=
this
.
get
();
SearchHits
searchHits
=
response
.
getHits
();
SearchHits
searchHits
=
response
.
getHits
();
long
totalCnt
=
searchHits
.
getTotalHits
();
long
totalCnt
=
searchHits
.
getTotalHits
()
.
value
;
List
<
JSONObject
>
list
=
getList
(
searchHits
);
List
<
JSONObject
>
list
=
getList
(
searchHits
);
return
PageResult
.<
JSONObject
>
builder
().
data
(
list
).
code
(
0
).
count
(
totalCnt
).
build
();
return
PageResult
.<
JSONObject
>
builder
().
data
(
list
).
code
(
0
).
count
(
totalCnt
).
build
();
}
}
...
...
zlt-web/back-web/src/main/resources/static/pages/search/index_manager_form.html
浏览文件 @
322fe40d
...
@@ -18,12 +18,6 @@
...
@@ -18,12 +18,6 @@
<input
type=
"text"
name=
"numberOfReplicas"
placeholder=
"请输入副本数"
maxlength=
"20"
class=
"layui-input"
>
<input
type=
"text"
name=
"numberOfReplicas"
placeholder=
"请输入副本数"
maxlength=
"20"
class=
"layui-input"
>
</div>
</div>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
类型
</label>
<div
class=
"layui-input-block"
>
<input
type=
"text"
name=
"type"
placeholder=
"请输入类型"
maxlength=
"20"
class=
"layui-input"
>
</div>
</div>
<div
class=
"layui-form-item layui-form-text"
>
<div
class=
"layui-form-item layui-form-text"
>
<label
class=
"layui-form-label"
>
mappings
</label>
<label
class=
"layui-form-label"
>
mappings
</label>
<div
class=
"layui-input-block"
>
<div
class=
"layui-input-block"
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录