← back to Wallco Ai
wallco.ai · /api/designs/search now returns facets — motifs (top-8) + categories (all) rolled up from matched designs · purely additive JSON field, existing autocomplete dropdown ignores it cleanly until wired into a future 'refine by motif' UI · verified q=rose → 53 hits, top motifs floral/peony/rose/leaf/vine, top categories damask/floral/mixed
4b1b3ede5ab0742f652ad7b386e890b9e689371c · 2026-05-12 08:02:09 -0700 · SteveStudio2
Files touched
Diff
commit 4b1b3ede5ab0742f652ad7b386e890b9e689371c
Author: SteveStudio2 <stevestudio2@SteveStacStudio.lan>
Date: Tue May 12 08:02:09 2026 -0700
wallco.ai · /api/designs/search now returns facets — motifs (top-8) + categories (all) rolled up from matched designs · purely additive JSON field, existing autocomplete dropdown ignores it cleanly until wired into a future 'refine by motif' UI · verified q=rose → 53 hits, top motifs floral/peony/rose/leaf/vine, top categories damask/floral/mixed
---
server.js | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/server.js b/server.js
index af7fa13..85cb66f 100644
--- a/server.js
+++ b/server.js
@@ -261,11 +261,36 @@ app.get('/api/designs/search', (req, res) => {
}
}
out.sort((a, b) => b.score - a.score || b.saturation - a.saturation);
+ // Facet counts — rolled up from the matched designs.
+ // Lets a UI show "Refine: rose (12) · peony (8) · scrollwork (5)" alongside results.
+ const motifTally = Object.create(null);
+ const categoryTally = Object.create(null);
+ for (const r of out) {
+ // r holds the projected shape; pull the source design back for full motifs list.
+ const src = DESIGNS.find(d => d.id === r.id);
+ if (!src) continue;
+ for (const m of (src.motifs || [])) {
+ const k = String(m).toLowerCase().trim();
+ if (k) motifTally[k] = (motifTally[k] || 0) + 1;
+ }
+ if (src.category) categoryTally[src.category] = (categoryTally[src.category] || 0) + 1;
+ }
+ const topMotifs = Object.entries(motifTally)
+ .sort((a, b) => b[1] - a[1])
+ .slice(0, 8)
+ .map(([motif, count]) => ({ motif, count }));
+ const topCategories = Object.entries(categoryTally)
+ .sort((a, b) => b[1] - a[1])
+ .map(([category, count]) => ({ category, count }));
res.json({
q: qRaw,
limit,
count: out.length,
results: out.slice(0, limit),
+ facets: {
+ motifs: topMotifs,
+ categories: topCategories,
+ },
});
});
← 3622bf5 wallco.ai · /designs search box → live autocomplete dropdown
·
back to Wallco Ai
·
wallco.ai · professional/trade functions — 3 new designer-wo d6bebc3 →