Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
change4weixin
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
shenjinzhu
change4weixin
Commits
745e3fa7
Commit
745e3fa7
authored
Jan 08, 2019
by
[zhangzhiwei]
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改es读取读取当前月份
parent
442d726b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
1 deletions
+45
-1
pom.xml
+6
-0
src/main/java/com/zhiwei/finance/ESUtil.java
+39
-1
No files found.
pom.xml
View file @
745e3fa7
...
...
@@ -179,6 +179,11 @@
<version>
7.0.47
</version>
</dependency>
<dependency>
<groupId>
com.zhiwei.tools
</groupId>
<artifactId>
zhiwei-tools
</artifactId>
<version>
0.1.1-SNAPSHOT
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
src/main/java/com/zhiwei/finance/ESUtil.java
View file @
745e3fa7
...
...
@@ -22,6 +22,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
com.zhiwei.tools.timeparse.TimeParse
;
import
com.zhiwei.util.Config
;
import
com.zhiwei.util.MongoConnection
;
import
com.zhiwei.util.ReadExcel
;
...
...
@@ -131,8 +132,9 @@ public class ESUtil {
}
keys
=
new
ReadExcel
().
getExcel
(
path
);
try
{
String
indexName
=
getIndex
(
start
,
type
);
for
(
String
key
:
keys
)
{
SearchRequestBuilder
srb
=
esClient
.
prepareSearch
(
Config
.
getVal
(
"indexName."
+
type
)
);
SearchRequestBuilder
srb
=
esClient
.
prepareSearch
(
indexName
);
BoolQueryBuilder
bb
=
new
BoolQueryBuilder
();
QueryBuilder
matchQuery
=
QueryBuilders
.
termQuery
(
"content"
,
key
);
bb
.
should
(
matchQuery
);
...
...
@@ -190,4 +192,40 @@ public class ESUtil {
}
return
result
;
}
/**
* 根据时间处理微博+网媒 index
* @param start
* @param type
* @return
*/
private
static
String
getIndex
(
Date
startDate
,
String
type
){
String
index
=
"network"
;
if
(!
type
.
contains
(
"weibo"
)){
index
=
"mediaspider"
;
}
Date
endData
=
TimeParse
.
stringFormartDate
(
"2017-08-03 00:00:00"
);
String
year
=
TimeParse
.
dateFormartString
(
startDate
,
"yyyyMM"
);
if
(
endData
.
before
(
startDate
)){
index
=
index
+
"_"
+
year
;
}
return
index
;
}
/**
* 根据查询时间处理微信大库index
* @param start
* @return
*/
private
static
String
getWechatIndex
(
Date
startDate
){
String
index
=
"wx_tanglihua"
;
Date
endData
=
TimeParse
.
stringFormartDate
(
"2017-05-01 00:00:00"
);
String
year
=
TimeParse
.
dateFormartString
(
startDate
,
"yyyyMM"
);
if
(
endData
.
before
(
startDate
)){
index
=
index
+
"_"
+
year
;
}
return
index
;
}
}
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