# Refresh after update

**URL:** https://discuss.elastic.co/t/refresh-after-update/154845
**Category:** Elasticsearch
**Created:** [October 31, 2018, 12:55pm UTC](https://discuss.elastic.co/t/refresh-after-update/154845 "2018-10-31T12:55:35Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![mdarfilal](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@mdarfilal](https://discuss.elastic.co/u/mdarfilal)
#### Post date: [October 31, 2018, 12:55pm UTC](https://discuss.elastic.co/t/refresh-after-update/154845/1 "2018-10-31T12:55:35Z")

</div>

I have some " **refresh**" problem with ElasticSearch **v6.2.1**.

Given an index " **my\_index**" and a type " **my\_type**", this is the scenario :

**Step 1** : Launch query that returns the 50 first documents where some fields (id, address, information) match with term parameter (e.g PARIS)

_The result_:

DOC1,  
DOC2,  
DOC3,  
DOC4,  
...  
DOC50

**Step 2** : Update DOC1 phoneNumber field with query (`/my_index/my_type/DOC1/_update`)

**Step 3** : Relaunch step 1 query.

_The result_:

DOC2,  
DOC3,  
DOC4,  
DOC5,  
...  
DOC1 (29th place),  
....  
DOC50

As we can see, my modified document is moved to the 29th place.  
My question is why my document does not take the same place, knowing that phoneNumber is not considered in my search. Since the DOC1 is the most pertinent result.

I tried to refresh the index (`/my_index/_refresh`), to launch the refresh after update with "`?refresh`" (even if it's by default), to set "`refresh_interval`" to 1 second.  
I tried to reduce `number_of_replicas` to `0` and `number_of_shards` to `1` with no result.

Any idea about this behavior, did I forget something?

The question is also asked in [stackoverflow](https://stackoverflow.com/questions/53066133/elasticsearch-refresh-after-update)

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [October 31, 2018, 1:34pm UTC](https://discuss.elastic.co/t/refresh-after-update/154845/2 "2018-10-31T13:34:51Z")

</div>

Are you using a sort parameter?

---

<div class="post-metadata">

### Author: ![mdarfilal](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@mdarfilal](https://discuss.elastic.co/u/mdarfilal)
#### Post date: [October 31, 2018, 1:39pm UTC](https://discuss.elastic.co/t/refresh-after-update/154845/3 "2018-10-31T13:39:10Z")

</div>

No sort parameter, below the query :

```
{
	"from": 0,
	"size": 50,
	"query": {
		"bool": {
			"should": [{
				"query_string": {
					"query": "*PARIS*",
					"fields": [
						"contact.address.*^1.2",
						"id^1.2",
						"information.*^1.2"
					],
					"type": "best_fields",
					"default_operator": "or",
					"max_determinized_states": 10000,
					"enable_position_increments": true,
					"fuzziness": "AUTO",
					"fuzzy_prefix_length": 0,
					"fuzzy_max_expansions": 50,
					"phrase_slop": 0,
					"analyze_wildcard": true,
					"escape": false,
					"auto_generate_synonyms_phrase_query": true,
					"fuzzy_transpositions": true,
					"boost": 1
				}
			}],
			"adjust_pure_negative": true,
			"boost": 1
		}
	},
	"_source": {
		"includes": [
			"id",
			"information.*",
			"geoPosition.*"
		],
		"excludes": []
	}
}
```

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [October 31, 2018, 3:55pm UTC](https://discuss.elastic.co/t/refresh-after-update/154845/4 "2018-10-31T15:55:10Z")

</div>

What are the `_score` of the documents? DOC2 and DOC1 in both cases?

---

<div class="post-metadata">

### Author: ![mdarfilal](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@mdarfilal](https://discuss.elastic.co/u/mdarfilal)
#### Post date: [November 2, 2018, 10:18am UTC](https://discuss.elastic.co/t/refresh-after-update/154845/5 "2018-11-02T10:18:47Z")

</div>

All docs have the same `_score` : `1.2` ☹  
That intrigues me too

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [November 2, 2018, 12:18pm UTC](https://discuss.elastic.co/t/refresh-after-update/154845/6 "2018-11-02T12:18:24Z")

</div>

As all scores are the same you can not rely on any specific position of one doc vs another.

---

<div class="post-metadata">

### Author: ![mdarfilal](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@mdarfilal](https://discuss.elastic.co/u/mdarfilal)
#### Post date: [November 2, 2018, 1:00pm UTC](https://discuss.elastic.co/t/refresh-after-update/154845/7 "2018-11-02T13:00:39Z")

</div>

I agree, so why at the first time, before the update the result is good and after the update it's going wrong ? Moreover, there is no reason to have the same score for all docs, anything wrong in the query ?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [November 2, 2018, 1:12pm UTC](https://discuss.elastic.co/t/refresh-after-update/154845/8 "2018-11-02T13:12:14Z")

</div>

I don't think it's good or bad.  
The score is just the same and because you are sorting by score, the result is correct.  
You can sort by another field if you wish.

---

<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: [November 30, 2018, 1:12pm UTC](https://discuss.elastic.co/t/refresh-after-update/154845/9 "2018-11-30T13:12:15Z")

</div>

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