Explorar o código

Merge pull request #6121 from weseek/fix/ensure-backword-compatibility-for-es6-highlighting-query

fix: Ensure backword compatibility for ES6 when using max_analyzed_offset
Yohei Shiina %!s(int64=3) %!d(string=hai) anos
pai
achega
9a8f33f17a

+ 4 - 1
packages/app/src/server/service/search-delegator/elasticsearch.ts

@@ -943,7 +943,6 @@ class ElasticsearchDelegator implements SearchDelegator<Data, ESTermsKey, ESQuer
 
 
   appendHighlight(query) {
   appendHighlight(query) {
     query.body.highlight = {
     query.body.highlight = {
-      max_analyzed_offset: 1000000 - 1, // Set the query parameter [max_analyzed_offset] to a value less than index setting [1000000] and this will tolerate long field values by truncating them.
       fields: {
       fields: {
         '*': {
         '*': {
           fragment_size: 40,
           fragment_size: 40,
@@ -953,6 +952,10 @@ class ElasticsearchDelegator implements SearchDelegator<Data, ESTermsKey, ESQuer
         },
         },
       },
       },
     };
     };
+
+    if (!this.isElasticsearchV6) {
+      query.body.highlight.max_analyzed_offset = 1000000 - 1; // Set the query parameter [max_analyzed_offset] to a value less than index setting [1000000] and this will tolerate long field values by truncating them.
+    }
   }
   }
 
 
   async search(data: SearchableData<ESQueryTerms>, user, userGroups, option): Promise<ISearchResult<unknown>> {
   async search(data: SearchableData<ESQueryTerms>, user, userGroups, option): Promise<ISearchResult<unknown>> {