[feat] tweaking sort and facet matching
This commit is contained in:
@@ -33,16 +33,17 @@ const searchResults = await client.collections('cards').documents().search({
|
||||
filter_by: `sealed:false${filterBy ? ` && ${filterBy}` : ''}`,
|
||||
query_by: 'productLineName,productName,setName,number,rarityName,Artist',
|
||||
per_page: 20,
|
||||
facet_by: 'productLineName,setName,rarityName,cardType,energyType',
|
||||
facet_by: 'productLineName,setName,variant,rarityName,cardType,energyType',
|
||||
page: Math.floor(start / 20) + 1,
|
||||
sort_by: '_text_match:asc, releaseDate:desc, productName:asc',
|
||||
});
|
||||
const productIds = searchResults.hits?.map((hit: any) => hit.document.productId) ?? [];
|
||||
const cardIds = searchResults.hits?.map((hit: any) => hit.document.cardId) ?? [];
|
||||
const totalHits = searchResults.found;
|
||||
const facets = searchResults.facet_counts;
|
||||
|
||||
// get pokemon data with prices and set info using searchResults and then query the database for each card to get the prices and set info
|
||||
const pokemon = await db.query.cards.findMany({
|
||||
where: { productId: { in: productIds, }, },
|
||||
where: { cardId: { in: cardIds, }, },
|
||||
with: {
|
||||
prices: true,
|
||||
set: true,
|
||||
@@ -74,6 +75,7 @@ const facetNames = (name:string) => {
|
||||
return {
|
||||
"productLineName": "Product Line",
|
||||
"setName": "Set",
|
||||
"variant": "Variant",
|
||||
"rarityName": "Rarity",
|
||||
"cardType": "Card Type",
|
||||
"energyType": "Energy Type"
|
||||
|
||||
Reference in New Issue
Block a user