Issues with migrating search from Algolia to Typesense

TLDR Nacho encountered issues with migrating search from Algolia to Typesense, including a custom component that interfered with the search and an incorrect element being used as the title. Jason provided guidance on removing the component and adjusting search configuration.

Photo of Nacho
Nacho
Thu, 09 Feb 2023 21:47:19 UTC

just noticed this url goes nowhere, does anyone have the updated link?

Photo of Jason
Jason
Thu, 09 Feb 2023 21:48:13 UTC

Oops, it should be this:

Photo of Jason
Jason
Thu, 09 Feb 2023 21:48:16 UTC

Will fix that comment

Photo of Nacho
Nacho
Thu, 09 Feb 2023 21:48:37 UTC

awesome thanks, sent you a DM here in slack but I already found my way mostly

Photo of Nacho
Nacho
Thu, 09 Feb 2023 21:48:43 UTC

will ask here if any more questions arise

Photo of Nacho
Nacho
Thu, 09 Feb 2023 21:48:47 UTC

running the scraper now

Photo of Jason
Jason
Thu, 09 Feb 2023 21:49:15 UTC

I was just typing this out… We don’t have a migration guide for Docusaurus per se, because it’s just a “fresh new integration”, when you follow that step-by-step guide which you’re following

Photo of Nacho
Nacho
Thu, 09 Feb 2023 21:49:23 UTC

yep perfect

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:00:53 UTC

where do I access the features you showed of pinning and synonyms and such?

Photo of Jason
Jason
Thu, 09 Feb 2023 22:01:10 UTC

It’s under “Curation” on the left panel

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:01:43 UTC

oh right it was greyed out because I was still scrapping whoops

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:01:55 UTC

okay will take a look scrapping it’s getting there already

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:31:14 UTC

okay how do I now replace the algolia search with the typesense search? I feel like I did here but I might be missing something else?

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:31:18 UTC

sorry if it’s a noob question :smile:

Photo of Jason
Jason
Thu, 09 Feb 2023 22:33:24 UTC

Yup that should be it

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:40:25 UTC

well for some reason it wasn’t, I’m still seeing the algolia search on my preview url

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:40:42 UTC

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:40:54 UTC

but no results :smile:

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:41:04 UTC

which makes sense since I removed my algolia key and such

Photo of Jason
Jason
Thu, 09 Feb 2023 22:41:56 UTC

Is it showing up locally?

Photo of Jason
Jason
Thu, 09 Feb 2023 22:42:16 UTC

Another thing to try, is first turning off the Algolia search bar completely

Photo of Jason
Jason
Thu, 09 Feb 2023 22:42:29 UTC

Make sure that works as expected, without any errors

Photo of Jason
Jason
Thu, 09 Feb 2023 22:42:41 UTC

And then install the typesense theme

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:42:45 UTC

hmm

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:42:48 UTC

how do I do that?

Photo of Jason
Jason
Thu, 09 Feb 2023 22:43:56 UTC

Looks like just removing the `algolia` key from the docusaurus theme config might do it?

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:44:11 UTC

hmm seems like we have some config on top that might be it

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:47:03 UTC

seems like we had a custom component to show algolia that’s why it was showing

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:47:24 UTC

but after removing it, not sure how to get back to the default so typesense would show by default

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:47:30 UTC

(as you can see, I didn’t set this up initially)

Photo of Jason
Jason
Thu, 09 Feb 2023 22:47:50 UTC

Ok once you’ve removed it, does the search bar disappear locally?

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:47:57 UTC

yes

Photo of Jason
Jason
Thu, 09 Feb 2023 22:48:01 UTC

Ok cool

Photo of Jason
Jason
Thu, 09 Feb 2023 22:48:19 UTC

Now if you add the typesense specific config and theme, does it show up now?

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:48:39 UTC

didn’t remove it, do you want me uninstall the theme and add it again?

Photo of Jason
Jason
Thu, 09 Feb 2023 22:49:35 UTC

