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