فهرست منبع

added contentWithNoKeyword to page

Mao 4 سال پیش
والد
کامیت
ea133039ed
2فایلهای تغییر یافته به همراه8 افزوده شده و 2 حذف شده
  1. 6 1
      packages/app/src/components/SearchPage/SearchResultList.jsx
  2. 2 1
      packages/app/src/server/routes/search.js

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

@@ -12,7 +12,12 @@ class SearchResultList extends React.Component {
       // TODO : send cetain chars of body (revisionBody) from elastisearch by adding some settings to the query
       // story: 77515 task : not created yet.
       let snippet = '';
-      if (page.elasticSearchResultInfo.snippet.length > 40) { snippet = page.elasticSearchResultInfo.snippet.substr(0, 40) }
+      if (page.elasticSearchResultInfo.contentWithNoSearchedKeyword != null) {
+        if (page.elasticSearchResultInfo.contentWithNoSearchedKeyword.length > 40) {
+          snippet = page.elasticSearchResultInfo.contentWithNoSearchedKeyword.substr(0, 40);
+        }
+        snippet = page.elasticSearchResultInfo.contentWithNoSearchedKeyword;
+      }
       else { snippet = page.elasticSearchResultInfo.snippet }
       return (
         <li key={page._id} className="nav-item page-list-li w-100 m-0 border-bottom">

+ 2 - 1
packages/app/src/server/routes/search.js

@@ -164,7 +164,7 @@ module.exports = function(crowi, app) {
         const data = esResult.data.find((data) => { return page.id === data._id });
         page._doc.tags = data._source.tag_names;
         if (data._highlight['body.en'] == null && data._highlight['body.ja'] == null) {
-          elasticSearchResult.snippet = myXss.process(data._source.body);
+          elasticSearchResult.contentWithNoSearchedKeyword = myXss.process(data._source.body);
         }
         else {
           const snippet = data._highlight['body.en'] == null ? data._highlight['body.ja'] : data._highlight['body.en'];
@@ -196,6 +196,7 @@ module.exports = function(crowi, app) {
     catch (err) {
       return res.json(ApiResponse.error(err));
     }
+    console.log(JSON.stringify(result));
     return res.json(ApiResponse.success(result));
   };