question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multi Index Search in SSR version of InstantSearch within Nuxt.

See original GitHub issue

Feature ⚡️

What is your use case for such a feature?

Be able to use Multi Index Search in SSR version of InstantSearch 2 within Nuxt. It’s a missing feature since 2.0 according to this https://github.com/algolia/vue-instantsearch/issues/348#issuecomment-338928514

What is your proposal

Hi, My proposal is use multi index with InstantSearchSsr, changing the injection $_ais to $_ais-indexname. The problem is that InstantSearchSrr component doesn’t allow to set the injection name dynamically since props are not accessible inside inject, so it always inject the same index using $_ais.

The only solution I found was create the InstantSearchSrr component manually.

To avoid problems, I recommend add a new param (multiIndex) to instantSearchOptions in the file createInstantSearch:

const { searchClient, indexName, multiIndex } = instantSearchOptions;

Then edit the rootMixin to change $_ais name based in the index name, if multiIndex is set to true. That way it’s only needed to create the custom component if enabled:

const rootMixin = {
    provide() {
      const name = multiIndex ? `$_ais-${indexName}` : '$_ais';
      return {
        // should be possible to configure this with {camelcase: ['error', {allow: ['^\\$_']}]}
        // but that didn't work
        // eslint-disable-next-line camelcase
        [name]: search,
      };
    },
  };

And export the function createInstantSearchComponent. So users area able to create their own InstantSearchSsr components:

export {
  createInstantSearchComponent,
} from './util/createInstantSearchComponent';

I know it’s not so practical as before, but works.

I made an example in CodeSandbox based on yours: https://codesandbox.io/s/zwvxqokz3l You can also check my fork: https://github.com/JoaoPedroAS51/vue-instantsearch/

Thanks!

What is the version you are using?

2.0.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
JoaoPedroAS51commented, Apr 1, 2019

I think when we merge this it should also be mentioned in the guide on ssr

Yes, this would be really useful.

I’m happy to help. I really love Algolia!

1reaction
nothaldircommented, Feb 10, 2021

@Haroenv I’m arriving a bit late, but is it possible to perform multi index search with SSR in nuxt with Vue InstantSearch 3 ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - Multi Index Search in SSR version of InstantSearch ...
Hi, My proposal is use multi index with InstantSearchSsr, changing the injection $_ais to $_ais-indexname . The problem is that InstantSearchSrr component doesn ......
Read more >
Server-side rendering with Vue InstantSearch - Algolia
On the server: Make a request to Algolia to get search results; Render the Vue app with the results of the request; Store...
Read more >
How To Implement Search Functionality In Your Nuxt App ...
We'll build a Nuxt site with Nuxt Content with a search feature using Algolia InstantSearch, for styling, we'll use TailwindCSS. This tutorial ...
Read more >
Integrate Algolia InstantSearch into a Vue Project
Algolia offers a super powerful and flexible search with ready to use ... Configure nuxt-content-algolia to send index to Algolia during ...
Read more >
react-instantsearch | Yarn - Package Manager
0 vulnerabilities. ⚡ Lightning-fast search for React and React Native apps, by Algolia ... This is the React version of Algolia's instantsearch library....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found