add: request + response interface changes
This commit is contained in:
1 parent
24eecd2922
commit
9b6d0c7334
4 files changed
+19
-11
No files matched your search
@@ -5,6 +5,9 @@ export default async (req, res) => {
|
||||
const schema = Validator.object()
|
||||
.keys({
|
||||
q: Validator.string().required(),
|
||||
offset: Validator.number().optional(),
|
||||
limit: Validator.number().optional(),
|
||||
filter: Validator.any(),
|
||||
})
|
||||
.options({ allowUnknown: true })
|
||||
|
||||
@@ -14,15 +17,16 @@ export default async (req, res) => {
|
||||
}
|
||||
|
||||
try {
|
||||
const { q, ...options } = value
|
||||
const { q, offset, limit, filter, ...options } = value
|
||||
const paginationOptions = { offset, limit }
|
||||
|
||||
const searchService = req.scope.resolve("searchService")
|
||||
|
||||
const results = await searchService.search(
|
||||
ProductService.IndexName,
|
||||
q,
|
||||
options
|
||||
)
|
||||
const results = await searchService.search(ProductService.IndexName, q, {
|
||||
paginationOptions,
|
||||
filter,
|
||||
additionalOptions: options,
|
||||
})
|
||||
|
||||
res.status(200).send(results)
|
||||
} catch (error) {
|
||||
|
||||
@@ -53,7 +53,7 @@ class DefaultSearchService extends SearchService {
|
||||
this.logger_.warn(
|
||||
"This is an empty method: search must be overridden a the child class"
|
||||
)
|
||||
return []
|
||||
return { hits: [] }
|
||||
}
|
||||
|
||||
updateSettings(indexName, settings) {
|
||||
|
||||
Reference in new issue
Block a user