Shun Miyazawa 3 лет назад
Родитель
Сommit
62d8db0c43

+ 0 - 2
packages/app/src/server/interfaces/search.ts

@@ -50,5 +50,3 @@ export type MongoTermsKey = 'match' | 'not_match' | 'prefix' | 'not_prefix';
 // Query Terms types
 export type ESQueryTerms = Pick<QueryTerms, ESTermsKey>;
 export type MongoQueryTerms = Pick<QueryTerms, MongoTermsKey>;
-
-export const DEFAULT_HIGHLIGHT_FRAGMENT_SIZE = 250;

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

@@ -13,8 +13,8 @@ import {
 } from '~/interfaces/search';
 import loggerFactory from '~/utils/logger';
 
-import {
-  SearchDelegator, SearchableData, QueryTerms, UnavailableTermsKey, ESQueryTerms, ESTermsKey, DEFAULT_HIGHLIGHT_FRAGMENT_SIZE,
+import { 
+  SearchDelegator, SearchableData, QueryTerms, UnavailableTermsKey, ESQueryTerms, ESTermsKey 
 } from '../../interfaces/search';
 import { PageModel } from '../../models/page';
 import { createBatchStream } from '../../util/batch-stream';
@@ -945,7 +945,7 @@ class ElasticsearchDelegator implements SearchDelegator<Data, ESTermsKey, ESQuer
     query.body.highlight = {
       fields: {
         '*': {
-          fragment_size: DEFAULT_HIGHLIGHT_FRAGMENT_SIZE,
+          fragment_size: 40,
           fragmenter: 'simple',
           pre_tags: ["<em class='highlighted-keyword'>"],
           post_tags: ['</em>'],

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

@@ -5,7 +5,6 @@ import { SearchDelegatorName } from '~/interfaces/named-query';
 import { IPageHasId } from '~/interfaces/page';
 import { IFormattedSearchResult, IPageWithSearchMeta, ISearchResult } from '~/interfaces/search';
 import {
-  DEFAULT_HIGHLIGHT_FRAGMENT_SIZE,
   SearchDelegator, SearchQueryParser, SearchResolver, ParsedQuery, SearchableData, QueryTerms,
 } from '~/server/interfaces/search';
 import loggerFactory from '~/utils/logger';
@@ -456,11 +455,9 @@ class SearchService implements SearchQueryParser, SearchResolver {
         const pathMatch = highlightData['path.en'] || highlightData['path.ja'];
         const isHtmlInPath = highlightData['path.en'] != null || highlightData['path.ja'] != null;
 
-        const shouldHighlight = pathMatch != null ? DEFAULT_HIGHLIGHT_FRAGMENT_SIZE >= pathMatch[0].length : false;
-
         elasticSearchResult = {
           snippet: snippet != null && typeof snippet[0] === 'string' ? filterXss.process(snippet) : null,
-          highlightedPath: pathMatch != null && typeof pathMatch[0] === 'string' && shouldHighlight ? filterXss.process(pathMatch) : null,
+          highlightedPath: pathMatch != null && typeof pathMatch[0] === 'string' ? filterXss.process(pathMatch) : null,
           isHtmlInPath,
         };
       }