Skip to content

Is there a way to get currentRefinement inside CustomHits implemented via connectHits? #5170

Answered by Haroenv
garrrikkotua asked this question in Q&A
Discussion options

You must be logged in to vote

You can use transformItems for that:

instantsearch.widgets.hits({
          container,
          transformItems(items, metadata) {
            return [
              {
                objectID: '_query',
                __position: 0,
                // choose an attribute you would use in the template, here "name"
                name: metadata.results?.query,
                // also add this to highlight, so you can use the same template
                _highlightResult: {
                  name: {
                    value: metadata.results?.query!,
                    matchLevel: 'none',
                    matchedWords: [],
                  },
                },
              },

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@garrrikkotua
Comment options

@Haroenv
Comment options

Answer selected by Haroenv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
Library: InstantSearch.js Issues in instantsearch.js
2 participants