Skip to content

Commit 80c4d8b

Browse files
committed
Upgrade elasticsearch support to 6.2
1 parent 2cb99c8 commit 80c4d8b

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"dependencies": {
1313
"async": "2.0.0-rc.2",
1414
"cheerio": "^0.19.0",
15-
"elasticsearch": "^9.0.2",
15+
"elasticsearch": "^14.1.0",
1616
"json-stable-stringify": "^1.0.1",
1717
"lodash": "^3.8.0",
1818
"mongodb": "2.0.27",

src/storage/connection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function elasticInit (callback) {
116116

117117
const client = new elasticsearch.Client({
118118
host: config.elasticsearchHost(),
119-
apiVersion: '1.7',
119+
apiVersion: '6.2',
120120
ssl: { rejectUnauthorized: true }, // Plz no trivial MITM attacks
121121
log: ElasticLogs,
122122
maxRetries: Infinity

src/storage/remote.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,10 @@ RemoteStorage.prototype.createNewIndex = function (indexName, callback) {
301301

302302
let envelopeMapping = {
303303
properties: {
304-
title: { type: 'string', index: 'analyzed' },
305-
body: { type: 'string', index: 'analyzed' },
306-
keywords: { type: 'string', index: 'analyzed' },
307-
categories: { type: 'string', index: 'not_analyzed' }
304+
title: { type: 'text', index: true, copy_to: 'all' },
305+
body: { type: 'text', index: true, copy_to: 'all' },
306+
keywords: { type: 'text', index: true, copy_to: 'all' },
307+
categories: { type: 'text', index: false, copy_to: 'all' }
308308
}
309309
};
310310

@@ -347,8 +347,7 @@ RemoteStorage.prototype.makeIndexActive = function (indexName, callback) {
347347

348348
connection.elastic.indices.get({
349349
index: 'envelopes*',
350-
ignoreUnavailable: true,
351-
feature: '_settings'
350+
ignoreUnavailable: true
352351
}, (err, response, status) => {
353352
if (err) return callback(err);
354353

@@ -374,11 +373,13 @@ RemoteStorage.prototype.queryEnvelopes = function (query, categories, pageNumber
374373
const q = {};
375374

376375
if (!categories) {
377-
q.match = { _all: query };
376+
q.match = { all: query };
378377
} else {
379-
q.filtered = {
380-
query: { match: { _all: query } },
381-
filter: { terms: { categories: categories } }
378+
q.bool = {
379+
must: {
380+
match: { all : query },
381+
filter: { terms: { categories: categories } }
382+
}
382383
};
383384
}
384385

0 commit comments

Comments
 (0)