Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
uphrh-smf-form
Commits
8d605ea9
Commit
8d605ea9
authored
2 years ago
by
nivetha
Browse files
Options
Download
Plain Diff
Merge branch 'master' of
https://git.idc.tarento.com/smf/smf-form
parents
e811e3e3
4d84af9f
master
bulk-download
cvs_download
delete-form
emailContentUpdate
inspection-flow-changes
institute-district
lat-long
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/com/tarento/formservice/dao/impl/FormsDaoImpl.java
+1
-1
...n/java/com/tarento/formservice/dao/impl/FormsDaoImpl.java
src/main/java/com/tarento/formservice/repository/ElasticSearchRepository.java
+26
-5
...rento/formservice/repository/ElasticSearchRepository.java
with
27 additions
and
6 deletions
+27
-6
src/main/java/com/tarento/formservice/dao/impl/FormsDaoImpl.java
+
1
−
1
View file @
8d605ea9
...
...
@@ -102,7 +102,7 @@ public class FormsDaoImpl implements FormsDao {
public
List
<
Map
<
String
,
Object
>>
searchPlainFormResponse
(
SearchRequest
searchRequest
)
{
try
{
List
<
Map
<
String
,
Object
>>
responseData
=
new
ArrayList
<>();
MultiSearchResponse
response
=
elasticsearchRepo
.
executeMultiSearchRequest
(
searchRequest
);
MultiSearchResponse
response
=
elasticsearchRepo
.
executeMultiSearchRequest
2
(
searchRequest
);
SearchResponse
searchResponse
=
response
.
getResponses
()[
0
].
getResponse
();
SearchHit
[]
hit
=
searchResponse
.
getHits
().
getHits
();
for
(
SearchHit
hits
:
hit
)
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/formservice/repository/ElasticSearchRepository.java
+
26
−
5
View file @
8d605ea9
...
...
@@ -64,12 +64,14 @@ public class ElasticSearchRepository {
private
AppConfiguration
appConfig
;
private
RestHighLevelClient
client
;
private
RestHighLevelClient
client2
;
@Autowired
private
ElasticSearchRepository
(
AppConfiguration
appConfiguration
,
RestTemplate
restTemp
)
{
appConfig
=
appConfiguration
;
restTemplate
=
restTemp
;
client
=
connectToElasticSearch
();
client2
=
connectToElasticSearch2
();
}
private
RestHighLevelClient
connectToElasticSearch
()
{
...
...
@@ -83,14 +85,17 @@ public class ElasticSearchRepository {
return
httpClientBuilder
.
setDefaultCredentialsProvider
(
credentialsProvider
);
}
};
// return new RestHighLevelClient(
// RestClient.builder(new HttpHost(appConfig.getElasticHost(), appConfig.getElasticPort())));
return
new
RestHighLevelClient
(
RestClient
.
builder
(
new
HttpHost
(
appConfig
.
getElasticHost
(),
appConfig
.
getElasticPort
()))
);
RestClient
.
builder
(
new
HttpHost
(
appConfig
.
getElasticHost
(),
appConfig
.
getElasticPort
()
,
"https"
))
.
setHttpClientConfigCallback
(
httpClientConfigCallback
));
}
private
RestHighLevelClient
connectToElasticSearch2
()
{
final
CredentialsProvider
credentialsProvider
=
new
BasicCredentialsProvider
();
credentialsProvider
.
setCredentials
(
AuthScope
.
ANY
,
new
UsernamePasswordCredentials
(
"username"
,
"password"
));
credentialsProvider
.
setCredentials
(
AuthScope
.
ANY
,
new
UsernamePasswordCredentials
(
"elastic"
,
"PuAz@itAqwsaR34bYu"
));
HttpClientConfigCallback
httpClientConfigCallback
=
new
HttpClientConfigCallback
()
{
@Override
...
...
@@ -98,8 +103,9 @@ public class ElasticSearchRepository {
return
httpClientBuilder
.
setDefaultCredentialsProvider
(
credentialsProvider
);
}
};
return
new
RestHighLevelClient
(
RestClient
.
builder
(
new
HttpHost
(
"hostname"
,
443
,
"https"
))
.
setHttpClientConfigCallback
(
httpClientConfigCallback
));
return
new
RestHighLevelClient
(
RestClient
.
builder
(
new
HttpHost
(
"elastic.pulz.app"
,
443
,
"https"
))
.
setHttpClientConfigCallback
(
httpClientConfigCallback
));
}
...
...
@@ -138,6 +144,7 @@ public class ElasticSearchRepository {
XContentType
.
JSON
);
LOGGER
.
info
(
"Index request: "
+
indexRequest
);
IndexResponse
response
=
client
.
index
(
indexRequest
,
RequestOptions
.
DEFAULT
);
client2
.
index
(
indexRequest
,
RequestOptions
.
DEFAULT
);
if
(!
StringUtils
.
isBlank
(
response
.
toString
()))
LOGGER
.
info
(
"Response : {}"
,
response
);
}
catch
(
Exception
e
)
{
...
...
@@ -224,7 +231,21 @@ public class ElasticSearchRepository {
}
return
response
;
}
public
MultiSearchResponse
executeMultiSearchRequest2
(
SearchRequest
searchRequest
)
{
MultiSearchResponse
response
=
null
;
try
{
MultiSearchRequest
multiRequest
=
new
MultiSearchRequest
();
multiRequest
.
add
(
searchRequest
);
response
=
client2
.
msearch
(
multiRequest
,
RequestOptions
.
DEFAULT
);
}
catch
(
IOException
e
)
{
LOGGER
.
error
(
marker
,
"Encountered an error while connecting : "
,
e
);
LOGGER
.
error
(
marker
,
"Error Message to report :{} "
,
e
.
getMessage
());
}
return
response
;
}
public
MultiSearchResponse
executeMultiSearchRequest
(
List
<
SearchRequest
>
searchRequests
)
{
MultiSearchResponse
response
=
null
;
try
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets