Explorar o código

add not tag search filter

yusuketk %!s(int64=7) %!d(string=hai) anos
pai
achega
95a7e7fc6b
Modificáronse 1 ficheiros con 8 adicións e 1 borrados
  1. 8 1
      src/server/util/search.js

+ 8 - 1
src/server/util/search.js

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