Browse Source

refactor: add type annotation and error handling to appendHighlight method

Shun Miyazawa 9 months ago
parent
commit
c10266e273
1 changed files with 5 additions and 1 deletions
  1. 5 1
      apps/app/src/server/service/search-delegator/elasticsearch.ts

+ 5 - 1
apps/app/src/server/service/search-delegator/elasticsearch.ts

@@ -848,7 +848,11 @@ class ElasticsearchDelegator implements SearchDelegator<Data, ESTermsKey, ESQuer
     };
   }
 
-  appendHighlight(query): void {
+  appendHighlight(query: SearchQuery): void {
+    if (query.body == null) {
+      throw new Error('query.body is not initialized');
+    }
+
     query.body.highlight = {
       fragmenter: 'simple',
       pre_tags: ["<em class='highlighted-keyword'>"],