@@ -48,22 +48,24 @@ export async function getSearchResults({
48
48
const highlight = getHighlightConfiguration ( query )
49
49
50
50
const searchQuery = {
51
- index : indexName ,
52
51
highlight,
53
52
from,
54
53
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
+ // ],
67
69
}
68
70
69
71
if ( includeTopics ) {
@@ -107,15 +109,17 @@ export async function getSearchResults({
107
109
throw new Error ( `Unrecognized sort enum '${ sort } '` )
108
110
}
109
111
110
- const result = await client . search ( searchQuery )
112
+ const result = await client . search ( { index : indexName , body : searchQuery } )
111
113
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 } )
113
117
const t1 = new Date ( )
114
118
115
119
const meta = {
116
- found : result . hits . total ,
120
+ found : hitsAll . hits . total ,
117
121
took : {
118
- query_msec : result . took ,
122
+ query_msec : hitsAll . took ,
119
123
total_msec : t1 . getTime ( ) - t0 . getTime ( ) ,
120
124
} ,
121
125
page,
0 commit comments