-
Notifications
You must be signed in to change notification settings - Fork 1
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
[EPIC] Redesign application architecture #7
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ace to interract with es
…ple alternative to speed up tests
…n the index/repo class
and such definition is useless. It is also error prone using index architecture splitted in multiple files since the `Index` method always return a new class. Example: file: app/indices/my_index.rb class MyIndex < Esse::Index(:v1) file: app/indices/collections/my_collection.rb class MyIndex < Esse::Index(:v1) # This is going to generate a new class obj module Collections class MyCollection
…tent with other interfaces
marcosgz
added a commit
that referenced
this pull request
Aug 23, 2024
marcosgz
added a commit
that referenced
this pull request
Aug 23, 2024
* during import, use the doc directly should reduce amount of allocated objects * feat: start updating bulk to work with std hash as default * reduce memory usage by creating raw hash instead of coercing them to doc/header doc * keep bulk order * minor refactoring * fix: do not compare document source, they may have attributes dinamically generated * feat: do not create new array when values are already a doc instances * feat: simplify data structure * chore: rename lazy_attributes to eager_load_lazy_attributes * feat: refactoring by reusing each_serialized_batch * feat: update rexml close #7
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[EPIC] Redesign application architecture
The current application architecture is not very well suited for the current elasticsearch and opensearch versions. The project was initially built with the idea of indexing types that are not supported anymore. But it is still necessary to have indexes composed of many data types, or better, many several data sources. So the new architecture we are introducing the context of Repository as a replacement of Type.
Another big change is the separation of the concerns of the index business logic from the lower level elasticsearch client. We are introducting a new layer called
Esse::Transport
as a proxy to the elasticsearch client. This layer will be responsible for the communication with the elasticsearch client and will be the only one to know about the elasticsearch client. TheEsse::Transport
will be responsible for the index management, index creation, index deletion, index aliases, index settings, index mappings, index documents, etc. And such methods are no longer isolated in theEsse::Index.elasticsearch
interface, but they are now available in theEsse::Index
interface.There are many changes in this PR to be described in a single PR description. I'll try to describe the most important ones and in future add more documentation to the project.
Esse::Index.elasticsearch methods
Below is a list of methods that were removed from the
Esse::Index.elasticsearch
interface and are now available in theEsse::Index
interface. Old methods are now deprecated and will be removed in the next major version.Note that
Esse::Index.backed
is an alias toEsse::Index.elasticsearch
. So if you are usingEsse::Index.backed
you will need to change accordingly.Esse::Index.elasticsearch.aliases
is nowEsse::Index.aliases
Esse::Index.elasticsearch.indices
is nowEsse::Index.indices_pointing_to_alias
Esse::Index.elasticsearch.update_aliases!
is nowEsse::Index.update_aliases
Esse::Index.elasticsearch.update_aliases
is nowEsse::Index.update_aliases
Esse::Index.elasticsearch.create_index
is nowEsse::Index.create_index
Esse::Index.elasticsearch.create_index!
is nowEsse::Index.create_index
Esse::Index.elasticsearch.close!
is nowEsse::Index.close
Esse::Index.elasticsearch.close
is nowEsse::Index.close
Esse::Index.elasticsearch.open!
is nowEsse::Index.open
Esse::Index.elasticsearch.open
is nowEsse::Index.open
Esse::Index.elasticsearch.refresh
is nowEsse::Index.refresh
Esse::Index.elasticsearch.refresh!
is nowEsse::Index.refresh
Esse::Index.elasticsearch.delete_index
is nowEsse::Index.delete_index
Esse::Index.elasticsearch.delete_index!
is nowEsse::Index.delete_index
Esse::Index.elasticsearch.create_index
is nowEsse::Index.create_index
Esse::Index.elasticsearch.create_index!
is nowEsse::Index.create_index
Esse::Index.elasticsearch.update_mapping
is nowEsse::Index.update_mapping
Esse::Index.elasticsearch.update_mapping!
is nowEsse::Index.update_mapping
Esse::Index.elasticsearch.update_settings
is nowEsse::Index.update_settings
Esse::Index.elasticsearch.update_settings!
is nowEsse::Index.update_settings
Esse::Index.elasticsearch.reset_index!
is nowEsse::Index.reset_index
Esse::Index.elasticsearch.import!
is nowEsse::Index.import
Esse::Index.elasticsearch.import
is nowEsse::Index.import
Esse::Index.elasticsearch.bulk!
is nowEsse::Index.bulk
Esse::Index.elasticsearch.bulk
is nowEsse::Index.bulk
Esse::Index.elasticsearch.index!
is nowEsse::Index.index
Esse::Index.elasticsearch.index
is nowEsse::Index.index
Esse::Index.elasticsearch.update!
is nowEsse::Index.update
Esse::Index.elasticsearch.update
is nowEsse::Index.update
Esse::Index.elasticsearch.delete!
is nowEsse::Index.delete
Esse::Index.elasticsearch.delete
is nowEsse::Index.delete
Esse::Index.elasticsearch.count
is nowEsse::Index.count
Esse::Index.elasticsearch.exist?
is nowEsse::Index.exist?
Esse::Index.elasticsearch.find!
is nowEsse::Index.get
Esse::Index.elasticsearch.find
is nowEsse::Index.get
Esse::IndexType.elasticsearch methods
The rename of
Esse::IndexType
toEsse::Repository
is already in the master branch done in the commit b7a63812. But I'm mentioning here because here is where we are actually dropping the concept of type and introducing the concept of repository.Below is a list of methods that were removed from the
Esse::IndexType.elasticsearch
interface. Most of them are now available in theEsse::Index
interface since the concept of type was changed to repository. Old methods are now deprecated and will be removed in the next major version.Note the
Esse::IndexType.backed
is an alias toEsse::IndexType.elasticsearch
. So if you are usingEsse::IndexType.backed
you will need to change accordingly.Esse::IndexType.elasticsearch.import!
is nowEsse::Repository.import
Esse::IndexType.elasticsearch.import
is nowEsse::Repository.import
Esse::IndexType.elasticsearch.bulk!
is nowEsse::Index.bulk
Esse::IndexType.elasticsearch.bulk
is nowEsse::Index.bulk
Esse::IndexType.elasticsearch.index!
is nowEsse::Index.index
Esse::IndexType.elasticsearch.index
is nowEsse::Index.index
Esse::IndexType.elasticsearch.index_document
is nowEsse::Index.index
Esse::IndexType.elasticsearch.update!
is nowEsse::Index.update
Esse::IndexType.elasticsearch.update
is nowEsse::Index.update
Esse::IndexType.elasticsearch.delete!
is nowEsse::Index.delete
Esse::IndexType.elasticsearch.delete
is nowEsse::Index.delete
Esse::IndexType.elasticsearch.delete_document
is nowEsse::Index.delete
Esse::IndexType.elasticsearch.count
is nowEsse::Index.count
Esse::IndexType.elasticsearch.exist?
is nowEsse::Index.exist?
Esse::IndexType.elasticsearch.find!
is nowEsse::Index.get
Esse::IndexType.elasticsearch.find
is nowEsse::Index.get
Referer to the Esse::Repository instead of Esse::IndexType if for some reason you are using the master branch instead of the published gem.
Esse::Serializer -> Esse::Document
The
Esse::Serializer
is nowEsse::Document
. TheEsse::Serializer
was a bad name for the class that is responsible for the serialization of the data to be indexed. TheEsse::Document
is a better name for the purpose of the class that is formatting the data to be indexed.We are continue to support Hash objects as a valid document. They will be automatically converted to Esse::HashDocument objects. But I recommend to inherit from
Esse::Document
instead of using Hash objects.The document has also routing support. You can define the routing in the document class:
Or add
_routing
value in case of Hash document:Event system
New events were added to the pub/sub system. The events are:
The events are triggered in the
Esse::Transport
layer.Esse::Cluster
Cluster now has a new method
#readonly=
to set the cluster in read-only mode. This is useful when you want to prevent the cluster from indexing data. This is useful when you want to perform a maintenance in the cluster and you want to prevent the cluster from indexing data while the maintenance is being performed.Esse::Index definition
The core of this project is the
Esse::Index
class. TheEsse::Index
class is responsible for the index definition like index name, index settings, index mappings, index aliases, repository, document format, etc. TheEsse::index
class is the interface to perform any operation in the elasticseach index.The next sections will describe the most important changes in the
Esse::Index
class.index_version -> index_prefix
The attribute
self.index_version=
was renamed toself.index_prefix=
. Prefix is a better name for the attribute that is used to compose the index name. The index name is composed by the prefix and the version. The version is a timestamp that is automatically generated by theEsse::Index
class.define_type -> repository
The
define_type
method was renamed torepository
. Therepository
method is responsible for defining the repository class. Repository should contain thecollection
anddocument
definitions. Thecollection
is responsible for streaming the data to be indexed. Thedocument
is responsible for formatting the data to be indexed. They are not allowed to be defined in theEsse::Index
class anymore.serializer -> document
The
serializer
method was renamed todocument
. Thedocument
method is responsible for defining the document class. The document class is responsible for formatting the data to be indexed.