Pārlūkot izejas kodu

Handle "tree" parameter in search method

Sotaro KARASAWA 9 gadi atpakaļ
vecāks
revīzija
b6f531690c
1 mainītis faili ar 9 papildinājumiem un 1 dzēšanām
  1. 9 1
      lib/routes/search.js

+ 9 - 1
lib/routes/search.js

@@ -33,6 +33,7 @@ module.exports = function(crowi, app) {
    */
   api.search = function(req, res){
     var keyword = req.query.q || null;
+    var tree = req.query.tree || null;
     if (keyword === null || keyword === '') {
       return res.json(ApiResponse.error('keyword should not empty.'));
     }
@@ -42,8 +43,15 @@ module.exports = function(crowi, app) {
       return res.json(ApiResponse.error('Configuration of ELASTICSEARCH_URI is required.'));
     }
 
+
+    var doSearch;
+    if (tree) {
+      doSearch = this.searchKeywordUnderPath(keyword, tree, {});
+    } else {
+      doSearch = this.searchKeyword(keyword, {});
+    }
     var result = {};
-    search.searchKeyword(keyword, {})
+    doSearch
       .then(function(data) {
         result.meta = data.meta;