Mao 4 лет назад
Родитель
Сommit
a41e4265c8

+ 3 - 6
packages/app/src/components/SearchPage/SearchResultList.jsx

@@ -9,14 +9,11 @@ class SearchResultList extends React.Component {
   render() {
     return this.props.pages.map((page) => {
       const pageId = `#${page._id}`;
-      // TODO : send cetain  length of body (revisionBody) from elastisearch by adding some settings to the query
-      // if such thing not possible , find revisionBody using query each time needed instead of putting body to esResult.
+      // TODO : send cetain  length of body (revisionBody) from elastisearch by adding some settings to the query and
+      //         when keyword is not in page content, display revisionBody.
       // TASK : https://estoc.weseek.co.jp/redmine/issues/79606
       let snippet = '';
-      if (page.elasticSearchResultInfo.contentWithNoSearchedKeyword != null) {
-        snippet = page.elasticSearchResultInfo.contentWithNoSearchedKeyword.substr(0, 40);
-      }
-      else { snippet = page.elasticSearchResultInfo.snippet }
+      snippet = page.elasticSearchResultInfo.snippet;
       return (
         <li key={page._id} className="nav-item page-list-li w-100 m-0 border-bottom">
           <a

+ 2 - 2
packages/app/src/server/service/search-delegator/elasticsearch.js

@@ -565,7 +565,7 @@ class ElasticsearchDelegator {
 
   createSearchQuerySortedByUpdatedAt(option) {
     // getting path by default is almost for debug
-    let fields = ['path', 'bookmark_count', 'body', 'comment_count', 'seenUsers_count', 'updated_at', 'tag_names'];
+    let fields = ['path', 'bookmark_count', 'comment_count', 'seenUsers_count', 'updated_at', 'tag_names'];
     if (option) {
       fields = option.fields || fields;
     }
@@ -586,7 +586,7 @@ class ElasticsearchDelegator {
   }
 
   createSearchQuerySortedByScore(option) {
-    let fields = ['path', 'bookmark_count', 'body', 'comment_count', 'seenUsers_count', 'updated_at', 'tag_names'];
+    let fields = ['path', 'bookmark_count', 'comment_count', 'seenUsers_count', 'updated_at', 'tag_names'];
     if (option) {
       fields = option.fields || fields;
     }

+ 5 - 9
packages/app/src/server/service/search.js

@@ -157,15 +157,11 @@ class SearchService {
     }
     esResult.data.forEach((data) => {
       const elasticSearchResult = { snippet: '', matchedPath: '' };
-      if (data._highlight['body.en'] == null && data._highlight['body.ja'] == null) {
-        elasticSearchResult.contentWithNoSearchedKeyword = myXss.process(data._source.body);
-      }
-      else {
-        const snippet = data._highlight['body.en'] == null ? data._highlight['body.ja'] : data._highlight['body.en'];
-        elasticSearchResult.snippet = myXss.process(snippet);
-      }
-      if (data._highlight['path.en'] !== null && data._highlight['path.ja'] !== null) {
-        const pathMatch = data._highlight['path.en'] == null ? data._highlight['path.ja'] : data._highlight['path.en'];
+      const highlightData = data._highlight;
+      const snippet = highlightData['body.en'] || highlightData['body.ja'];
+      elasticSearchResult.snippet = myXss.process(snippet);
+      if (highlightData['path.en'] != null && highlightData['path.ja'] != null) {
+        const pathMatch = highlightData['path.en'] || highlightData['path.ja'];
         elasticSearchResult.matchedPath = pathMatch;
       }
       data.elasticSearchResultInfo = elasticSearchResult;