Robust Search

Hello! Has anyone implemented any kind of “smarter search” in Strapi? Generally speaking, one that finds posts/products using terms that don’t necessarily match exactly what’s in the content.

The perfect world would be a semantic search with AI that can even read the thumbnails attached to the post (I recently saw a search like this using Gemini that could even interpret videos, it was amazing!)

This topic has been created from a Discord post (1268583491231289394) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

Using Algolia with the Algolia plugin would be a good place to start: Algolia | Strapi Market

I used Typesense: https://typesense.org/

I am struggling to send data to Algolia. Even when setting it to populate only the ID field, I always get a record size error.

Cool! I’ll check it out! Did you integrate it with Strapi? Have you tried the semantic search?

Got a stacktrace? Got any really large entries?

I’m assuming there isn’t a Strapi plugin for typesense? Did you build a custom integration using lifecycle hooks to keep data in typesense up to date?

I used it on my client as on-site search. Semantic search works great.

Populating only the ID field shouldn’t create a large entry, haha. The limit for the free plan is 10kb, but my entry with only the ID set up is 30kb.

Nice! Is it possible to send the site so I can check it out?
Did you integrate it using only their docs? Any tips I should know before starting?

Yea true. What’s your plugin config? Maybe it’s still sending the whole entry for some reason. I’m not at my computer but I actually forked that plugin so I could filter which entries are sent so there could totally be a bug that I’m not experiencing.

Here it is:

    enabled: true,
    config: {
      apiKey: process.env.ALGOLIA_ADMIN_KEY,
      applicationId: process.env.ALGOLIA_APP_ID,
      contentTypes: [
        { name: 'api::product.product',
          populate: {
            id: true
          }
         },
      ],
    },
  },```

I also tried using "hideFields" to hide most of the fields

I’ll be back at my computer in an hr - I’ll take a look at mine then

Sorry it was an internal project so it is not avaliable for public.

This is also a good start:

I did it a bit differently because I was working with Docker, so I also run typesense in a container.
And some packages for react are also replaced with new ones so you need to be careful (example: react-instasearch-dom).

No, I did not find it. Yes I used lifecycle hooks to trigger my indexer script.

Ahhh I’m sorry Andre I linked the wrong algolia plugin! My bad.

I use a forked version of https://mattie-bundle.mattiebelt.com/ but the published version of that plugin should work well for you.

Here’s an Strapi blog about it: Add Search to a Strapi & Next.js project with Algolia

The quick start (Quick Start Guides - Mattie Bundle for Strapi - docs) is also a great place to…get started :sweat_smile:

Your config would look like this:

  search: {
    enabled: true,
    config: {
      provider: 'algolia',
      providerOptions: {
        apiKey: env('ALGOLIA_PROVIDER_ADMIN_API_KEY'),
        applicationId: env('ALGOLIA_PROVIDER_APPLICATION_ID'),
      },
      contentTypes: [{ name: 'api::product.product', fields: ['id'] }],
    },
  },

And then add whatever other fields you want to the fields array.

Thanks a lot for you help! I’ll check!

I’ll check! Thanks a lot!

Apparently, this project is really outdated… The last commit was 2 years ago, and the recommended Node version is 12 to 14. :confused:

Yeaaaa that’s why I forked it and made my own changes: GitHub - busbyk/mattie-strapi-bundle: Mattie plugin bundle for Strapi

It’s somewhere way down on my todo list to submit a PR but for a few reasons I haven’t since it won’t be trivial to do so: 1. I made many changes in my main branch so those changes really should be broken out into multiple PRs 2. I didn’t write any tests - there’s not much testing in that repo in general but I introduced a concept of filters which I’d probably want to at least write some basic tests for to make it easier to accept 3. I’d want to add to the docs

And lastly: the maintainer is basically MIA - hasn’t responded to any issues or PRs. Might be worth reaching out to him directly since he has his email on his profile.

But feel free to use my forked version if you’re interested. I used gitpkg to install via github:

    "@mattie-bundle/strapi-plugin-search": "https://gitpkg.vercel.app/api/pkg.tgz?url=busbyk%2Fmattie-strapi-bundle%2Fpackages%2Fsearch%2Fstrapi-plugin-search&commit=ffd7174ae47c02a91c8dda33a9bbc5f210f593fa",
    "@mattie-bundle/strapi-provider-search-algolia": "https://gitpkg.vercel.app/api/pkg.tgz?url=busbyk%2Fmattie-strapi-bundle%2Fpackages%2Fsearch%2Fstrapi-provider-search-algolia&commit=ffd7174ae47c02a91c8dda33a9bbc5f210f593fa",