-
Notifications
You must be signed in to change notification settings - Fork 369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Elasticsearch 7.0 Removal of mapping types #673
Comments
The following is an example of a workaround with compatibility parameters. As it is possible to respond by rewriting the URL, some people have adopted a method to solve using nginx. |
Just linking to my other comment |
Is there a plan to update Chewy to work with ES 7 or to use the workaround for now? |
Hello everyone. There is definitely a plan to update Chewy. Unfortunately, I can't tell when it is going to happen exactly. Hopefully, sooner than later. I'm sorry for it. |
Hi, is there at least a branch where we can coordinate this? I would like to contribute. |
# config/initializers/elastic_7.rb
# https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-7.0.html#hits-total-now-object-search-response
# https://www.elastic.co/blog/moving-from-types-to-typeless-apis-in-elasticsearch-7-0
# https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html#_schedule_for_removal_of_mapping_types
Elasticsearch::Transport::Client.prepend Module.new {
def search(arguments = {})
arguments[:rest_total_hits_as_int] = true
super arguments
end
}
Elasticsearch::API::Indices::IndicesClient.prepend Module.new {
def create(arguments = {})
arguments[:include_type_name] = true
super arguments
end
def put_mapping(arguments = {})
arguments[:include_type_name] = true
super arguments
end
} It works with Chewy 5.1.0 and ElasticSearch 7.7.0 or 6.8.1 |
Elasticsearch 6.8.x (pre 7.x) is EOL tomorrow, https://www.elastic.co/es/support/eol any plans to make chewy compatible? |
Disclaimer: This only works for multiple mappings on an Index that share the same properties.On my case I had indexes with multiple types but same attribute structure, so #673 (comment) and #712 didn't work for me by themselves. I had to go further to make sure that the Index Create statements would only send a single mapping to ES but keep separate type definitions on Chewy. This is very important as it allows Active Record imports for separate Tables/Models. Additionally, in order to allow the actual imports, Chewy::Type::Import was monkey patched as well to always send the first defined type as the mapping to ES. The overall structure looks something like this:
In addition to #673 (comment), this is the additional monkey patched we added on
This is definitely very hacky and prone to serious issues in the future, but waiting for official support on ES 7 is no longer an option so had to workaround it. Hope it helps someone. |
Please take a look at Chewy 7.0.0 release. Stay tuned for the 7.1 release, with dropped support for ES6.8 and removed deprecation warnings. |
Re: https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html
I'm unable to use chewy to create indexes in Elasticsearch 7.0. Chewy attempts to create indexes with mappings that looks like this:
ES7 has removed the "mapping type" level from the "mappings" field, so now expects documents that look like this:
For the 7.x series, the old way is still supported, but only my appending a
?include_type_name=true
query param to the create index URL.I tried a few ways to set it in the body, but that doesn't seem possible. It also doesn't seem possible for chewy to provide a query param when creating the index.
The text was updated successfully, but these errors were encountered: