Help|Odd behavior using search_after with score

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?

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"
      }
    }
  ]
}

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