Ordering per subcategory

Hello. I need a light to see how we can do this using algolia.

Our system has categories and subcategories.
One product can have 1 category, and up to 3 subcategories.

A requirement was made per product, per category, and/or subcategory to set a score with the following behavior:

  • If I search by a subcategory, I should pin to the top the products that contain that score (ordered by it).
  • If I search by 2 or more subcategories, I should pin to the top the products that have that score.

Now the border case:

  • If a product has a score in one subcategory, but it doesn’t have in another (remember I have up to 3 sub cats), and I search by that other, I need to NOT pin that product to the top.

Is there a configuration that could help me with this?, technically I would need something that behaves as an “AND” instead of OR?

Thanks in advance!

HI @louise1, I’m not sure I understand your use case. When you say ‘search by a subcategory’ do you mean search in the search bar or select a facet?

Could you give some example queries and example categories with more information about what you are trying to achieve with the scoring - where the scores will be located, etc.

In our system there are filtering and search of course.

When I say “search by subcategory”, I mean filtering. There are at least 100 subcategories, in sum of all categories. Each product can have up to 3

The problem that we have right now is that: if we do have product 1 in category A, B and C, and the product only has score in A and B, I don’t see a clear way how to NOT show it in C.

Hi Louise,

To be fully transparent, I haven’t fully understood your use case either, so what I say might not be applicable or might miss the mark.

There is an operator attribute on the RefinementList widgets that allows you to define whether the selected filters of that attribute should be an AND or an OR. Maybe this is what you are looking for.

Here’s a link to the documentation about this operator attribute: refinementList | InstantSearch.js | API parameters | API Reference | Algolia Documentation

Hopefully this helps you move forward!