Is there a way to get currentRefinement inside CustomHits implemented via connectHits? #5170
Answered
by
Haroenv
garrrikkotua
asked this question in
Q&A
-
My problem is that I want to show current search query as one of the hits (in some situations). It is possible to do with CustomHits? If not, that other methods I can use? Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
Haroenv
Nov 24, 2022
Replies: 1 comment 2 replies
-
You can use 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: [],
},
},
},
...items,
];
},
}) |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
Haroenv
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use
transformItems
for that: