This message was deleted.
# community-help
s
This message was deleted.
j
Interesting use-case!
May be something like this could help to access the state of the widgets: https://www.algolia.com/doc/guides/building-search-ui/going-further/access-state-outside-lifecycle/js/ And send that state to the backend?
j
That's awesome. So accessing uiState will definitely give me both the state of things in <Configure/> and <RefinementsLists/>. Is there any way that some of the helper functions in https://github.com/typesense/typesense-instantsearch-adapter/blob/master/src/SearchRequestAdapter.js#L361 can be exposed as part of the searchadapter API? Would love to not have to rewrite these for the filters, and be more robust to potential changes
j
Sure, happy to convert the
_buildSearchParameters
to a public method, so you can use it by instantiating
SearchRequestAdapter
. Do you want to do a PR that renames that method to
transformSearchParameters
?
j
Sure 🙂
Wanted to get your take on the approach here - and I haven't fully dug around instantsearch to figure this out yet. The uiState provides the following data -> the index keying a dict with the different refinementLists/menus/configure "filter"/ranges.
Copy code
{
  "profiles": {
    "range": {
      "mixed_profile.years_of_experience": "3:4"
    },
    "refinementList": {
      "mixed_profile.skills": [
        "C++"
      ]
    },
    "menu": {
      "segments.id": "kpu9rfNB"
    },
    "configure": {
      "filters": "(mixed_profile.location: NY)"
    }
  }
}
It seems as though
_buildSearchParameters
(or
transformSearchParameters
) uses the
instantsearchRequest.params
to transform "algolia params" into "typesense params", so basically the parsing of the uiState into these params is already built into instantsearch. Wouldn't it be better for the instantsearchadapter to use the uiState directly instead of using algolias params to convert into the typesense params? Detaching from the double-conversion could allow for the implementation of features like multiple geo filters (which algolia only limits to one field). For my use case, exposing of the
transformSearchParameters
into a public method would be very useful, but I'd still have to dig around instantsearch to find where uiState is converted into the algolia params (or also possibly build that myself, which isnt a huge deal considering low # of filter types)
Either way, thanks for the help! Happy to help contribute to the repo/bettering the tool.
j
Ah hmm, I didn’t realize the uiState data structure was not the same as the `instantsearchRequest.params`…
Wouldn’t it be better for the instantsearchadapter to use the uiState directly instead of using algolias params to convert into the typesense params?
If it’s available sure, but I don’t think the uiState data structure is available within the searchClient context… Instead Algolia only sends the resolved search params.