[Vuejs]-Algolia Search and Nested Array

0👍

Yes, Algolia will automatically filter out Peter Pan and return items with Skating.

As an example I’ve got some data setup like so:

announcements: [
  {
     id: ..,
     ..
     author: {
       id: ..,
       name: 'Preston',
       ..
     }
  },
  ..
]

If I search Announcements for Preston it’ll return any announcement that has Preston in the author attribute. This is the default for Algolia and will search the entire record for your search term. This can be slow.

You can go into the Algolia dashboard, or with the API, and under your index’s Ranking tab define what you want to search by and ignore.

0👍

The first thing you need to do is adding events.title to the searchable attributes. This will make sure that when the end-user types skat, it will match one of the title.

Then you can check what parts of each result is matched using _highlightResult and more specifically filtering based on the matchLevel:

checking the matchLevel in _highlightResult

full is when you have a match and none is when you don’t.

This filtering should be possible in JS, in the template you use to display the results.

Leave a comment