Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 9d6524db
authored
Mar 09, 2021
by
水库浪子
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'origin/back_end_dev' into back_end_dev
2 parents
20efa4e0
ddf47be3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
linkwe-common/src/main/java/com/linkwechat/common/core/elasticsearch/ElasticSearch.java
linkwe-common/src/main/java/com/linkwechat/common/core/elasticsearch/ElasticSearch.java
View file @
9d6524d
...
@@ -32,6 +32,7 @@ import org.elasticsearch.search.builder.SearchSourceBuilder;
...
@@ -32,6 +32,7 @@ import org.elasticsearch.search.builder.SearchSourceBuilder;
import
org.elasticsearch.search.fetch.subphase.highlight.HighlightField
;
import
org.elasticsearch.search.fetch.subphase.highlight.HighlightField
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -207,7 +208,9 @@ public class ElasticSearch {
...
@@ -207,7 +208,9 @@ public class ElasticSearch {
list
.
forEach
(
item
->
request
.
add
(
new
IndexRequest
(
idxName
,
"_doc"
).
id
(
item
.
getId
())
list
.
forEach
(
item
->
request
.
add
(
new
IndexRequest
(
idxName
,
"_doc"
).
id
(
item
.
getId
())
.
source
(
item
.
getData
(),
XContentType
.
JSON
)));
.
source
(
item
.
getData
(),
XContentType
.
JSON
)));
try
{
try
{
restHighLevelClient
.
bulk
(
request
,
RequestOptions
.
DEFAULT
);
if
(!
CollectionUtils
.
isEmpty
(
request
.
requests
()))
{
restHighLevelClient
.
bulk
(
request
,
RequestOptions
.
DEFAULT
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
...
@@ -225,7 +228,9 @@ public class ElasticSearch {
...
@@ -225,7 +228,9 @@ public class ElasticSearch {
list
.
parallelStream
().
forEach
(
item
->
request
.
add
(
new
IndexRequest
(
idxName
,
"_doc"
).
id
(
item
.
getId
())
list
.
parallelStream
().
forEach
(
item
->
request
.
add
(
new
IndexRequest
(
idxName
,
"_doc"
).
id
(
item
.
getId
())
.
source
(
item
.
getData
(),
XContentType
.
JSON
)));
.
source
(
item
.
getData
(),
XContentType
.
JSON
)));
try
{
try
{
restHighLevelClient
.
bulkAsync
(
request
,
RequestOptions
.
DEFAULT
,
getActionListener
(
consumer
,
list
,
param
));
if
(!
CollectionUtils
.
isEmpty
(
request
.
requests
()))
{
restHighLevelClient
.
bulkAsync
(
request
,
RequestOptions
.
DEFAULT
,
getActionListener
(
consumer
,
list
,
param
));
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
...
@@ -236,7 +241,9 @@ public class ElasticSearch {
...
@@ -236,7 +241,9 @@ public class ElasticSearch {
list
.
parallelStream
().
forEach
(
item
->
request
.
add
(
new
IndexRequest
(
idxName
,
"_doc"
).
id
(
item
.
getString
(
"msgid"
))
list
.
parallelStream
().
forEach
(
item
->
request
.
add
(
new
IndexRequest
(
idxName
,
"_doc"
).
id
(
item
.
getString
(
"msgid"
))
.
source
(
item
,
XContentType
.
JSON
)));
.
source
(
item
,
XContentType
.
JSON
)));
try
{
try
{
restHighLevelClient
.
bulkAsync
(
request
,
RequestOptions
.
DEFAULT
,
getActionListener
(
consumer
,
list
));
if
(!
CollectionUtils
.
isEmpty
(
request
.
requests
()))
{
restHighLevelClient
.
bulkAsync
(
request
,
RequestOptions
.
DEFAULT
,
getActionListener
(
consumer
,
list
));
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
...
@@ -246,7 +253,9 @@ public class ElasticSearch {
...
@@ -246,7 +253,9 @@ public class ElasticSearch {
BulkRequest
request
=
new
BulkRequest
();
BulkRequest
request
=
new
BulkRequest
();
list
.
forEach
(
item
->
request
.
add
(
new
UpdateRequest
(
idxName
,
item
.
getId
()).
upsert
(
item
.
getData
(),
XContentType
.
JSON
)));
list
.
forEach
(
item
->
request
.
add
(
new
UpdateRequest
(
idxName
,
item
.
getId
()).
upsert
(
item
.
getData
(),
XContentType
.
JSON
)));
try
{
try
{
restHighLevelClient
.
bulk
(
request
,
RequestOptions
.
DEFAULT
);
if
(!
CollectionUtils
.
isEmpty
(
request
.
requests
()))
{
restHighLevelClient
.
bulk
(
request
,
RequestOptions
.
DEFAULT
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
...
@@ -268,7 +277,9 @@ public class ElasticSearch {
...
@@ -268,7 +277,9 @@ public class ElasticSearch {
BulkRequest
request
=
new
BulkRequest
();
BulkRequest
request
=
new
BulkRequest
();
idList
.
forEach
(
item
->
request
.
add
(
new
DeleteRequest
(
idxName
,
"_doc"
,
item
.
toString
())));
idList
.
forEach
(
item
->
request
.
add
(
new
DeleteRequest
(
idxName
,
"_doc"
,
item
.
toString
())));
try
{
try
{
restHighLevelClient
.
bulk
(
request
,
RequestOptions
.
DEFAULT
);
if
(!
CollectionUtils
.
isEmpty
(
request
.
requests
()))
{
restHighLevelClient
.
bulk
(
request
,
RequestOptions
.
DEFAULT
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment