mirror of https://github.com/pelias/api.git
Browse Source
query/category_filter.js -Define a function that handles injecting category-filtration logic into elasticsearch queries. -Abstract it out into a standalone module since it's going to be used by both `query/search.js` and `query/reverse.js`. sanitiser/search.js, test/unit/sanitiser/search.js -Add category filtration to `/search`. -Fixes (partly) #128search-suggest-categories
Severyn Kozak
10 years ago
4 changed files with 21 additions and 2 deletions
@ -0,0 +1,16 @@
|
||||
/** |
||||
* Inject the logic for filtering results by category into an elasticsearch |
||||
* query. |
||||
*/ |
||||
|
||||
'use strict'; |
||||
|
||||
module.exports = function ( query, params ){ |
||||
if( params.categories && params.categories.length > 0 ){ |
||||
query.query.filtered.filter.bool.must.push({ |
||||
terms: { |
||||
category: params.categories |
||||
} |
||||
}); |
||||
} |
||||
}; |
Loading…
Reference in new issue