Decrease score when field has additional values

Hey, is it possible to decrease a score when a field has more values than is being matched for?

const documents = [
  {
    id: 1,
    tags: ['a', 'b'],
  },
  {
    id: 2,
    tags: ['a'],
  },
];

const query = {
  bool: {
    should: [
      {
        term: {
          tag: 'a',
        },
      },
    ],
  },
};

Given the data above, when I run a query like this, I receive both results (expected) however they have identical scores.

I would like for the document which has id: 2 to have a higher score because it matches more precisely than the document with id: 1. Is this possible?

Thanks,
Matt

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.