Full-text search

Hi Team,

We need to create a full text search on our website and group the results. For example if we find events we would group them in a tab called “events”.
What would be the best way to solve this with datoCMS?
Can graphql do a full-text search over all fields?

Thanks in advance for your reply

What I did is this:

  1. I have created my own search index of DatoCMS data in JSON file, by using DatoCMS API. The crawler script is added as “postbuild” command in the Next.js project, so Vercel will run this script at every build and generate the index file with the latest data.

  2. I am using fuzzysort javascript library. It is basically very lite full text search library, and very good too. The search is very fast and the results actually make sense. You can check their live demo here: https://rawgit.com/farzher/fuzzysort/master/test.html.

  3. I build similar UI as Algolia uses for their open source docsearch: https://docsearch.algolia.com.

I am very happy with the results. The only thing missing now for me is add multi-language support, but basically I already know how I will solve that. I will build one search index for every language and then filter the righ JSON based on the current locale.

Just for the information, my current JSON search index file for one language is about 25 kB. I expect to double this size per language as I will add a bit more content into the index. Currently am indexing the following data:

  • Product and product category pages (product name, description, tags)
  • Products tech specs pages (page title)
  • Solution and solution category pages (solution name, description, tags)
  • Landing pages (title, excerpt)
  • Downloads assets: PDF manuals, brochures, datasheets (file name, asset description
  • Training courses (course title, description)

It is probably not a perfect solution for every use case, but in my case search works very well and so far I am happy with it.

Here is a quick demo how it works in action… Of course not fully production ready yet, but you get the idea.

2 Likes

If i understand you right, you are using the site-search api. Am i correct? Or did you create a crawler of your entire Data?

I am not using site-search API. I made my own crawler like described in my original reply…