Did you restart the docusaurus dev server?

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:51:06 UTC

this was the culprit

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:51:07 UTC

yeah

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:51:13 UTC

I think the problem is that we’re rendering a custom navbar

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:51:26 UTC

so that might be out of scope for you

Photo of Jason
Jason
Thu, 09 Feb 2023 22:51:54 UTC

Yeah, and also out of my docusaurus knowledge :sweat_smile:

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:52:23 UTC

I’ll figure it out, will update :smile:

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:54:03 UTC

well now I have the search, just need to have the things I had in my navbar back

Photo of Jason
Jason
Thu, 09 Feb 2023 22:54:26 UTC

That was fast!

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:54:36 UTC

yeah just had to delete the component

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:54:59 UTC

basically because I had a SearchBar component, it was getting replaced

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:56:14 UTC

okaaay all fixed

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:56:20 UTC

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:56:36 UTC

now onto the fun stuff with personalization and setting the github action

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:56:44 UTC

my scrapper has been running for like 90 mins I feel like

Photo of Nacho
Nacho
Thu, 09 Feb 2023 22:56:51 UTC

oh just finished

Photo of Nacho
Nacho
Thu, 09 Feb 2023 23:33:23 UTC

any idea why some results instead of sending me to the page they sent me here?

Photo of Nacho
Nacho
Thu, 09 Feb 2023 23:33:31 UTC

(see url)

Photo of Jason
Jason
Thu, 09 Feb 2023 23:34:06 UTC

Could tell me the search term that generates those URLs?

Photo of Nacho
Nacho
Thu, 09 Feb 2023 23:45:33 UTC

“ui components”

Photo of Jason
Jason
Thu, 09 Feb 2023 23:49:36 UTC

The first two links in the search results essentially point to the home page, and that tile doesn’t have any anchor / link to point the user to

Photo of Nacho
Nacho
Thu, 09 Feb 2023 23:50:03 UTC

ohh so that’s what it’s getting linked to

Photo of Jason
Jason
Thu, 09 Feb 2023 23:50:08 UTC

yup

Photo of Jason
Jason
Thu, 09 Feb 2023 23:50:26 UTC

I’d recommend excluding the home page from search results

Photo of Nacho
Nacho
Thu, 09 Feb 2023 23:50:40 UTC

yeah, did with base config first to start

Photo of Nacho
Nacho
Thu, 09 Feb 2023 23:50:51 UTC

not sure why it doesn’t find this page

Photo of Nacho
Nacho
Thu, 09 Feb 2023 23:52:02 UTC

how do I exclude homepage?

Photo of Jason
Jason
Thu, 09 Feb 2023 23:52:19 UTC

Photo of Nacho
Nacho
Thu, 09 Feb 2023 23:52:19 UTC

the config file is incredibly cumbersome

Photo of Jason
Jason
Thu, 09 Feb 2023 23:52:32 UTC

You want to use `stop_urls`

Photo of Nacho
Nacho
Thu, 09 Feb 2023 23:53:00 UTC

so just `"stop_urls": [` `"/tests", "/"` `],`

Photo of Nacho
Nacho
Thu, 09 Feb 2023 23:53:01 UTC

?

Photo of Nacho
Nacho
Thu, 09 Feb 2023 23:53:05 UTC

add the “/”

Photo of Nacho
Nacho
Thu, 09 Feb 2023 23:53:22 UTC

oh no\

Photo of Nacho
Nacho
Thu, 09 Feb 2023 23:53:24 UTC

that wont work

Photo of Jason
Jason
Thu, 09 Feb 2023 23:53:56 UTC

Might have to use regex to make sure it only matches the home page

Photo of Jason
Jason
Thu, 09 Feb 2023 23:58:30 UTC

That’s because is set to `header h1`, but on that page there’s no dom element like that You want to change that to `article h1, header h1`

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:00:42 UTC

that was exactly what I was looking at

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:01:12 UTC

also, does this look correct to you?

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:01:21 UTC

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:01:28 UTC

