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
211d471b
Commit
211d471b
authored
Nov 17, 2022
by
shenjunjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release' into 'master'
Release See merge request
!99
parents
9ba54fd5
7c3e9315
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
28 deletions
+35
-28
src/main/java/com/zhiwei/brandkbs2/common/GenericAttribute.java
+1
-0
src/main/java/com/zhiwei/brandkbs2/es/ChannelEsDao.java
+6
-6
src/main/java/com/zhiwei/brandkbs2/es/EsQueryTools.java
+24
-18
src/main/java/com/zhiwei/brandkbs2/service/impl/ChannelServiceImpl.java
+1
-1
src/test/java/com/zhiwei/brandkbs2/BrandkbsIndexCreateTest.java
+3
-3
No files found.
src/main/java/com/zhiwei/brandkbs2/common/GenericAttribute.java
View file @
211d471b
...
@@ -18,6 +18,7 @@ public class GenericAttribute {
...
@@ -18,6 +18,7 @@ public class GenericAttribute {
// public static final String ES_INDEX_TEST = "brandkbs2_test";
// public static final String ES_INDEX_TEST = "brandkbs2_test";
public
static
final
String
ES_INDEX_TEST
=
"brandkbs2_2022"
;
public
static
final
String
ES_INDEX_TEST
=
"brandkbs2_2022"
;
public
static
final
String
ES_CHANNEL_INDEX_TEST
=
"brandkbs2_channel_record_test"
;
public
static
final
String
ES_CHANNEL_INDEX_TEST
=
"brandkbs2_channel_record_test"
;
public
static
final
String
ES_CHANNEL_INDEX_PREFIX
=
"brandkbs2_channel_record_"
;
/**
/**
* es ind_title
* es ind_title
**/
**/
...
...
src/main/java/com/zhiwei/brandkbs2/es/ChannelEsDao.java
View file @
211d471b
...
@@ -23,6 +23,7 @@ import org.springframework.stereotype.Component;
...
@@ -23,6 +23,7 @@ import org.springframework.stereotype.Component;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -109,13 +110,12 @@ public class ChannelEsDao extends EsClientDao {
...
@@ -109,13 +110,12 @@ public class ChannelEsDao extends EsClientDao {
public
String
getChannelRecordIndex
()
{
public
String
getChannelRecordIndex
()
{
// if (test) {
// if (test) {
return
GenericAttribute
.
ES_CHANNEL_INDEX_TEST
;
//
return GenericAttribute.ES_CHANNEL_INDEX_TEST;
// }
// }
// // 近1年数据库 TODO
// 近1年数据库
// Calendar date = Calendar.getInstance();
Calendar
date
=
Calendar
.
getInstance
();
// int year = date.get(Calendar.YEAR);
int
year
=
date
.
get
(
Calendar
.
YEAR
);
// res.add(GenericAttribute.ES_CHANNEL_INDEX_TEST);
return
GenericAttribute
.
ES_CHANNEL_INDEX_PREFIX
+
year
;
// return res.toArray(new String[0]);
}
}
private
BoolQueryBuilder
channelUniqueBool
(
String
fid
)
{
private
BoolQueryBuilder
channelUniqueBool
(
String
fid
)
{
...
...
src/main/java/com/zhiwei/brandkbs2/es/EsQueryTools.java
View file @
211d471b
...
@@ -8,10 +8,7 @@ import com.zhiwei.qbjc.bean.pojo.common.MessagePlatform;
...
@@ -8,10 +8,7 @@ import com.zhiwei.qbjc.bean.pojo.common.MessagePlatform;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.lucene.search.join.ScoreMode
;
import
org.apache.lucene.search.join.ScoreMode
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.*
;
import
org.elasticsearch.index.query.NestedQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
java.util.*
;
import
java.util.*
;
...
@@ -97,30 +94,39 @@ public class EsQueryTools {
...
@@ -97,30 +94,39 @@ public class EsQueryTools {
public
static
BoolQueryBuilder
assembleCacheMapsQuery
(
String
projectId
,
String
linkedGroupId
,
String
contendId
,
List
<
String
>
mediaTypes
)
{
public
static
BoolQueryBuilder
assembleCacheMapsQuery
(
String
projectId
,
String
linkedGroupId
,
String
contendId
,
List
<
String
>
mediaTypes
)
{
BoolQueryBuilder
nestedBoolQueryBuilder
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
nestedBoolQueryBuilder
=
QueryBuilders
.
boolQuery
();
// must key
String
key
=
concat
(
projectId
,
contendId
);
nestedBoolQueryBuilder
.
must
(
cacheMapsNestedQuery
(
QueryBuilders
.
termQuery
(
"brandkbs_cache_maps.key.keyword"
,
concat
(
projectId
,
contendId
))));
TermQueryBuilder
mustQuery
=
QueryBuilders
.
termQuery
(
"brandkbs_cache_maps.key.keyword"
,
key
);
// mediaType
if
(
CollectionUtils
.
isEmpty
(
mediaTypes
))
{
if
(
CollectionUtils
.
isNotEmpty
(
mediaTypes
))
{
// 不组装mediaTypes的情况
BoolQueryBuilder
mediaTypeQueryBuilder
=
QueryBuilders
.
boolQuery
();
nestedBoolQueryBuilder
.
must
(
cacheMapsNestedQuery
(
mustQuery
));
}
else
{
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
();
mediaTypes
.
forEach
(
e
->
{
mediaTypes
.
forEach
(
e
->
{
mediaTypeQueryBuilder
.
should
(
cacheMapsNestedQuery
(
QueryBuilders
.
termQuery
(
"brandkbs_cache_maps.channel_type.keyword"
,
e
)));
BoolQueryBuilder
mediaTypeQueryBuilder
=
QueryBuilders
.
boolQuery
();
mediaTypeQueryBuilder
.
must
(
QueryBuilders
.
termQuery
(
"brandkbs_cache_maps.channel_type.keyword"
,
e
));
mediaTypeQueryBuilder
.
must
(
mustQuery
);
boolQueryBuilder
.
should
(
cacheMapsNestedQuery
(
mediaTypeQueryBuilder
));
});
});
nestedBoolQueryBuilder
.
must
(
mediaType
QueryBuilder
);
nestedBoolQueryBuilder
.
must
(
bool
QueryBuilder
);
}
}
return
nestedBoolQueryBuilder
;
return
nestedBoolQueryBuilder
;
}
}
public
static
BoolQueryBuilder
assembleCacheMapsQueryWithProject
(
String
projectId
,
List
<
String
>
mediaTypes
)
{
public
static
BoolQueryBuilder
assembleCacheMapsQueryWithProject
(
String
projectId
,
List
<
String
>
mediaTypes
)
{
BoolQueryBuilder
nestedBoolQueryBuilder
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
nestedBoolQueryBuilder
=
QueryBuilders
.
boolQuery
();
// must key
TermQueryBuilder
mustQuery
=
QueryBuilders
.
termQuery
(
"brandkbs_cache_maps.project_id.keyword"
,
projectId
);
nestedBoolQueryBuilder
.
must
(
cacheMapsNestedQuery
(
QueryBuilders
.
termQuery
(
"brandkbs_cache_maps.project_id.keyword"
,
projectId
)));
if
(
CollectionUtils
.
isEmpty
(
mediaTypes
))
{
// mediaType
// 不组装mediaTypes的情况
if
(
CollectionUtils
.
isNotEmpty
(
mediaTypes
))
{
nestedBoolQueryBuilder
.
must
(
cacheMapsNestedQuery
(
mustQuery
));
BoolQueryBuilder
mediaTypeQueryBuilder
=
QueryBuilders
.
boolQuery
();
}
else
{
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
();
mediaTypes
.
forEach
(
e
->
{
mediaTypes
.
forEach
(
e
->
{
mediaTypeQueryBuilder
.
should
(
cacheMapsNestedQuery
(
QueryBuilders
.
termQuery
(
"brandkbs_cache_maps.channel_type.keyword"
,
e
)));
BoolQueryBuilder
mediaTypeQueryBuilder
=
QueryBuilders
.
boolQuery
();
mediaTypeQueryBuilder
.
must
(
QueryBuilders
.
termQuery
(
"brandkbs_cache_maps.channel_type.keyword"
,
e
));
mediaTypeQueryBuilder
.
must
(
mustQuery
);
boolQueryBuilder
.
should
(
cacheMapsNestedQuery
(
mediaTypeQueryBuilder
));
});
});
nestedBoolQueryBuilder
.
must
(
mediaType
QueryBuilder
);
nestedBoolQueryBuilder
.
must
(
bool
QueryBuilder
);
}
}
return
nestedBoolQueryBuilder
;
return
nestedBoolQueryBuilder
;
}
}
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/ChannelServiceImpl.java
View file @
211d471b
...
@@ -751,7 +751,7 @@ public class ChannelServiceImpl implements ChannelService {
...
@@ -751,7 +751,7 @@ public class ChannelServiceImpl implements ChannelService {
boolean
isPositive
=
false
;
boolean
isPositive
=
false
;
boolean
isNegative
=
false
;
boolean
isNegative
=
false
;
long
specNegativeCount
=
eventDao
.
getEventCount
(
new
ChannelIndex
(
channel
),
Arrays
.
asList
(
EmotionEnum
.
POSITIVE
.
getName
(),
EmotionEnum
.
NEUTRAL
.
getName
()),
EmotionEnum
.
NEGATIVE
.
getName
());
long
specNegativeCount
=
eventDao
.
getEventCount
(
new
ChannelIndex
(
channel
),
Arrays
.
asList
(
EmotionEnum
.
POSITIVE
.
getName
(),
EmotionEnum
.
NEUTRAL
.
getName
()),
EmotionEnum
.
NEGATIVE
.
getName
());
long
specPositiveCount
=
eventDao
.
getEventCount
(
new
ChannelIndex
(
channel
),
Arrays
.
asList
(
EmotionEnum
.
NEGATIVE
.
getName
(),
EmotionEnum
.
POSI
TIVE
.
getName
()),
EmotionEnum
.
POSITIVE
.
getName
());
long
specPositiveCount
=
eventDao
.
getEventCount
(
new
ChannelIndex
(
channel
),
Collections
.
singletonList
(
EmotionEnum
.
NEGA
TIVE
.
getName
()),
EmotionEnum
.
POSITIVE
.
getName
());
// 特殊情况:若皆有发布过反常稿件
// 特殊情况:若皆有发布过反常稿件
if
(
specNegativeCount
>
0
&&
specPositiveCount
>
0
)
{
if
(
specNegativeCount
>
0
&&
specPositiveCount
>
0
)
{
//正面稿件数>负面稿件数,为正面
//正面稿件数>负面稿件数,为正面
...
...
src/test/java/com/zhiwei/brandkbs2/BrandkbsIndexCreateTest.java
View file @
211d471b
...
@@ -30,9 +30,9 @@ public class BrandkbsIndexCreateTest {
...
@@ -30,9 +30,9 @@ public class BrandkbsIndexCreateTest {
public
void
test1
()
throws
IOException
{
public
void
test1
()
throws
IOException
{
String
channelIndex
=
"brandkbs2_channel_record_2023"
;
String
channelIndex
=
"brandkbs2_channel_record_2023"
;
// String brandkbsIndex = "brandkbs2_2022";
// String brandkbsIndex = "brandkbs2_2022";
//
putChannelIndex(channelIndex);
putChannelIndex
(
channelIndex
);
// putBrandkbsIndex("brandkbs2_2018","brandkbs2_2019","brandkbs2_2020","brandkbs2_2021");
// putBrandkbsIndex("brandkbs2_2018","brandkbs2_2019","brandkbs2_2020","brandkbs2_2021");
putBrandkbsIndex
(
"brandkbs2_2017"
);
//
putBrandkbsIndex("brandkbs2_2017");
}
}
public
void
putChannelIndex
(
String
...
indexes
)
throws
IOException
{
public
void
putChannelIndex
(
String
...
indexes
)
throws
IOException
{
...
@@ -219,7 +219,7 @@ public class BrandkbsIndexCreateTest {
...
@@ -219,7 +219,7 @@ public class BrandkbsIndexCreateTest {
builder
(
obj2
,
"long"
,
"time"
,
false
);
builder
(
obj2
,
"long"
,
"time"
,
false
);
builder
(
obj2
,
"long"
,
"last_time"
,
false
);
builder
(
obj2
,
"long"
,
"last_time"
,
false
);
message
.
put
(
"properties"
,
obj2
);
message
.
put
(
"properties"
,
obj2
);
properties
.
put
(
"
mark_cache_maps
"
,
message
);
properties
.
put
(
"
record
"
,
message
);
}
}
public
static
void
markMapCache
(
Map
<
String
,
Object
>
properties
)
{
public
static
void
markMapCache
(
Map
<
String
,
Object
>
properties
)
{
...
...
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