Search partial matches

Hi!

Would it be possible to implement a wildcard/prefix search in Dato Site Search?

fuzzySearch is kind of giving partial search matches, but only if the search input differs by a few characters.

As far as I know, ElasticSearch is supporting wildcards or similar behavior via “search_as_you_type”, in case Dato Site Search is using ElasticSearch under the hood.

Thanks!

Welcome to the forum, @fabrice, and sorry this isn’t currently supported! We do use Elastisearch, but we don’t have the mappings configured for type-ahead yet. I’ve noted it as a feature request to be considered in the future.

In the meantime, you can either run your own search engine on it (like Algolia or Typesense), or use the CDA as a workaround, e.g.:

query Autocomplete($term: String!) {
  allArticles(
    first: 10
    filter: {
      OR: [
        { title: { matches: { pattern: $term, regexp: false } } }
        { body: { matches: { pattern: $term, regexp: false } } }
      ]
    }
  ) {
    id
    title
    slug
  }
}

But this searches your Dato records, not your frontend, so you’d have to handle the linkification from slug to frontend URL. You’d also have to debounce the input (every character is an API call).

Otherwise, let’s keep this feature request open and I’ll report back here if we ever implement it properly on our side!

Sorry @fabrice,

The developers evaluated this and decided it’s not something we want to add right now :frowning:

Our site search is purposefully left pretty barebones, only good enough for the simplest use cases.

For more powerful features, they recommend using a third-party search provider like Algolia or Typesense instead. Sorry about that!

Ok, thanks for checking :slight_smile: