Is there a major difference in ES5 queries and ES6?

I am making a recommender with Elasticsearch. I know what people have bought and this forms the query. The index is of items and has a field that contains items bought in common.

In previous versions of ES (<= 5.6) the two queries below resulted in different scores and therefor different rankings

Here is what I found in ES 6.5

{
  "query": {
    "bool": {
      "should": [
        {
          "terms": {
            "bought": [
              "iPad Pro"
            ]
          }
        }
      ]
    }
  }
}

returns items, all with score = 1.0. This might make sense because each of the items has "iPad Pro" in its "bought" field.

But the following query:

{
  "query": {
    "bool": {
      "should": [
        {
          "terms": {
            "bought": [
              "iPad Pro",
              "iPhone 8"
            ]
          }
        }
      ]
    }
  }
}

also returns exactly the same items with scores of 1.0. This is not what I expected and does not make sense to me (it is also not what 5.6 did) because some items have both "iPad Pro" and "iPhone 8" and some only have 1 of these.

I would expect that the items that have both would score higher than those that have only one. It is as if this query is acting like a filter, not scoring by similarity to the query.

What am I doing wrong?

Does anyone know if there is a new ES query form for doing this type of thing? Wow I can't believe they made this big a change -- baffling.

I see other people have run into this. IMO bad choice for a change by ES but, oh well.

Should we be switching to a "terms_set" query in ES 6+ to replace the old "terms"? Does anyone know if it has exactly that same semantics as "terms" in ES 5?

Ok, this is the new behavior of the "terms" query. Yikes. Does anyone know is there is a new way to get the same scoring as the 5.6 version of "terms" this page does not say: https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-6.0.html#_changes_to_queries

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