Pārlūkot izejas kodu

Merge branch 'master' into imprv/vrt-tests

Yuki Takei 4 gadi atpakaļ
vecāks
revīzija
9d17e2de75

+ 1 - 0
packages/app/.env.development

@@ -4,6 +4,7 @@
 ##
 ##
 MIGRATIONS_DIR=src/migrations/
 MIGRATIONS_DIR=src/migrations/
 
 
+APP_SITE_URL=http://localhost:3000
 FILE_UPLOAD=mongodb
 FILE_UPLOAD=mongodb
 # MONGO_GRIDFS_TOTAL_LIMIT=10485760
 # MONGO_GRIDFS_TOTAL_LIMIT=10485760
 MATHJAX=1
 MATHJAX=1

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

@@ -614,22 +614,25 @@ class ElasticsearchDelegator implements SearchDelegator<Data> {
    * }
    * }
    */
    */
   async searchKeyword(query): Promise<IFormattedSearchResult> {
   async searchKeyword(query): Promise<IFormattedSearchResult> {
+
     // for debug
     // for debug
     if (process.env.NODE_ENV === 'development') {
     if (process.env.NODE_ENV === 'development') {
+      logger.debug('query: ', { query });
+
       const { body: result } = await this.client.indices.validateQuery({
       const { body: result } = await this.client.indices.validateQuery({
+        index: query.index,
+        type: query.type,
         explain: true,
         explain: true,
         body: {
         body: {
           query: query.body.query,
           query: query.body.query,
         },
         },
       });
       });
-      logger.debug('ES returns explanations: ', result.explanations);
+      // for debug
+      logger.debug('ES result: ', result);
     }
     }
 
 
     const { body: result } = await this.client.search(query);
     const { body: result } = await this.client.search(query);
 
 
-    // for debug
-    logger.debug('ES result: ', result);
-
     const totalValue = this.isElasticsearchV6 ? result.hits.total : result.hits.total.value;
     const totalValue = this.isElasticsearchV6 ? result.hits.total : result.hits.total.value;
 
 
     return {
     return {
@@ -665,9 +668,9 @@ class ElasticsearchDelegator implements SearchDelegator<Data> {
     // eslint-disable-next-line prefer-const
     // eslint-disable-next-line prefer-const
     let query = {
     let query = {
       index: this.aliasName,
       index: this.aliasName,
+      _source: fields,
       body: {
       body: {
         query: {}, // query
         query: {}, // query
-        _source: fields,
       },
       },
     };
     };
 
 
@@ -687,7 +690,7 @@ class ElasticsearchDelegator implements SearchDelegator<Data> {
     // default sort order is score descending
     // default sort order is score descending
     const sort = ES_SORT_AXIS[sortAxis] || ES_SORT_AXIS[RELATION_SCORE];
     const sort = ES_SORT_AXIS[sortAxis] || ES_SORT_AXIS[RELATION_SCORE];
     const order = ES_SORT_ORDER[sortOrder] || ES_SORT_ORDER[DESC];
     const order = ES_SORT_ORDER[sortOrder] || ES_SORT_ORDER[DESC];
-    query.body.sort = { [sort]: { order } };
+    query.sort = { [sort]: { order } };
   }
   }
 
 
   convertSortQuery(sortAxis) {
   convertSortQuery(sortAxis) {