Refresh after update


(Mohammed Darfilal) #1

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


(David Pilato) #2

Are you using a sort parameter?


(Mohammed Darfilal) #3

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

(David Pilato) #4

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


(Mohammed Darfilal) #5

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


(David Pilato) #6

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


(Mohammed Darfilal) #7

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 ?


(David Pilato) #8

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.


(system) #9

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