Przeglądaj źródła

add not tag search filter

yusuketk 7 lat temu
rodzic
commit
95a7e7fc6b
1 zmienionych plików z 8 dodań i 1 usunięć
  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) {
     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 } });
   }
+
+  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) {