Skip to content

Commit a0c9c1b

Browse files
Change module name from Elasticsearch to OpenSearch
1 parent 5163442 commit a0c9c1b

File tree

131 files changed

+509
-509
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+509
-509
lines changed

CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
* Add newlines at the end of files that are missing it
5656
* Port adapter tests to rspec (#834)
5757
* Ensure that specified ActiveRecord order is not overwritten by Elasticsearch search results order (#835)
58-
* Port remainder of Elasticsearch::Model unit tests to rspec (#836)
58+
* Port remainder of OpenSearch::Model unit tests to rspec (#836)
5959
* Port all integration tests to rspec (#837)
6060
* Avoid executing search twice; Reuse response in Response#raw_response (#850)
6161
* Update example to account for deprecation of _suggest endpoint in favor of _search
@@ -136,7 +136,7 @@
136136
* Undo last commit; depend on version 5 of elasticsearch gems
137137
* Reduce repeated string instantiation (#813)
138138
* Make default doc type '_doc' in preparation for deprecation of mapping types (#816)
139-
* Remove Elasticsearch::Persistence::Model (ActiveRecord persistence pattern) (#812)
139+
* Remove OpenSearch::Persistence::Model (ActiveRecord persistence pattern) (#812)
140140
* Deprecate _all field in ES 6.x (#820)
141141
* Remove development dependency on virtus, include explicitly in Gemfile for integration test
142142
* Refactor Repository as mixin (#824)
@@ -166,8 +166,8 @@
166166
* Fixed a problem where `Hashie::Mash#min` and `#max` returned unexpected values
167167
* Added information about `elasticsearch-dsl` to the README
168168
* Added support for inherited index names and doc types
169-
* Added a `Elasticsearch::Model.settings` method
170-
* Changed the naming inheritance logic to use `Elasticsearch::Model.settings`
169+
* Added a `OpenSearch::Model.settings` method
170+
* Changed the naming inheritance logic to use `OpenSearch::Model.settings`
171171
* Added information about the `settings` method and the `inheritance_enabled` setting into the README
172172
* Disable "verbose" and "warnings" in integration tests
173173
* Added code for establishing ActiveRecord connections to test classes

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ Example of a basic integration into an ActiveRecord-based model:
7373
require 'opensearch/model'
7474

7575
class Article < ActiveRecord::Base
76-
include Elasticsearch::Model
77-
include Elasticsearch::Model::Callbacks
76+
include OpenSearch::Model
77+
include OpenSearch::Model::Callbacks
7878
end
7979

8080
# Index creation right at import time is not encouraged.
@@ -114,7 +114,7 @@ class Article
114114
end
115115

116116
require 'opensearch/persistence'
117-
repository = Elasticsearch::Persistence::Repository.new
117+
repository = OpenSearch::Persistence::Repository.new
118118

119119
repository.save Article.new(title: 'Test')
120120
# POST http://localhost:9200/repository/article

opensearch-model/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Added a `suggest` method to wrap the suggestions in response
44
* Added the `:includes` option to Adapter::ActiveRecord::Records for eagerly loading associated models
55
* Delegated `max_pages` method properly for Kaminari's `next_page`
6-
* Fixed `#dup` behaviour for Elasticsearch::Model
6+
* Fixed `#dup` behaviour for OpenSearch::Model
77
* Fixed typos in the README and examples
88

99
## 0.1.8
@@ -61,7 +61,7 @@
6161
* Properly delegate existence methods like `result.foo?` to `result._source.foo`
6262
* Exception is raised when `type` is not passed to Mappings#new
6363
* Allow passing an ActiveRecord scope to the `import` method
64-
* Added, that `each_with_hit` and `map_with_hit` in `Elasticsearch::Model::Response::Records` call `to_a`
64+
* Added, that `each_with_hit` and `map_with_hit` in `OpenSearch::Model::Response::Records` call `to_a`
6565
* Added support for [`will_paginate`](https://github.com/mislav/will_paginate) pagination library
6666
* Added the ability to transform models during indexing
6767
* Added explicit `type` and `id` methods to Response::Result, aliasing `_type` and `_id`

opensearch-model/README.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Elasticsearch::Model
1+
# OpenSearch::Model
22

33
The `opensearch-model` library builds on top of the the [`elasticsearch`](https://github.com/elastic/elasticsearch-ruby) library.
44

@@ -61,15 +61,15 @@ and include the main module in your class:
6161
require 'opensearch/model'
6262

6363
class Article < ActiveRecord::Base
64-
include Elasticsearch::Model
64+
include OpenSearch::Model
6565
end
6666
```
6767

6868
This will extend the model with functionality related to Elasticsearch.
6969

7070
#### Feature Extraction Pattern
7171

72-
Instead of including the `Elasticsearch::Model` module directly in your model, you can include it in a "concern" or "trait" module, which is quite common pattern in Rails applications, using e.g. `ActiveSupport::Concern` as the instrumentation:
72+
Instead of including the `OpenSearch::Model` module directly in your model, you can include it in a "concern" or "trait" module, which is quite common pattern in Rails applications, using e.g. `ActiveSupport::Concern` as the instrumentation:
7373

7474
```ruby
7575
# In: app/models/concerns/searchable.rb
@@ -78,7 +78,7 @@ module Searchable
7878
extend ActiveSupport::Concern
7979

8080
included do
81-
include Elasticsearch::Model
81+
include OpenSearch::Model
8282

8383
mapping do
8484
# ...
@@ -99,10 +99,10 @@ end
9999

100100
#### The `__elasticsearch__` Proxy
101101

102-
The `Elasticsearch::Model` module contains a big amount of class and instance methods to provide
102+
The `OpenSearch::Model` module contains a big amount of class and instance methods to provide
103103
all its functionality. To prevent polluting your model namespace, this functionality is primarily
104104
available via the `__elasticsearch__` class and instance level proxy methods;
105-
see the `Elasticsearch::Model::Proxy` class documentation for technical information.
105+
see the `OpenSearch::Model::Proxy` class documentation for technical information.
106106

107107
The module will include important methods, such as `search`, into the class or module only
108108
when they haven't been defined already. Following two calls are thus functionally equivalent:
@@ -112,7 +112,7 @@ Article.__elasticsearch__.search 'fox'
112112
Article.search 'fox'
113113
```
114114

115-
See the `Elasticsearch::Model` module documentation for technical information.
115+
See the `OpenSearch::Model` module documentation for technical information.
116116

117117
### The Elasticsearch client
118118

@@ -133,7 +133,7 @@ Article.__elasticsearch__.client = OpenSearch::Client.new host: 'api.server.org'
133133
Or configure the client for all models:
134134

135135
```ruby
136-
Elasticsearch::Model.client = OpenSearch::Client.new log: true
136+
OpenSearch::Model.client = OpenSearch::Client.new log: true
137137
```
138138

139139
You might want to do this during your application bootstrap process, e.g. in a Rails initializer.
@@ -194,7 +194,7 @@ response.results.map { |r| r._source.title }
194194
# => ["Quick brown fox", "Fast black dogs"]
195195

196196
response.results.select { |r| r.title =~ /^Q/ }
197-
# => [#<Elasticsearch::Model::Response::Result:0x007 ... "_source"=>{"title"=>"Quick brown fox"}}>]
197+
# => [#<OpenSearch::Model::Response::Result:0x007 ... "_source"=>{"title"=>"Quick brown fox"}}>]
198198
```
199199

200200
In fact, the `response` object will delegate `Enumerable` methods to `results`:
@@ -265,19 +265,19 @@ response.records.each_with_hit { |record, hit| puts "* #{record.title}: #{hit._s
265265
It is possible to search across multiple models with the module method:
266266

267267
```ruby
268-
Elasticsearch::Model.search('fox', [Article, Comment]).results.to_a.map(&:to_hash)
268+
OpenSearch::Model.search('fox', [Article, Comment]).results.to_a.map(&:to_hash)
269269
# => [
270270
# {"_index"=>"articles", "_type"=>"article", "_id"=>"1", "_score"=>0.35136628, "_source"=>...},
271271
# {"_index"=>"comments", "_type"=>"comment", "_id"=>"1", "_score"=>0.35136628, "_source"=>...}
272272
# ]
273273

274-
Elasticsearch::Model.search('fox', [Article, Comment]).records.to_a
274+
OpenSearch::Model.search('fox', [Article, Comment]).records.to_a
275275
# Article Load (0.3ms) SELECT "articles".* FROM "articles" WHERE "articles"."id" IN (1)
276276
# Comment Load (0.2ms) SELECT "comments".* FROM "comments" WHERE "comments"."id" IN (1,5)
277277
# => [#<Article id: 1, title: "Quick brown fox">, #<Comment id: 1, body: "Fox News">, ...]
278278
```
279279

280-
By default, all models which include the `Elasticsearch::Model` module are searched.
280+
By default, all models which include the `OpenSearch::Model` module are searched.
281281

282282
NOTE: It is _not_ possible to chain other methods on top of the `records` object, since it
283283
is a heterogenous collection, with models potentially backed by different databases.
@@ -308,7 +308,7 @@ To initialize and include the Kaminari pagination support manually:
308308

309309
```ruby
310310
Kaminari::Hooks.init if defined?(Kaminari::Hooks)
311-
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
311+
OpenSearch::Model::Response::Response.__send__ :include, OpenSearch::Model::Response::Pagination::Kaminari
312312
```
313313

314314
#### The Elasticsearch DSL
@@ -348,7 +348,7 @@ Also, you can use the [**`elasticsearch-dsl`**](https://github.com/elastic/elast
348348
```ruby
349349
require 'opensearch/dsl'
350350

351-
query = Elasticsearch::DSL::Search.search do
351+
query = OpenSearch::DSL::Search.search do
352352
query do
353353
match :title do
354354
query 'fox dogs'
@@ -364,7 +364,7 @@ response.results.first.title
364364
### Index Configuration
365365

366366
For proper search engine function, it's often necessary to configure the index properly.
367-
The `Elasticsearch::Model` integration provides class methods to set up index settings and mappings.
367+
The `OpenSearch::Model` integration provides class methods to set up index settings and mappings.
368368

369369
**NOTE**: Elasticsearch will automatically create an index when a document is indexed,
370370
with default settings and mappings. Create the index in advance with the `create_index!`
@@ -436,12 +436,12 @@ Article.first.__elasticsearch__.index_document
436436
#### Automatic Callbacks
437437

438438
You can automatically update the index whenever the record changes, by including
439-
the `Elasticsearch::Model::Callbacks` module in your model:
439+
the `OpenSearch::Model::Callbacks` module in your model:
440440

441441
```ruby
442442
class Article
443-
include Elasticsearch::Model
444-
include Elasticsearch::Model::Callbacks
443+
include OpenSearch::Model
444+
include OpenSearch::Model::Callbacks
445445
end
446446

447447
Article.first.update_attribute :title, 'Updated!'
@@ -454,7 +454,7 @@ The automatic callback on record update keeps track of changes in your model
454454
(via [`ActiveModel::Dirty`](http://api.rubyonrails.org/classes/ActiveModel/Dirty.html)-compliant implementation),
455455
and performs a _partial update_ when this support is available.
456456

457-
The automatic callbacks are implemented in database adapters coming with `Elasticsearch::Model`. You can easily
457+
The automatic callbacks are implemented in database adapters coming with `OpenSearch::Model`. You can easily
458458
implement your own adapter: please see the relevant chapter below.
459459

460460
#### Custom Callbacks
@@ -464,7 +464,7 @@ by hooking into `after_create`, `after_save`, `after_update` or `after_destroy`
464464

465465
```ruby
466466
class Article
467-
include Elasticsearch::Model
467+
include OpenSearch::Model
468468

469469
after_save { logger.debug ["Updating document... ", index_document ].join }
470470
after_destroy { logger.debug ["Deleting document... ", delete_document].join }
@@ -476,7 +476,7 @@ your data against inconsistencies caused by transaction rollbacks:
476476

477477
```ruby
478478
class Article < ActiveRecord::Base
479-
include Elasticsearch::Model
479+
include OpenSearch::Model
480480

481481
after_commit on: [:create] do
482482
__elasticsearch__.index_document if self.published?
@@ -504,7 +504,7 @@ with a tool like [_Resque_](https://github.com/resque/resque) or [_Sidekiq_](htt
504504

505505
```ruby
506506
class Article
507-
include Elasticsearch::Model
507+
include OpenSearch::Model
508508

509509
after_save { Indexer.perform_async(:index, self.id) }
510510
after_destroy { Indexer.perform_async(:delete, self.id) }
@@ -560,7 +560,7 @@ Indexer JID-eb7e2daf389a1e5e83697128 INFO: done: 0.006 sec
560560
### Model Serialization
561561

562562
By default, the model instance will be serialized to JSON using the `as_indexed_json` method,
563-
which is defined automatically by the `Elasticsearch::Model::Serializing` module:
563+
which is defined automatically by the `OpenSearch::Model::Serializing` module:
564564

565565
```ruby
566566
Article.first.__elasticsearch__.as_indexed_json
@@ -572,7 +572,7 @@ for instance with the [`as_json`](http://api.rubyonrails.org/classes/ActiveModel
572572

573573
```ruby
574574
class Article
575-
include Elasticsearch::Model
575+
include OpenSearch::Model
576576

577577
def as_indexed_json(options={})
578578
as_json(only: 'title')
@@ -619,7 +619,7 @@ _ActiveRecord_ callbacks -- please see the full example in `examples/activerecor
619619

620620
### Other ActiveModel Frameworks
621621

622-
The `Elasticsearch::Model` module is fully compatible with any ActiveModel-compatible model, such as _Mongoid_:
622+
The `OpenSearch::Model` module is fully compatible with any ActiveModel-compatible model, such as _Mongoid_:
623623

624624
```ruby
625625
require 'mongoid'
@@ -634,7 +634,7 @@ class Article
634634

635635
attr_accessible :id, :title, :published_at
636636

637-
include Elasticsearch::Model
637+
include OpenSearch::Model
638638

639639
def as_indexed_json(options={})
640640
as_json(except: [:id, :_id])
@@ -655,7 +655,7 @@ Full examples for CouchBase, DataMapper, Mongoid, Ohm and Riak models can be fou
655655
### Adapters
656656

657657
To support various "OxM" (object-relational- or object-document-mapper) implementations and frameworks,
658-
the `Elasticsearch::Model` integration supports an "adapter" concept.
658+
the `OpenSearch::Model` integration supports an "adapter" concept.
659659

660660
An adapter provides implementations for common behaviour, such as fetching records from the database,
661661
hooking into model callbacks for automatic index updates, or efficient bulk loading from the database.
@@ -680,20 +680,20 @@ end
680680

681681
# Register the adapter
682682
#
683-
Elasticsearch::Model::Adapter.register(
683+
OpenSearch::Model::Adapter.register(
684684
DataMapperAdapter,
685685
lambda { |klass| defined?(::DataMapper::Resource) and klass.ancestors.include?(::DataMapper::Resource) }
686686
)
687687
```
688688

689-
Require the adapter and include `Elasticsearch::Model` in the class:
689+
Require the adapter and include `OpenSearch::Model` in the class:
690690

691691
```ruby
692692
require 'datamapper_adapter'
693693

694694
class Article
695695
include DataMapper::Resource
696-
include Elasticsearch::Model
696+
include OpenSearch::Model
697697

698698
property :id, Serial
699699
property :title, String
@@ -714,7 +714,7 @@ response.records.records.class
714714
# => DataMapper::Collection
715715
```
716716

717-
More examples can be found in the `examples` folder. Please see the `Elasticsearch::Model::Adapter`
717+
More examples can be found in the `examples` folder. Please see the `OpenSearch::Model::Adapter`
718718
module and its submodules for technical information.
719719

720720
### Settings

opensearch-model/examples/activerecord_article.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ class Article < ActiveRecord::Base
7070

7171
# Extend the model with Elasticsearch support
7272
#
73-
Article.__send__ :include, Elasticsearch::Model
74-
# Article.__send__ :include, Elasticsearch::Model::Callbacks
73+
Article.__send__ :include, OpenSearch::Model
74+
# Article.__send__ :include, OpenSearch::Model::Callbacks
7575

7676
# ActiveRecord::Base.logger.silence do
7777
# 10_000.times do |i|
@@ -81,7 +81,7 @@ class Article < ActiveRecord::Base
8181

8282
puts '', '-'*Pry::Terminal.width!
8383

84-
Elasticsearch::Model.client = OpenSearch::Client.new log: true
84+
OpenSearch::Model.client = OpenSearch::Client.new log: true
8585

8686
response = Article.search 'foo';
8787

0 commit comments

Comments
 (0)