README.md in elasticsearch-model-6.1.2 vs README.md in elasticsearch-model-7.0.0.pre
- old
+ new
@@ -17,11 +17,10 @@
| Rubygem | | Elasticsearch |
|:-------------:|:-:| :-----------: |
| 0.1 | → | 1.x |
| 2.x | → | 2.x |
| 5.x | → | 5.x |
-| 6.x | → | 6.x |
| master | → | master |
## Installation
Install the package from [Rubygems](https://rubygems.org):
@@ -493,11 +492,15 @@
after_commit on: [:create] do
__elasticsearch__.index_document if self.published?
end
after_commit on: [:update] do
- __elasticsearch__.update_document if self.published?
+ if self.published?
+ __elasticsearch__.update_document
+ else
+ __elasticsearch__.delete_document
+ end
end
after_commit on: [:destroy] do
__elasticsearch__.delete_document if self.published?
end
@@ -535,11 +538,15 @@
case operation.to_s
when /index/
record = Article.find(record_id)
Client.index index: 'articles', type: 'article', id: record.id, body: record.__elasticsearch__.as_indexed_json
when /delete/
- Client.delete index: 'articles', type: 'article', id: record_id
+ begin
+ Client.delete index: 'articles', type: 'article', id: record_id
+ rescue Elasticsearch::Transport::Transport::Errors::NotFound
+ logger.debug "Article not found, ID: #{record_id}"
+ end
else raise ArgumentError, "Unknown operation '#{operation}'"
end
end
end
```
@@ -723,13 +730,18 @@
### Settings
The module provides a common `settings` method to customize various features.
-Before version 7.0.0 of the gem, the only supported setting was `:inheritance_enabled`. This setting has been deprecated
-and removed.
+At the moment, the only supported setting is `:inheritance_enabled`, which makes the class receiving the module
+respect index names and document types of a super-class, eg. in case you're using "single table inheritance" (STI)
+in Rails:
+```ruby
+Elasticsearch::Model.settings[:inheritance_enabled] = true
+```
+
## Development and Community
For local development, clone the repository and run `bundle install`. See `rake -T` for a list of
available Rake tasks for running tests, generating documentation, starting a testing cluster, etc.
@@ -741,20 +753,9 @@
```bash
curl -# https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.0.0.RC1.tar.gz | tar xz -C tmp/
SERVER=start TEST_CLUSTER_COMMAND=$PWD/tmp/elasticsearch-1.0.0.RC1/bin/elasticsearch bundle exec rake test:all
```
-
-### Single Table Inheritance deprecation
-
-`Single Table Inheritance` has been supported through the 6.x series of this gem. With this feature,
-elasticsearch settings (index mappings, etc) on a parent model could be inherited by a child model leading to different
-model documents being indexed into the same Elasticsearch index. This feature depended on the ability to set a `type`
-for a document in Elasticsearch. The Elasticsearch team has deprecated support for `types`, as is described
-[here.](https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html)
-This gem will also remove support for types and `Single Table Inheritance` in version 7.0 as it enables an anti-pattern.
-Please save different model documents in separate indices. If you want to use STI, you can include an artificial
-`type` field manually in each document and use it in other operations.
## License
This software is licensed under the Apache 2 license, quoted below.