How to add filters using Angular Instant Search v3

I am using Angular Instant Search to provide a search directory of other users on the platform. I would like to ensure that the currently logged in user isn’t returned in the results (among other things).

How can I have this filter applied with each user’s search?

I’ve attempted to apply this with:

       filters: 'NOT'

The url field contains the unique identifier for each user.

Hi there!

Indeed, going for filters is the right approach.

So for example, imagine your records look like the following:

    "name": "John Smith",
    "email_address": ""
    "name": "Matt Appleseed",
    "email_address": ""

Here, you would want to filter out based on email_address. The first step would be to set the email_address as an attribute for faceting, so you can filter on it. You can find out more about this here.

Once this is done, you can filter on email_address. Filters work the same whether you’re using our Angular InstantSearch library, or any other library or API client.

In your Angular InstantSearch configure widget, you can set it up as you did, using the filters search parameter:

  [searchParameters]="{ filters: `NOT email_address:${emailAddressOfCurrentUser}` }"

Does this help?


1 Like

It all makes sense now! Thank you, I knew I was missing something

1 Like