"Weighted" Disjunctive faceting


I’m wondering if there is a way to use disjunctive facets (OR) in a way that gives preference to results that have more matches. Here’s an example:

{ id: 1, colors: [“red”] }
{ id: 2, colors: [“red”, “blue”, “green”] }
{ id: 3, colors: [“red”, “blue”, “yellow”] }

{ facetFilters: [ “colors: red”, colors:“blue”, “colors:green”] }

Desired result:
ID 2 should be first since all 3 of the facets are a match.
ID 3 should be next since 2 out of the 3 facets are a match (red and blue).
ID 1 should be last since only 1 of the 3 facets match (red).

I can approximate this behavior by using multiple queries but it scales exponentially with the number of elements in the query. Is this type of “weighted” disjunctive faceting possible in one query?


I don’t see a way to do it with facets.

An alternative way to look at is to instead of doing filters you would do with a query.

Query would be: “red blue green”

and I would use:

Tell me if that makes sense.

Thanks for the suggestion, I think this behavior will get us close to the results we’re looking for.

1 Like