react-instantsearch icon indicating copy to clipboard operation
react-instantsearch copied to clipboard

How to find all tags in an index? Then get count of each tags?

Open Steffi3rd opened this issue 6 years ago • 9 comments

Hello,

I have around 1000 tags (or more) in my index.

1 / I would like to display all theses tags.

2 / And once I have all these tags, I would like to show a count with the number of items with this tags.

3 / Order by DESC the tags by the most used tags

Is there a way to that please?

Steffi3rd avatar Oct 28 '19 11:10 Steffi3rd

Hey @Steffi3rd, this is not going to be possible, there's a limit on how many tags you can show, as well as the number of hits in a regular result. You can read more about that here:

  • https://www.algolia.com/doc/api-reference/api-parameters/maxValuesPerFacet/

If you choose to go for hits instead of facets, you can take a look at:

  • https://www.algolia.com/doc/api-reference/api-parameters/paginationLimitedTo
  • combined with: https://www.algolia.com/doc/api-reference/api-parameters/hitsPerPage/

Hope that helps you!

Haroenv avatar Oct 28 '19 12:10 Haroenv

@Haroenv Hello ! okay, thanks for your solutions.

So what can I do if I want to find the 10 most used tags?

Steffi3rd avatar Oct 28 '19 12:10 Steffi3rd

What do you mean with "most used"? If you mean "with the most results", then that's the default behaviour, but you can also see sortFacetValuesBy: count

Haroenv avatar Oct 28 '19 12:10 Haroenv

I mean something like this :

I have an index named "Items" like in Algolia. item 1 { tags: ["X", "Y"] } item 2 { tags: ["Y"] } item 3 { tags: ["Y"] } item 4 { tags: ["Y"] } item 5 { tags: [] } item 6 { tags: ["X"] } item 7 { tags: ["Y", "X"] } item 8 { tags: ["Z", "Y"] }

Then I would like to find which tags is the most used. In this example, we see that "Y" is the most used tag, then it's "X", and finally "Z"

So the results I would like to have is :

  • "Y" (6)
  • "X" (3)
  • "Z" (1)

Steffi3rd avatar Oct 28 '19 12:10 Steffi3rd

like this? https://www.algolia.com/doc/api-reference/widgets/refinement-list/react/

Haroenv avatar Oct 28 '19 12:10 Haroenv

When using multiple refinement lists (for example with country and city facets), the items returned by the country change to a single country if a city is selected. Is it possible to have a refinementList always display all items regardless of the current filters?

everdrone avatar Apr 12 '22 21:04 everdrone

Only what can be filtered further is displayed, to avoid people seeing zero results often @everdrone

Haroenv avatar Apr 19 '22 11:04 Haroenv

Only what can be filtered further is displayed, to avoid people seeing zero results often @everdrone

This means that from the country <select> menu, all other countries are going to disappear if a city is selected, making it harder for the user to switch. Since the user needs to first deselect the city, then pick a new country and then filter by city again. Isn't there a way to get around this? @Haroenv

everdrone avatar Apr 19 '22 11:04 everdrone

I can't think of an easy way for this. If you only allow a single refinement per level, you can use HierarchicalMenu @everdrone

Haroenv avatar Apr 19 '22 16:04 Haroenv

@everdrone Does @Haroenv's suggestion work for you?

sarahdayan avatar Dec 19 '22 15:12 sarahdayan

Yes, eventually I went for the single refinement as suggested

everdrone avatar Dec 19 '22 15:12 everdrone