Explorar el Código

get max body length to index from configManager

Yuki Takei hace 1 año
padre
commit
0f5982d343

+ 4 - 2
apps/app/src/server/service/search-delegator/elasticsearch.ts

@@ -448,6 +448,8 @@ class ElasticsearchDelegator implements SearchDelegator<Data, ESTermsKey, ESQuer
     const countQuery = new PageQueryBuilder(queryFactory()).query;
     const countQuery = new PageQueryBuilder(queryFactory()).query;
     const totalCount = await countQuery.count();
     const totalCount = await countQuery.count();
 
 
+    const maxBodyLengthToIndex = configManager.getConfig('crowi', 'app:elasticsearchMaxBodyLengthToIndex');
+
     const readStream = Page
     const readStream = Page
       .aggregate<AggregatedPage>([
       .aggregate<AggregatedPage>([
         // filter targets
         // filter targets
@@ -550,7 +552,7 @@ class ElasticsearchDelegator implements SearchDelegator<Data, ESTermsKey, ESQuer
             grantedGroups: 1,
             grantedGroups: 1,
             'revision.body': {
             'revision.body': {
               $cond: {
               $cond: {
-                if: { $lte: ['$bodyLength', 100000] },
+                if: { $lte: ['$bodyLength', maxBodyLengthToIndex] },
                 then: '$revision.body',
                 then: '$revision.body',
                 else: '',
                 else: '',
               },
               },
@@ -561,7 +563,7 @@ class ElasticsearchDelegator implements SearchDelegator<Data, ESTermsKey, ESQuer
                 as: 'comment',
                 as: 'comment',
                 in: {
                 in: {
                   $cond: {
                   $cond: {
-                    if: { $lte: ['$$comment.commentLength', 100000] },
+                    if: { $lte: ['$$comment.commentLength', maxBodyLengthToIndex] },
                     then: '$$comment.comment',
                     then: '$$comment.comment',
                     else: '',
                     else: '',
                   },
                   },