diff --git a/apis/product/routes/controller/getProductInfo.js b/apis/product/routes/controller/getProductInfo.js index 8c47a6c..0cfbc71 100644 --- a/apis/product/routes/controller/getProductInfo.js +++ b/apis/product/routes/controller/getProductInfo.js @@ -9,13 +9,6 @@ const getProductListController = async (req, res, next) => { }; delete res.locals.filter; } - if (res.locals.keyword) { - res.locals.query = { - ...res.locals.query, - ...res.locals.keyword, - }; - delete res.locals.keyword; - } try { const list = await getElasticSearchResults(res.locals); res.json(list); diff --git a/apis/product/routes/middleware/listView.js b/apis/product/routes/middleware/listView.js index e2f544b..fa61b08 100644 --- a/apis/product/routes/middleware/listView.js +++ b/apis/product/routes/middleware/listView.js @@ -6,7 +6,7 @@ import { } from '../../core/string-conveter'; const addFilter = (filter = [], query) => { - if ('range' in query) { + if ('range' in query || 'term' in query) { return [...filter, query]; } return [...filter, { bool: query }]; @@ -106,12 +106,13 @@ const addOrderToOption = ({ query: { sort } }, res, next) => { next(); }; -// TODO 키워드 검색(토크나이저...) +// TODO 키워드 검색 const addKeywordTofilter = ({ query: { keyword } }, res, next) => { if (keyword) { - res.locals.keyword = { + const query = { term: { title: keyword }, }; + res.locals.filter = addFilter(res.locals.filter, query); } next(); };