i want to grup by typesense and i am using tanstac...
# community-help
l
i want to grup by typesense and i am using tanstack how the issue is that i have to flatten the data and render is there any alternate available ?
j
Could you elaborate with an example?
l
i want to group by using typesense and i am using tanstack which modified version of react-table inside Group_key i am getting the groupped key but it is nested JSON i wanat to render the data from grouping typesense
to achieve that currently i am doing from the frontend i have destructured the data
j
It’s still hard to understand the specifics, without an example. Could you share a sample search query, and the response you get from Typesense, and elaborate based on that?
l
I am fetching the data from typesense, and grouping by a field. But in the hightlight > document, the data is nested. Is there any way to flatten the data when I use group by?
j
the data is nested
I’m not sure I understand this part. The structure of the
highlight
object in the response just follows your document’s original structure
l
Copy code
const variantItems = itemsArray.flatMap(({ variants, itemName, id }) =>
        variants?.flatMap(
          ({
            locations,
            name: variant,
            salesPrice,
            purchasePrice,
            discountedPrice,
            discountedPricePercentage,
          }) =>
            locations.flatMap(location => ({
              id,
              itemName,
              locationName: location.location.name,
              stock: location.currentQuantity,
              variant,
              salesPrice,
              purchasePrice,
              discountedPrice,
              discountedPricePercentage,
              status: 'In-stock',
            }))
        )
      )
this is how i am getting the values to group by from the frontend can i get it with less complexity