When a voter is created and indexed, the searching the index should return the voter. This is how everything worked on the previous gem versions.
Attempted solution
I experimented and added refresh_interval: "1s" to our settings hash, and the expected behavior has resumed.
class Voter < ApplicationRecord
include Elasticsearch::Model
# ...
# All kinds of business code
# ..
settings index: {
refresh_interval: "1s",
analysis: {
# same as above
},
analyzer: {
# same as above
},
autocomplete: {
# same as above
},
autocomplete_search: {
# same as above
}
}
}
} do
mappings dynamic: false do
# Specify a bunch of indexes in here
end
end
end
This worked temporarily then stopped working. I've now had to add Voter.__elasticsearch__.refresh_index! for the updates in the index to appear.
We have other models that the indexes are updating, but they are not using the index: {} hash in the settings method at all. This seems to be the only outlying difference.
I ran into this situation after doing a ruby & rails upgrade (rails 6.0.x -> 6.1.x, ruby 2.7.x -> ruby 3.1.x)
We have a model setup similarly to this:
This was working before we did the upgrade. Here's the command and diff output to show the gem versions that changed:
Expected Behavior:
When a voter is created and indexed, the searching the index should return the voter. This is how everything worked on the previous gem versions.
Attempted solution
I experimented and added
refresh_interval: "1s"
to our settings hash, and the expected behavior has resumed.This worked temporarily then stopped working. I've now had to add
Voter.__elasticsearch__.refresh_index!
for the updates in the index to appear.We have other models that the indexes are updating, but they are not using the
index: {}
hash in thesettings
method at all. This seems to be the only outlying difference.