Filter scoring with wildcards

I have records with two properties containing arrays. I would like to assign a greater weight to matches within one of the properties using filter scoring (something like property:*<score=2>). Is this possible?

Example of the kind of functionality I’m looking for:

Document (describes a vendor):

{
  "fruits": [
    "banana",
    "apple",
    "lemon"
  ],
  "ripeness": [
    "very ripe",
    "unripe"
  ]
}

In this case, I would want to assign double the weight of ripeness to fruit (don’t read too closely into that example doc, doesn’t make much sense :joy:). So, if both “banana” and “unripe” matched a search, “unripe” would add a score of 1 and “banana” would add a score of 2, for a total of 3. I could easily do this by just writing our filter scoring for every possible parameter, but I’d rather not (in the event that they change, which is likely).

Hello there!

The goal of using filter scoring is to give more weight for a match of a specific value for a given attribute. Therefore, there’s no reason to score for all value matches, because that would only reproduce Algolia’s ranking algorithm (with performance extra overhead).

Could you tell me a bit more about your use case, and what you’re trying to achieve with scoring?

Best,

Hi Sarah!

Apologies for the slow response here, was expecting an email. I’m trying to use algolia’s indexing engine to quickly generate relevance scores for records. Specifically, I am trying to measure the number of overlapping fields between my search query and the records in my index, and some properties I care about more than others. I can explain further via a private channel if that’s helpful, but can’t go into more depth here :grimacing:.

Thanks in advance!

Hi,

I understand you’d like to promote any valu of a given attribute but not the values of another attribute.

There is currently no wildcard syntax for values, because most of the time you will want to promote a specific value, not all the values.

Maybe what you could do is create a new attribute that would be an array of facet names you’d like to promote and add those to all records at indexing time.

You could then optionally filter on those instead.

{
  "fruits": [
    "banana",
    "apple",
    "lemon"
  ],
  "ripeness": [
    "very ripe",
    "unripe"
  ],
  "attributes": [
    "fruits",
    "ripeness"
  ]
}

You could then have a score on attributes:fruits.

I hope that makes sense.