Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
brandkbs2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shenjunjie
brandkbs2
Commits
6476b0d5
Commit
6476b0d5
authored
Jul 27, 2022
by
陈健智
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改getFirstArticle方法
parent
8cc8e277
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
14 deletions
+13
-14
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
+13
-14
No files found.
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
View file @
6476b0d5
...
...
@@ -30,6 +30,7 @@ import com.zhiwei.brandkbs2.util.RedisUtil;
import
com.zhiwei.brandkbs2.util.TextUtil
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
com.zhiwei.qbjc.bean.pojo.common.MessagePlatform
;
import
io.lettuce.core.ScriptOutputType
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.time.DateUtils
;
...
...
@@ -52,6 +53,7 @@ import org.elasticsearch.search.aggregations.bucket.histogram.ParsedDateHistogra
import
org.elasticsearch.search.aggregations.bucket.terms.ParsedStringTerms
;
import
org.elasticsearch.search.aggregations.bucket.terms.Terms
;
import
org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder
;
import
org.elasticsearch.search.builder.SearchSourceBuilder
;
import
org.elasticsearch.search.sort.FieldSortBuilder
;
import
org.elasticsearch.search.sort.SortBuilders
;
import
org.elasticsearch.search.sort.SortOrder
;
...
...
@@ -814,23 +816,20 @@ public class MarkDataServiceImpl implements MarkDataService {
public
JSONObject
getFirstArticle
(
Long
startTime
,
Long
endTime
,
String
aggTitle
,
String
projectId
,
String
linkedGroupId
)
throws
IOException
{
// 索引
String
[]
indexes
=
esClientDao
.
getIndexes
();
//
query
BoolQueryBuilder
query
=
projectLinkedGroupQuery
(
projectId
,
linkedGroupId
);
query
.
must
(
QueryBuilders
.
rangeQuery
(
"time"
).
gte
(
startTime
).
lt
(
endTime
))
//
postFilter
BoolQueryBuilder
postFilter
=
projectLinkedGroupQuery
(
projectId
,
linkedGroupId
);
postFilter
.
must
(
QueryBuilders
.
rangeQuery
(
"time"
).
gte
(
startTime
).
lt
(
endTime
))
.
must
(
QueryBuilders
.
termQuery
(
"agg_title.keyword"
,
aggTitle
));
// response
SearchResponse
searchResponse
=
esClientDao
.
searchResponse
(
indexes
,
null
,
query
,
null
,
null
,
null
,
0
,
0
,
null
);
//sort
FieldSortBuilder
sort
=
new
FieldSortBuilder
(
"time"
).
order
(
SortOrder
.
ASC
);
//hits
SearchHits
hits
=
searchResponse
.
getHits
();
SearchHits
hits
=
esClientDao
.
searchHits
(
indexes
,
postFilter
,
null
,
null
,
sort
,
0
,
1
,
null
);
SearchHit
hit
=
hits
.
getAt
(
0
);
JSONObject
resultJSONObject
=
new
JSONObject
();
hits
.
forEach
(
hit
->
{
Map
<
String
,
Object
>
source
=
hit
.
getSourceAsMap
();
resultJSONObject
.
put
(
"time"
,
source
.
get
(
"time"
));
resultJSONObject
.
put
(
"content"
,
source
.
get
(
"content"
));
resultJSONObject
.
put
(
"url"
,
source
.
get
(
"url"
));
resultJSONObject
.
put
(
"realSource"
,
source
.
get
(
"real_source"
));
});
resultJSONObject
.
put
(
"content"
,
hit
.
getSourceAsMap
().
get
(
"content"
));
resultJSONObject
.
put
(
"url"
,
hit
.
getSourceAsMap
().
get
(
"url"
));
resultJSONObject
.
put
(
"realSource"
,
hit
.
getSourceAsMap
().
get
(
"real_source"
));
return
resultJSONObject
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment