Custom Score Based on Matches in String Array


#1

We are trying to generate a document score based on the number of matches in an array of strings. For example, if there are 3 matched elements in the array, the score should increase by 3. Currently, we are using function_score query like so:

function_score: {
  ...
  functions: [{
    filter: {
      match: {
        expertises: "software hardware"
      }
    },
    weight: 1
  }]
}

The mapping for expertises property is like so:

expertises: {
  type: 'text',
  norms: {
    enabled: false
  },
  fields: {
    keyword: {
      type: 'keyword',
      ignore_above: 256
    }
  }
},

The issue is that this setup is giving a constant score no matter the amount of array items matched. Is it possible to compute a score based on number of items matched in the expertises array?


(system) #2

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