Selaa lähdekoodia

add tag query when search page

yusuketk 7 vuotta sitten
vanhempi
sitoutus
b587592366
1 muutettua tiedostoa jossa 7 lisäystä ja 0 poistoa
  1. 7 0
      src/server/util/search.js

+ 7 - 0
src/server/util/search.js

@@ -522,6 +522,13 @@ SearchClient.prototype.appendCriteriaForQueryString = function(query, queryStrin
     });
     });
     query.body.query.bool.filter.push({ bool: { must_not: queries } });
     query.body.query.bool.filter.push({ bool: { must_not: queries } });
   }
   }
+
+  if (parsedKeywords.tag.length > 0) {
+    const queries = parsedKeywords.tag.map((tag) => {
+      return { term: { tag_names: tag } };
+    });
+    query.body.query.bool.filter.push({ bool: { should: queries } });
+  }
 };
 };
 
 
 SearchClient.prototype.filterPagesByViewer = async function(query, user, userGroups) {
 SearchClient.prototype.filterPagesByViewer = async function(query, user, userGroups) {