I'm trying to translate this mapping for an Item
model using the tire
gem to its equivalent with the elasticsearch-rails
gem:
tire do
mapping(
_parent: { type: 'player' },
_routing: { required: true, path: :user }
) do
indexes :user, type: "string", index: :not_analyzed
end
My mapping in elasticsearch-rails
is:
mapping(_parent: {type: 'player', require: 'true', _routing: {path: 'user', required: 'true'}}) do
indexes :user, type: "string", index: not_analyzed
end
This seems okay until I try to import some players:
transform_function = lambda do |item|
{
index: {
_id: item.id,
_parent: item.player_id,
_routing: item.user_id,
data: item.__elasticsearch__.as_indexed_json
}
}
Item.__elasticsearch__.import \
index: 'my_index',
batch_size: 100,
transform: transform_function
I get an error when I try to import stuff:
Elasticsearch::Transport::Transport::Errors::BadRequest: [400]
{
"error" : "MapperParsingException[The provided routing value [1] doesn't match the routing key stored in the document: [null]]",
"status":400
}
I don't know what that error means and I can't seem to find an applicable explanation online. Other people who experienced this error seem to be doing something different...
I think this is just an issue with how I'm declaring the mapping in elasticsearch-rails
. Unfortunately, there isn't that much documentation around how this should look... Anyone have ideas?
Aucun commentaire:
Enregistrer un commentaire