typesense / typesense-instantsearch-adapter

A JS adapter library to build rich search interfaces with Typesense and InstantSearch.js
MIT License
361 stars 62 forks source link

groups are getting flattened in a group_by query #178

Open majestiq opened 11 months ago

majestiq commented 11 months ago

Description

when using a group by query with the instantsearch adapter, the results will be flattened. ie: groupLimit = 4 means that I will have # of results per page X 4 results showing on the page.

Expected Behavior

Only show the first items from the group and allow secondary items in the group to be access via an array in the Hits object rendering. That way, from the Hits widget, we can put in custom rendering to decide how to handle additional items in a group.

jasonbosco commented 11 months ago

@majestiq This is a great idea!

I've added the ability to turn off grouped result flattening in 2.7.1-4 of the adapter. If you upgrade to it and then add flattenGroupedHits: false you should see unflattened results:

const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
    server: {
      apiKey: "xyz",
      nodes: [
        {
          host: "localhost",
          port: "8108",
          path: "/",
          protocol: "http",
        },
      ],
    },
    flattenGroupedHits: false, // <=======
    additionalSearchParameters,
  });

Could you give it a shot and let me know how it goes?