Merge branch 'new-collections' of https://gitea.carpa.com/LGCC/search into new-collections
This commit is contained in:
commit
9f7d868d2b
|
|
@ -329,21 +329,27 @@ async function runBrowse(page = 1, append = false) {
|
||||||
multiSearchParameters: {},
|
multiSearchParameters: {},
|
||||||
multiSearchSearchesParameter: {
|
multiSearchSearchesParameter: {
|
||||||
searches: [{
|
searches: [{
|
||||||
collection: props.mainCollection,
|
collection: props.paragraphsCollection,
|
||||||
q: '*',
|
q: '*',
|
||||||
queryBy: 'title',
|
queryBy: QUERY_BY,
|
||||||
filterBy: filterBy.value,
|
filterBy: filterBy.value,
|
||||||
sortBy: 'timestamp:desc',
|
sortBy: `$${props.mainCollection}(timestamp:desc)`,
|
||||||
|
groupBy: props.groupByField,
|
||||||
perPage: settings.pageSize,
|
perPage: settings.pageSize,
|
||||||
page: typePage,
|
page: typePage,
|
||||||
includeFields: 'id,title,date,timestamp,place,city,state,country,type,slug,draft'
|
includeFields: `$${props.mainCollection}(id,title,date,timestamp,place,city,state,country,type,slug,draft)`
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
console.log('Browse result', multi)
|
||||||
if (seq !== searchSeq) return
|
if (seq !== searchSeq) return
|
||||||
const result = (multi?.results?.[0] as { found?: number, hits?: Array<{ document: DocMeta }> } | undefined)
|
const result = (multi?.results?.[0] as TypesenseSearchResponse | undefined)
|
||||||
const newItems = (result?.hits ?? []).map(h => ({ docId: h.document.id!, meta: h.document }))
|
const rawGroups = result?.groupedHits ?? []
|
||||||
|
const newItems = rawGroups.map(g => {
|
||||||
|
const docId = g.groupKey[0]!
|
||||||
|
const parentMeta = (g.hits[0]?.document as unknown as Record<string, unknown>)[props.mainCollection] as Partial<DocMeta> | undefined
|
||||||
|
return { docId, meta: { id: docId, ...parentMeta } as DocMeta }
|
||||||
|
})
|
||||||
|
|
||||||
browseItems.value = append ? browseItems.value.concat(newItems) : newItems
|
browseItems.value = append ? browseItems.value.concat(newItems) : newItems
|
||||||
browseTotal.value = result?.found ?? browseItems.value.length
|
browseTotal.value = result?.found ?? browseItems.value.length
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue