Просмотр исходного кода

Merge pull request #897 from weseek/feat/add-tag-search-query

Feat/add tag search query
Yuki Takei 7 лет назад
Родитель
Сommit
c45139a7e1
1 измененных файлов с 14 добавлено и 0 удалено
  1. 14 0
      src/server/util/search.js

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

@@ -532,6 +532,20 @@ SearchClient.prototype.appendCriteriaForQueryString = function(query, queryStrin
     });
     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: { must: queries } });
+  }
+
+  if (parsedKeywords.not_tag.length > 0) {
+    const queries = parsedKeywords.not_tag.map((tag) => {
+      return { term: { tag_names: tag } };
+    });
+    query.body.query.bool.filter.push({ bool: { must_not: queries } });
+  }
 };
 
 SearchClient.prototype.filterPagesByViewer = async function(query, user, userGroups) {