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
b0cf4fdb
Commit
b0cf4fdb
authored
Apr 10, 2024
by
陈健智
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
渠道、标题聚合榜单屏蔽
parent
2729ec69
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
13 deletions
+49
-13
src/main/java/com/zhiwei/brandkbs2/easyexcel/listener/BytedanceEventListener.java
+0
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
+19
-12
src/main/java/com/zhiwei/brandkbs2/util/Tools.java
+30
-1
No files found.
src/main/java/com/zhiwei/brandkbs2/easyexcel/listener/BytedanceEventListener.java
View file @
b0cf4fdb
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
View file @
b0cf4fdb
...
...
@@ -828,7 +828,7 @@ public class MarkDataServiceImpl implements MarkDataService {
public
List
<
Map
.
Entry
<
String
,
Integer
>>
getMarkTopTitle
(
Long
startTime
,
Long
endTime
,
String
emotion
,
String
projectId
,
String
contendId
,
int
size
,
boolean
include
)
throws
IOException
{
// 索引
String
[]
indexes
=
esClientDao
.
getIndexes
();
TermsAggregationBuilder
aggregationBuilder
=
AggregationBuilders
.
terms
(
"titles"
).
field
(
"agg_title.keyword"
).
size
(
size
+
1
);
TermsAggregationBuilder
aggregationBuilder
=
AggregationBuilders
.
terms
(
"titles"
).
field
(
"agg_title.keyword"
).
size
(
size
+
Tools
.
FILTER_TITLE
.
size
()
);
// query
BoolQueryBuilder
query
;
if
(
include
)
{
...
...
@@ -848,8 +848,8 @@ public class MarkDataServiceImpl implements MarkDataService {
ParsedStringTerms
teamAgg
=
(
ParsedStringTerms
)
aggMap
.
get
(
"titles"
);
for
(
Terms
.
Bucket
bucket
:
teamAgg
.
getBuckets
())
{
String
title
=
bucket
.
getKeyAsString
();
// 过滤 “分享一篇文章” 的标题
if
(
"分享一篇文章"
.
equals
(
title
))
{
// 过滤 “分享一篇文章”
,”暂无标题“,”Notitle“
的标题
if
(
Tools
.
filterUselessTitle
(
title
))
{
continue
;
}
int
num
=
(
int
)
bucket
.
getDocCount
();
...
...
@@ -861,7 +861,7 @@ public class MarkDataServiceImpl implements MarkDataService {
private
List
<
JSONObject
>
getMarkTopTitle
(
Long
startTime
,
Long
endTime
,
String
emotion
,
String
projectId
,
String
contendId
,
String
planId
,
int
size
)
throws
IOException
{
// 索引
String
[]
indexes
=
esClientDao
.
getIndexes
();
TermsAggregationBuilder
aggregationBuilder
=
AggregationBuilders
.
terms
(
"titles"
).
field
(
"agg_title.keyword"
).
size
(
size
+
1
);
TermsAggregationBuilder
aggregationBuilder
=
AggregationBuilders
.
terms
(
"titles"
).
field
(
"agg_title.keyword"
).
size
(
size
+
Tools
.
FILTER_TITLE
.
size
()
);
TermsAggregationBuilder
sourceAggregationBuilder
=
AggregationBuilders
.
terms
(
"source"
).
field
(
"source"
).
size
(
10000
);
// query
BoolQueryBuilder
query
;
...
...
@@ -890,8 +890,8 @@ public class MarkDataServiceImpl implements MarkDataService {
for
(
Terms
.
Bucket
bucket
:
teamAgg
.
getBuckets
())
{
JSONObject
jsonObject
=
new
JSONObject
();
String
title
=
bucket
.
getKeyAsString
();
// 过滤 “分享一篇文章” 的标题
if
(
"分享一篇文章"
.
equals
(
title
))
{
// 过滤 “分享一篇文章”
,”暂无标题“,”Notitle“
的标题
if
(
Tools
.
filterUselessTitle
(
title
))
{
continue
;
}
jsonObject
.
put
(
"title"
,
title
);
...
...
@@ -1720,9 +1720,11 @@ public class MarkDataServiceImpl implements MarkDataService {
result
.
put
(
"source"
,
channel
.
getSource
());
result
.
put
(
"platform"
,
channel
.
getPlatform
());
result
.
put
(
"num"
,
bucket
.
getDocCount
());
if
(!
Tools
.
filterUselessSource
(
channel
.
getSource
())){
channelResultList
.
add
(
result
);
}
}
}
});
return
channelResultList
;
}
...
...
@@ -2713,7 +2715,7 @@ public class MarkDataServiceImpl implements MarkDataService {
// query
BoolQueryBuilder
query
=
yuqingAnalyzeQuery
(
startTime
,
endTime
,
planId
,
null
,
null
);
// 渠道聚合,取前20
TermsAggregationBuilder
sourceAggregationBuilder
=
AggregationBuilders
.
terms
(
"source_count"
).
field
(
"source"
).
order
(
BucketOrder
.
count
(
false
)).
size
(
20
);
TermsAggregationBuilder
sourceAggregationBuilder
=
AggregationBuilders
.
terms
(
"source_count"
).
field
(
"source"
).
order
(
BucketOrder
.
count
(
false
)).
size
(
20
+
Tools
.
FILTER_SOURCE
.
size
()
);
// 情感倾向子聚合
TermsAggregationBuilder
emotionAggregationBuilder
=
AggregationBuilders
.
terms
(
"emotion_count"
).
field
(
"brandkbs_mark_cache_maps.name.keyword"
);
SearchResponse
searchResponse
=
esClientDao
.
searchResponse
(
indexes
,
null
,
query
,
...
...
@@ -2721,15 +2723,20 @@ public class MarkDataServiceImpl implements MarkDataService {
Map
<
String
,
Aggregation
>
aggMap
=
searchResponse
.
getAggregations
().
asMap
();
ParsedStringTerms
sourceCountTeam
=
(
ParsedStringTerms
)
aggMap
.
get
(
"source_count"
);
List
<?
extends
Terms
.
Bucket
>
buckets
=
sourceCountTeam
.
getBuckets
();
buckets
.
forEach
(
bucket
->
{
for
(
Terms
.
Bucket
bucket
:
buckets
)
{
JSONObject
jsonObject
=
new
JSONObject
();
Map
<
String
,
Aggregation
>
map
=
bucket
.
getAggregations
().
asMap
();
ParsedStringTerms
countTeam
=
(
ParsedStringTerms
)
map
.
get
(
"emotion_count"
);
List
<?
extends
Terms
.
Bucket
>
bucketList
=
countTeam
.
getBuckets
();
jsonObject
.
put
(
"source"
,
bucket
.
getKeyAsString
());
String
source
=
bucket
.
getKeyAsString
();
// 过滤渠道名:”匿名“
if
(
Tools
.
filterUselessSource
(
source
)){
continue
;
}
jsonObject
.
put
(
"source"
,
source
);
// 发文次数
jsonObject
.
put
(
"count"
,
bucket
.
getDocCount
());
// 负面发文次数
ParsedStringTerms
countTeam
=
(
ParsedStringTerms
)
map
.
get
(
"emotion_count"
);
List
<?
extends
Terms
.
Bucket
>
bucketList
=
countTeam
.
getBuckets
();
AtomicLong
negativeCount
=
new
AtomicLong
();
bucketList
.
forEach
(
data
->
{
if
(
Objects
.
equals
(
data
.
getKeyAsString
(),
EmotionEnum
.
NEGATIVE
.
getName
()))
{
...
...
@@ -2738,7 +2745,7 @@ public class MarkDataServiceImpl implements MarkDataService {
});
jsonObject
.
put
(
"negativeCount"
,
negativeCount
.
get
());
list
.
add
(
jsonObject
);
}
);
}
}
catch
(
Exception
e
){
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"新舆情分析getActiveChannels异常-"
,
e
);
}
...
...
src/main/java/com/zhiwei/brandkbs2/util/Tools.java
View file @
b0cf4fdb
...
...
@@ -52,7 +52,7 @@ import java.util.stream.Stream;
import
java.util.zip.GZIPInputStream
;
import
java.util.zip.GZIPOutputStream
;
import
static
com
.
zhiwei
.
brandkbs2
.
common
.
GenericAttribute
.
ES_MARK_CACHE_MAPS
;
import
static
com
.
zhiwei
.
brandkbs2
.
common
.
GenericAttribute
.
*
;
import
static
com
.
zhiwei
.
brandkbs2
.
config
.
Constant
.*;
import
static
java
.
util
.
Objects
.
nonNull
;
...
...
@@ -75,6 +75,16 @@ public class Tools {
private
static
final
DozerBeanMapper
DOZER_BEAN_MAPPER
=
new
DozerBeanMapper
();
/**
* 须过滤的标题
*/
public
static
final
List
<
String
>
FILTER_TITLE
=
Arrays
.
asList
(
"Notitle"
,
"分享一篇文章"
,
"暂无标题"
);
/**
* 须过滤的渠道
*/
public
static
final
List
<
String
>
FILTER_SOURCE
=
Arrays
.
asList
(
"匿名"
);
/**
* 上传文件
...
...
@@ -1345,4 +1355,22 @@ public class Tools {
}
return
Arrays
.
stream
(
str
.
split
(
"[\\u007c]+"
)).
filter
(
StringUtils:
:
isNotBlank
).
collect
(
Collectors
.
joining
(
"|"
));
}
/**
* 过滤 “分享一篇文章”,”暂无标题“,”Notitle“ 的无用标题
* @param title
* @return
*/
public
static
Boolean
filterUselessTitle
(
String
title
){
return
FILTER_TITLE
.
contains
(
title
);
}
/**
* 过滤 “匿名“ 的无用渠道
* @param source
* @return
*/
public
static
Boolean
filterUselessSource
(
String
source
){
return
FILTER_SOURCE
.
contains
(
source
);
}
}
\ No newline at end of file
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