in the hierarchy sense

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:01:37 UTC

what’s important is the “useContract() function”

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:01:40 UTC

and that’s hierarchy lvl2

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:02:02 UTC

(getting deep now in the config stuff)

Photo of Jason
Jason
Fri, 10 Feb 2023 00:02:42 UTC

In the Typesense Cloud dashboard, it by default searches only the first 3 fields. But in docsearch there’s a specific field priority order defined

Photo of Jason
Jason
Fri, 10 Feb 2023 00:03:10 UTC

So what you see in the actual docsearch UI will return results in that priority order, which will be different from what you see in the dashboard….

Photo of Jason
Jason
Fri, 10 Feb 2023 00:03:28 UTC

Unless of course you setup the dashboard to mimic those same settings used in docusaurus

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:06:52 UTC

not sure I follow

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:07:03 UTC

so my results in the cloud dashboard will differ to what I see in my site?

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:07:11 UTC

that’s what you’re saying right

Photo of Jason
Jason
Fri, 10 Feb 2023 00:08:04 UTC

correct

Photo of Jason
Jason
Fri, 10 Feb 2023 00:08:35 UTC

If you scroll to the bottom of the search page in the cloud dashboard, you’ll see the search settings used

Photo of Jason
Jason
Fri, 10 Feb 2023 00:09:05 UTC

Those are different from what the docusaurus-typesense plugin uses at runtime

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:09:31 UTC

right, and how do I sync them? I can do that with the preset thing you told me right?

Photo of Jason
Jason
Fri, 10 Feb 2023 00:09:39 UTC

Yup!

Photo of Jason
Jason
Fri, 10 Feb 2023 00:10:47 UTC

I would recommend starting out with the default config from the docsearch plugin. If you look at the network requests sent to Typesense in the browser’s dev console, you’ll see all the default values for all the search parameters

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:12:02 UTC

I feel like prioritizing lvl2 is what’s giving me best results

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:12:16 UTC

but that might be a problem with how stuff is set up in docusaurus?

Photo of Jason
Jason
Fri, 10 Feb 2023 00:12:32 UTC

You could try changing it and see what the impact is…

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:12:49 UTC

because pages like this

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:12:54 UTC

the title is an h2

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:12:57 UTC

when it should be an h1

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:13:06 UTC

sorry if I’m bothering you with my thoughts here

Photo of Jason
Jason
Fri, 10 Feb 2023 00:13:07 UTC

I’d recommend updating the markup if that’s an option

Photo of Jason
Jason
Fri, 10 Feb 2023 00:13:15 UTC

No worries!

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:13:39 UTC

hmm yeah that might be an option I need to check the autogeneration

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:14:25 UTC

okay let’s say I can’t do that (not sure yet)

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:14:41 UTC

if I say okay I want this

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:14:46 UTC

how do I set it up on docusaurus to be like this?

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:15:21 UTC

I create the preset

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:15:31 UTC

Photo of Jason
Jason
Fri, 10 Feb 2023 00:18:20 UTC

Then in this line, you’d add that preset name:

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:29:42 UTC

do you have an example? I don’t see preset on any of the examples

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:30:04 UTC

also, is this scoped to _everything_ or can I do only for certain url scopes like with the hieararchies?

Photo of Jason
Jason
Fri, 10 Feb 2023 00:32:34 UTC

This will be scoped to everything…

Photo of Jason
Jason
Fri, 10 Feb 2023 00:32:42 UTC

I don’t have an example unfortunately

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:54:47 UTC

do you think someone can get me one? :smile: not sure what the syntax is supposed to be

Photo of Jason
Jason
Fri, 10 Feb 2023 00:55:54 UTC

`typesenseSearchParameters: {"preset": "lvl2-priority"}`

Photo of Jason
Jason
Fri, 10 Feb 2023 00:56:08 UTC

In

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:56:16 UTC

okay nice awesome

Photo of Nacho
Nacho
Fri, 10 Feb 2023 00:56:16 UTC

thanks