Merge branch 'typesense-search-engine' into fix-bugs
This commit is contained in:
@@ -64,12 +64,25 @@ const ensureCollectionExists = async () => {
|
||||
}
|
||||
|
||||
const searchBelongings = async (inputQuery) => {
|
||||
inputQuery = updateInputQuery(inputQuery, {})
|
||||
|
||||
const tsFeatures = new TsApiFeatures(client, 'belongings', inputQuery).filter().facet().sort().limitFields().paginate().search()
|
||||
|
||||
let { facets, items, totalCount, pagesCount } = await tsFeatures.execute()
|
||||
|
||||
return { facets, belongings: items, totalCount, pagesCount }
|
||||
}
|
||||
|
||||
const updateInputQuery = (inputQuery, extraQueries, features) => {
|
||||
for (const [key, value] of Object.entries(extraQueries)) {
|
||||
inputQuery[key] = value
|
||||
}
|
||||
|
||||
inputQuery.query_by = 'name,unit,tags,description,_id'
|
||||
|
||||
return inputQuery
|
||||
}
|
||||
|
||||
const indexAllBelongings = async () => {
|
||||
const batchSize = 20
|
||||
const count = await Belonging.countDocuments({}, null)
|
||||
|
||||
Reference in New Issue
Block a user