From 364fbe0ad769daaf147a044bf759840f25d4ea25 Mon Sep 17 00:00:00 2001 From: David Ascanio Date: Tue, 26 May 2026 18:31:49 -0300 Subject: [PATCH] filter browse results to only show items with paragraphs --- app/components/searchPanel/SearchPanel.vue | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/components/searchPanel/SearchPanel.vue b/app/components/searchPanel/SearchPanel.vue index 53cfe9b..86b7c7c 100644 --- a/app/components/searchPanel/SearchPanel.vue +++ b/app/components/searchPanel/SearchPanel.vue @@ -329,21 +329,27 @@ async function runBrowse(page = 1, append = false) { multiSearchParameters: {}, multiSearchSearchesParameter: { searches: [{ - collection: props.mainCollection, + collection: props.paragraphsCollection, q: '*', - queryBy: 'title', + queryBy: QUERY_BY, filterBy: filterBy.value, - sortBy: 'timestamp:desc', + sortBy: `$${props.mainCollection}(timestamp:desc)`, + groupBy: props.groupByField, perPage: settings.pageSize, 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 - const result = (multi?.results?.[0] as { found?: number, hits?: Array<{ document: DocMeta }> } | undefined) - const newItems = (result?.hits ?? []).map(h => ({ docId: h.document.id!, meta: h.document })) + const result = (multi?.results?.[0] as TypesenseSearchResponse | undefined) + const rawGroups = result?.groupedHits ?? [] + const newItems = rawGroups.map(g => { + const docId = g.groupKey[0]! + const parentMeta = (g.hits[0]?.document as unknown as Record)[props.mainCollection] as Partial | undefined + return { docId, meta: { id: docId, ...parentMeta } as DocMeta } + }) browseItems.value = append ? browseItems.value.concat(newItems) : newItems browseTotal.value = result?.found ?? browseItems.value.length