1
- /* eslint-disable no-underscore-dangle */
2
1
/*
3
2
* This file is part of Search NEU and licensed under AGPL3.
4
3
* See the license file in the root folder for details.
5
4
*/
6
5
7
- import { Client as OsClient } from "@opensearch-project/opensearch" ;
8
- import { ResponseError } from "@opensearch-project/opensearch/lib/errors" ;
6
+ import { Client as OsClient , errors } from "@opensearch-project/opensearch" ;
9
7
import pMap from "p-map" ;
10
8
import _ from "lodash" ;
11
9
import macros from "./macros" ;
@@ -17,6 +15,7 @@ import {
17
15
} from "../types/searchTypes" ;
18
16
import employeeMap from "../scrapers/employees/employeeMapping.json" ;
19
17
import classMap from "../scrapers/classes/classMapping.json" ;
18
+ import { Search_Request } from "@opensearch-project/opensearch/api" ;
20
19
21
20
// TODO: The localhost should NOT be hardcoded in!
22
21
const URL : string =
@@ -288,7 +287,7 @@ export class Elastic {
288
287
index : index ,
289
288
from : from ,
290
289
size : size ,
291
- body : body ,
290
+ body : body as Search_Request [ "body" ] ,
292
291
} ) ;
293
292
}
294
293
@@ -299,7 +298,7 @@ export class Elastic {
299
298
multiQuery . push ( { index } ) ;
300
299
multiQuery . push ( query ) ;
301
300
}
302
- return client . msearch ( { body : multiQuery } ) ;
301
+ return client . msearch ( { body : multiQuery } ) as unknown as EsMultiResult ;
303
302
}
304
303
305
304
closeClient ( ) : void {
@@ -326,7 +325,7 @@ export class Elastic {
326
325
}
327
326
328
327
// If it's a 429, we'll get a ResponseError
329
- if ( e instanceof ResponseError ) {
328
+ if ( e instanceof errors . ResponseError ) {
330
329
macros . warn ( "Request failed - retrying..." ) ;
331
330
// Each time, we want to wait a little longer
332
331
const timeoutMs = ( i + 1 ) * RETRY_TIME_MULTIPLIER ;
0 commit comments