# Is there a major difference in ES5 queries and ES6?

**URL:** <https://discuss.elastic.co/t/is-there-a-major-difference-in-es5-queries-and-es6/165498>\
**Category:** Elasticsearch\
**Created:** [January 23, 2019, 11:09pm UTC](https://discuss.elastic.co/t/is-there-a-major-difference-in-es5-queries-and-es6/165498 "2019-01-23T23:09:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pferrel](https://avatars.discourse-cdn.com/v4/letter/p/59ef9b/32.png) [@pferrel](https://discuss.elastic.co/u/pferrel)\
**Post date:** [January 23, 2019, 11:09pm UTC](https://discuss.elastic.co/t/is-there-a-major-difference-in-es5-queries-and-es6/165498/1 "2019-01-23T23:09:41Z")

</div>

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

```auto
{
  "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:

```auto
{
  "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.

---

<div class="post-metadata">

**Author:** ![pferrel](https://avatars.discourse-cdn.com/v4/letter/p/59ef9b/32.png) [@pferrel](https://discuss.elastic.co/u/pferrel)\
**Post date:** [January 24, 2019, 7:47pm UTC](https://discuss.elastic.co/t/is-there-a-major-difference-in-es5-queries-and-es6/165498/2 "2019-01-24T19:47:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![pferrel](https://avatars.discourse-cdn.com/v4/letter/p/59ef9b/32.png) [@pferrel](https://discuss.elastic.co/u/pferrel)\
**Post date:** [January 26, 2019, 1:29am UTC](https://discuss.elastic.co/t/is-there-a-major-difference-in-es5-queries-and-es6/165498/3 "2019-01-26T01:29:29Z")

</div>

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](https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-6.0.html#_changes_to_queries)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 23, 2019, 1:29am UTC](https://discuss.elastic.co/t/is-there-a-major-difference-in-es5-queries-and-es6/165498/4 "2019-02-23T01:29:30Z")

</div>

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