|
@@ -90,15 +90,12 @@ class ElasticsearchDelegator implements SearchDelegator<Data> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
initClient() {
|
|
initClient() {
|
|
|
- const { host, httpAuth, indexName } = this.getConnectionInfo();
|
|
|
|
|
- const httpAuthArr = httpAuth.split(':');
|
|
|
|
|
- const username = httpAuthArr[0];
|
|
|
|
|
- const password = httpAuthArr[1];
|
|
|
|
|
|
|
+ const { host, auth, indexName } = this.getConnectionInfo();
|
|
|
|
|
|
|
|
this.client = new elasticsearch.Client({
|
|
this.client = new elasticsearch.Client({
|
|
|
node: host,
|
|
node: host,
|
|
|
- ssl: { rejectUnauthorized: false }, // TODO: set ssl from global env config
|
|
|
|
|
- auth: { username, password },
|
|
|
|
|
|
|
+ ssl: { rejectUnauthorized: false },
|
|
|
|
|
+ auth,
|
|
|
requestTimeout: this.configManager.getConfig('crowi', 'app:elasticsearchRequestTimeout'),
|
|
requestTimeout: this.configManager.getConfig('crowi', 'app:elasticsearchRequestTimeout'),
|
|
|
// log: 'debug',
|
|
// log: 'debug',
|
|
|
});
|
|
});
|
|
@@ -107,12 +104,12 @@ class ElasticsearchDelegator implements SearchDelegator<Data> {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* return information object to connect to ES
|
|
* return information object to connect to ES
|
|
|
- * @return {object} { host, httpAuth, indexName}
|
|
|
|
|
|
|
+ * @return {object} { host, auth, indexName}
|
|
|
*/
|
|
*/
|
|
|
getConnectionInfo() {
|
|
getConnectionInfo() {
|
|
|
let indexName = 'crowi';
|
|
let indexName = 'crowi';
|
|
|
let host = this.esUri;
|
|
let host = this.esUri;
|
|
|
- let httpAuth = '';
|
|
|
|
|
|
|
+ let auth;
|
|
|
|
|
|
|
|
const elasticsearchUri = this.configManager.getConfig('crowi', 'app:elasticsearchUri');
|
|
const elasticsearchUri = this.configManager.getConfig('crowi', 'app:elasticsearchUri');
|
|
|
|
|
|
|
@@ -122,13 +119,14 @@ class ElasticsearchDelegator implements SearchDelegator<Data> {
|
|
|
indexName = url.pathname.substring(1); // omit heading slash
|
|
indexName = url.pathname.substring(1); // omit heading slash
|
|
|
|
|
|
|
|
if (url.username != null && url.password != null) {
|
|
if (url.username != null && url.password != null) {
|
|
|
- httpAuth = `${url.username}:${url.password}`;
|
|
|
|
|
|
|
+ const { username, password } = url;
|
|
|
|
|
+ auth = { username, password };
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
host,
|
|
host,
|
|
|
- httpAuth,
|
|
|
|
|
|
|
+ auth,
|
|
|
indexName,
|
|
indexName,
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
@@ -525,7 +523,7 @@ class ElasticsearchDelegator implements SearchDelegator<Data> {
|
|
|
batch.forEach(doc => prepareBodyForCreate(body, doc));
|
|
batch.forEach(doc => prepareBodyForCreate(body, doc));
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- const res = await bulkWrite({
|
|
|
|
|
|
|
+ const { body: res } = await bulkWrite({
|
|
|
body,
|
|
body,
|
|
|
// requestTimeout: Infinity,
|
|
// requestTimeout: Infinity,
|
|
|
});
|
|
});
|