Skip to content

Commit 54991f7

Browse files
Peter Bengtssonrachmari
andauthored
connect to ES 7.11 (github#30462)
Co-authored-by: Rachael Sewell <[email protected]>
1 parent 63599cf commit 54991f7

File tree

5 files changed

+95
-491
lines changed

5 files changed

+95
-491
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
if: ${{ matrix.test-group == 'content' }}
5353
uses: getong/elasticsearch-action@95b501ab0c83dee0aac7c39b7cea3723bef14954
5454
with:
55-
elasticsearch version: '7.17.5'
55+
elasticsearch version: '7.11.1'
5656
host port: 9200
5757
container port: 9200
5858
host node port: 9300

middleware/api/es-search.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,24 @@ export async function getSearchResults({
4848
const highlight = getHighlightConfiguration(query)
4949

5050
const searchQuery = {
51-
index: indexName,
5251
highlight,
5352
from,
5453
size,
55-
// Since we know exactly which fields from the source we're going
56-
// need we can specify that here. It's an inclusion list.
57-
// We can save precious network by not having to transmit fields
58-
// stored in Elasticsearch to here if it's not going to be needed
59-
// anyway.
60-
_source_includes: [
61-
'title',
62-
'url',
63-
'breadcrumbs',
64-
// 'headings'
65-
'popularity',
66-
],
54+
55+
// COMMENTED out because of ES 7.11.
56+
// Once we're on ES >7.11 we can add this option in.
57+
// // Since we know exactly which fields from the source we're going
58+
// // need we can specify that here. It's an inclusion list.
59+
// // We can save precious network by not having to transmit fields
60+
// // stored in Elasticsearch to here if it's not going to be needed
61+
// // anyway.
62+
// _source_includes: [
63+
// 'title',
64+
// 'url',
65+
// 'breadcrumbs',
66+
// // 'headings'
67+
// 'popularity',
68+
// ],
6769
}
6870

6971
if (includeTopics) {
@@ -107,15 +109,17 @@ export async function getSearchResults({
107109
throw new Error(`Unrecognized sort enum '${sort}'`)
108110
}
109111

110-
const result = await client.search(searchQuery)
112+
const result = await client.search({ index: indexName, body: searchQuery })
111113

112-
const hits = getHits(result.hits.hits, { indexName, debug, includeTopics })
114+
// const hitsAll = result.hits // ES >7.11
115+
const hitsAll = result.body // ES <=7.11
116+
const hits = getHits(hitsAll.hits.hits, { indexName, debug, includeTopics })
113117
const t1 = new Date()
114118

115119
const meta = {
116-
found: result.hits.total,
120+
found: hitsAll.hits.total,
117121
took: {
118-
query_msec: result.took,
122+
query_msec: hitsAll.took,
119123
total_msec: t1.getTime() - t0.getTime(),
120124
},
121125
page,

0 commit comments

Comments
 (0)