I have a model User that I am indexing in ElasticSearch through Searchkick:
class User < ActiveRecord::Base
searchkick callbacks: :async, routing: true
end
Also I have a background job to reindex conditionally. The problem is that in some case I have repeated indexes for a single user:
2.3.8 :191 > u = User.find_by_email("john.doe@mail.com")
=> #<User id: 401953, email: "john.doe@mail.com", name: "John Doe", university_id: 83, device_id: "b3f3d62839ca6b981ea236562e6da9ff", app_version: "6.7.0>
But I am having repeated searchkick indexes with the same id and _index!
2.3.8 :192 > ap User.search("*", where: {email: "john.doe@mail.com"}, load: false).results
[
[0] {
"_index" => "users_production_20200717081323100",
"_type" => "user",
"_id" => "401953",
"_score" => 1.0,
"_routing" => "123",
"email" => "john.doe@mail.com",
app_version" => "6.6.0",
"id" => "401953"
},
[1] {
"_index" => "users_production_20200717081323100",
"_type" => "user",
"_id" => "401953",
"_score" => 1.0,
"_routing" => "123",
"email" => "john.doe@mail.com",
app_version" => "6.7.0",
"id" => "401953"
}
]
The only attribute that changes is the app_version. In some moment the user had "6.6.0" version and when update to 6.7.0 the index was repeated. In this case, why is happening this? is this the normal behavior of the gem?. Shouldn't it be updated and leave a single index?
Regards