Match and term in bool's should

I'd like to search items that either have firstField (mapped as text) similar to a query string or secondField (mapped as an integer) equal to, say, 1.

After reading the docs, I understand the OR I am trying to implement can be done with a should clause inside a bool like so:

{
  "query": {
    "bool": {
      "should": [
        {"match": {"firstField":  "queryString"}},
        {"term":  {"secondField": 1}}
      ]
    }
  }
}

The results however show that secondField contributes far less (approximately 4 times) to the result than firstField does since their scoring algorithms are different. firstField effectively eclipses secondField, even though I want them to weigh the same on the final score.

My question is twofold:

  • is it even recommended to have a match inside a should (or any other bool sub-clause) since the result is non-boolean?
  • how can I make two clauses of different natures (in this case match and term) weigh the same on the final score (have the same scoring span)?

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