Do I have to add a Facet to filter?

I have some tags. That tags have name attributes.

When a user is creating a Post, they can pick some tags. After they’ve already picked a tag, it should not show up in the list of potential tags.

I set up some filters.

const filters = "NOT name:finance AND NOT name:test"
// in the actual code, this string is dynamic. It is regenerated with every tag selected.

// and then the React component
<Configure
    filters={searchFilter}
/>

In the Index, when I have Attributes for faceting set to name, the filter above works.
But when I delete it, it doesn’t work.

I don’t actually need to “Facet” the name in the tags at all. And it seems wasteful.

There will only be one tag named “test”.

As far as I understand, facets would be useful to organize a set of data around some attribute (e.g. facet all shoes by brand Nike).

Here is a shot from the index with some bunk tag names:
image

There will only ever be (1) tag for each facet. I could use the filterOnly attribute to disable the counts, but…

Is there a better way (least wasteful) way to do this???

Hi there!
If you intend to filter on a particular attribute, it will need to be listed as an attribute for faceting. As you’ve already found filterOnly is a way of making this more performant if you don’t need the counts.

One alternative depending on your use case is to make use of the _tags attribute and use tagFilters. _tags does not need to be declared as an attribute for faceting and tagFilters don’t allow for some of the advanced filtering options of the regular filters parameter. For example _tags Tags can only be contained in a top-level _tags attribute.

Hope this helps!

1 Like

Thank you! That makes sense.

1 Like

Since every tag name is unique, and I’m filtering on tag name — so every facet (even though I’m using filterOnly) will have only one match, will that degrade performance?

Would it be better to just return all the tags and filter on the client?

Hi @george, good question! Faceting does have an impact on performance, which is why we limit facet values to 1000 per facet.
We do this because the main cost associated with facets is computing the facet counts. As you can see in your screenshot, for each facet value we count how many records have this value and return these counts in the response.

However, using filterOnly disables the counting of facets and only prepares them for filtering: it’s the most efficient way to use facets, and will likely be always more performant than filtering on the client :slight_smile:

Let me know if this helps or if you have further questions!

Happy building,

1 Like