# Help|Odd behavior using search\_after with score

**URL:** <https://discuss.elastic.co/t/help-odd-behavior-using-search-after-with-score/173816>\
**Category:** Elasticsearch\
**Created:** [March 25, 2019, 6:51pm UTC](https://discuss.elastic.co/t/help-odd-behavior-using-search-after-with-score/173816 "2019-03-25T18:51:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simon\_Poissant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simon_poissant/32/42740_2.png) [@Simon\_Poissant](https://discuss.elastic.co/u/Simon_Poissant)\
**Post date:** [March 25, 2019, 6:51pm UTC](https://discuss.elastic.co/t/help-odd-behavior-using-search-after-with-score/173816/1 "2019-03-25T18:51:52Z")

</div>

Hi everyone,

I'm trying to use `search_after` with the following sorting params:

```
"sort": [{
			"_score": {
				"order": "desc"
			}
		},
		{
			"_id": {
				"order": "asc"
			}
		}],

```

I've noticed that sometimes I will do a query using the previous results for the `search_after` params and it will return **the same results BUT with different scores**.

**Is it possible that the scores are affected by the search\_after param and that this approach is thus not viable?**

Or maybe I'm just missing something?

---

<div class="post-metadata">

**Author:** ![Simon\_Poissant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simon_poissant/32/42740_2.png) [@Simon\_Poissant](https://discuss.elastic.co/u/Simon_Poissant)\
**Post date:** [March 25, 2019, 7:29pm UTC](https://discuss.elastic.co/t/help-odd-behavior-using-search-after-with-score/173816/2 "2019-03-25T19:29:10Z")

</div>

It gets even weirder... I've noticed that invoking the exact same query multiple times in a row will return alternating results (i.e. the first time I get results ABC to XYZ, the second time results 123 to 890, the third time it's back to ABC to XYZ, etc.)

```
{
  "size": 20,
  "query": {
    "bool": {
      "must": [
        {
          "simple_query_string": {
            "query": "\"test query\"",
            "fields": [
              "content.plain^1.0",
              "breadcrumb.titles^1.0",
              "content.html^1.0"
            ],
            "flags": -1,
            "default_operator": "or",
            "analyze_wildcard": false,
            "auto_generate_synonyms_phrase_query": true,
            "fuzzy_prefix_length": 0,
            "fuzzy_max_expansions": 50,
            "fuzzy_transpositions": true,
            "boost": 1
          }
        }
      ],
      "filter": [
        {
          "bool": {
            "must": [
              {
                "term": {
                  "owner.client": {
                    "value": "ACME",
                    "boost": 1
                  }
                }
              },
              {
                "term": {
                  "owner.env": {
                    "value": "test",
                    "boost": 1
                  }
                }
              },
              {
                "exists": {
                  "field": "content.plain",
                  "boost": 1
                }
              },
              {
                "bool": {
                  "should": [
                    {
                      "term": {
                        "segmentType": {
                          "value": "PARAGRAPH",
                          "boost": 1
                        }
                      }
                    },
                    {
                      "term": {
                        "segmentType": {
                          "value": "SLIDE",
                          "boost": 1
                        }
                      }
                    },
                    {
                      "term": {
                        "segmentType": {
                          "value": "TABLE",
                          "boost": 1
                        }
                      }
                    }
                  ],
                  "adjust_pure_negative": true,
                  "minimum_should_match": "1",
                  "boost": 1
                }
              }
            ],
            "adjust_pure_negative": true,
            "boost": 1
          }
        }
      ],
      "adjust_pure_negative": true,
      "boost": 1
    }
  },
  "search_after":[
      13.438397,
      "VNocfBovWzCmCBWU6BOlzw"
  ],
  "sort": [
    {
      "_score": {
        "order": "desc"
      }
    },
    {
      "_id": {
        "order": "asc"
      }
    }
  ]
}
```

---

<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:** [April 22, 2019, 7:35pm UTC](https://discuss.elastic.co/t/help-odd-behavior-using-search-after-with-score/173816/3 "2019-04-22T19:35:41Z")

</div>

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