typesense / typesense-instantsearch-adapter

A JS adapter library to build rich search interfaces with Typesense and InstantSearch.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

groups are getting flattened in a group_by query

majestiq opened this issue · comments

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.

@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?