|
|
@@ -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;
|
|
|
|