Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use different presets with single index/collection? #224

Open
dharmabumzee opened this issue Nov 22, 2024 · 3 comments
Open

How to use different presets with single index/collection? #224

dharmabumzee opened this issue Nov 22, 2024 · 3 comments

Comments

@dharmabumzee
Copy link

dharmabumzee commented Nov 22, 2024

Description

Hi 👋

I'm having some trouble figuring out how to use one index/collection and two presets. Multiple indices work great, and collectionSpecificSearchParameters is really handy for config override per collection, but I can't figure out how to map indexId to use different presets per Index widget.

Is this even possible?

Thanks for any help in advance 🤞

additionalSearchParameters: {
        preset,
        facet_by,
      },
collectionSpecificSearchParameters: {
        // This works
        [index]: {
          preset: 'Some preset',
        },
        // This doesn't, but is there a way to connect `indexId` with specific preset?
        "id-1": {
          preset: 'Preset for 1',
        },
        "id-2": {
          preset: 'Preset for 2',
        },
      },
     
<InstantSearch
      searchClient={client.searchClient}
      indexName={index}
      initialUiState={initialUiState}
      onStateChange={onStateChange}
    >
     <Index indexName={index} indexId="id-1">
       <Hits />
     </Index>
    
     <Index indexName={index} indexId="id-2">
       <Hits />
     </Index>
</InstantSearch>

Metadata

Typesense Version:

"react-instantsearch": "7.2.0"
"typesense-instantsearch-adapter": "2.7.1",
@dharmabumzee dharmabumzee changed the title Is is possible to use One index with multiple presets Nov 22, 2024
@dharmabumzee dharmabumzee changed the title One index with multiple presets How to use different presets with single index/collection? Nov 22, 2024
@jasonbosco
Copy link
Member

There's no way to link the indexId inside collectionSpecificSearchParameters, we only rely on the indexName.

@dharmabumzee
Copy link
Author

Thanks @jasonbosco! Is there any other way to use different presets on the same index with a single client?

@jasonbosco
Copy link
Member

The method you outlined here is the only way I'm aware of:

Screenshot 2024-11-25 at 2 17 44 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants