|
@@ -14,6 +14,7 @@ import { SearchDelegatorName } from '~/interfaces/named-query';
|
|
|
import {
|
|
import {
|
|
|
MetaData, SearchDelegator, Result, SearchableData, QueryTerms,
|
|
MetaData, SearchDelegator, Result, SearchableData, QueryTerms,
|
|
|
} from '../../interfaces/search';
|
|
} from '../../interfaces/search';
|
|
|
|
|
+import ElasticsearchClient from './elasticsearch-client';
|
|
|
|
|
|
|
|
const logger = loggerFactory('growi:service:search-delegator:elasticsearch');
|
|
const logger = loggerFactory('growi:service:search-delegator:elasticsearch');
|
|
|
|
|
|
|
@@ -100,16 +101,19 @@ class ElasticsearchDelegator implements SearchDelegator<Data> {
|
|
|
initClient() {
|
|
initClient() {
|
|
|
const { host, auth, indexName } = this.getConnectionInfo();
|
|
const { host, auth, indexName } = this.getConnectionInfo();
|
|
|
|
|
|
|
|
- this.client = new this.elasticsearch.Client({
|
|
|
|
|
|
|
+ this.client = new ElasticsearchClient(new this.elasticsearch.Client({
|
|
|
node: host,
|
|
node: host,
|
|
|
ssl: { rejectUnauthorized: this.configManager.getConfig('crowi', 'app:elasticsearchRejectUnauthorized') },
|
|
ssl: { rejectUnauthorized: this.configManager.getConfig('crowi', 'app:elasticsearchRejectUnauthorized') },
|
|
|
auth,
|
|
auth,
|
|
|
requestTimeout: this.configManager.getConfig('crowi', 'app:elasticsearchRequestTimeout'),
|
|
requestTimeout: this.configManager.getConfig('crowi', 'app:elasticsearchRequestTimeout'),
|
|
|
- // log: 'debug',
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ }));
|
|
|
this.indexName = indexName;
|
|
this.indexName = indexName;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ getType() {
|
|
|
|
|
+ return this.isElasticsearchV6 ? 'pages' : '_doc';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* return information object to connect to ES
|
|
* return information object to connect to ES
|
|
|
* @return {object} { host, auth, indexName}
|
|
* @return {object} { host, auth, indexName}
|
|
@@ -348,7 +352,7 @@ class ElasticsearchDelegator implements SearchDelegator<Data> {
|
|
|
const command = {
|
|
const command = {
|
|
|
index: {
|
|
index: {
|
|
|
_index: this.indexName,
|
|
_index: this.indexName,
|
|
|
- _type: this.isElasticsearchV6 ? 'pages' : '_doc',
|
|
|
|
|
|
|
+ _type: this.getType(),
|
|
|
_id: page._id.toString(),
|
|
_id: page._id.toString(),
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
@@ -384,7 +388,7 @@ class ElasticsearchDelegator implements SearchDelegator<Data> {
|
|
|
const command = {
|
|
const command = {
|
|
|
delete: {
|
|
delete: {
|
|
|
_index: this.indexName,
|
|
_index: this.indexName,
|
|
|
- _type: this.isElasticsearchV6 ? 'pages' : '_doc',
|
|
|
|
|
|
|
+ _type: this.getType(),
|
|
|
_id: page._id.toString(),
|
|
_id: page._id.toString(),
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|