-
Notifications
You must be signed in to change notification settings - Fork 196
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
ESConfig: configurable Elasticsearch document types to allow splitting index #1296
Draft
haarg
wants to merge
18
commits into
master
Choose a base branch
from
haarg/esconfig
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+707
−815
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
Centralize Elasticsearch configuration in MetaCPAN::ESConfig. Allow overridden values from the main config file. This module is not meant to have any behavior aside from holding the configuration.
ESConfig knows how to find mapping data. Use it to find the mapping data as well as index configuration. The mapping data should be able to be moved into json files rather than json wrapped in a module. This can happen in the future.
The analysis set in MetaCPAN::Model wasn't used for anything directly, generate the index deployment statements. The index settings we actually use lives in MetaCPAN::Script::Mapping::DeployStatement, so the declarations in MetaCPAN::Model were used for nothing.
Rather than searching for modules on disk, use the explicit configuration in ESConfig to configure MetaCPAN::Model.
PPI and thus Perl::Critic don't understand signatures, so the rule ends up prohibiting signatures as well
haarg
changed the title
ESConfig: configurable Elasticsearch document types
ESConfig: configurable Elasticsearch document types to allow splitting index
Oct 23, 2024
Allows getting a "type" object from a document name rather than needing to specify an index and type.
Previously when trying to refresh indices, scripts would call $self->index->refresh. This would refresh the "currently used" index. That doesn't make any sense when splitting each type into its own index. This was also using ElasticSearchX::Model, which we want to get rid of. Instead, call ->indices->refresh via the Search::Elasticsearch object. This will refresh all indices, which is fine for our purposes. In the future, we could consider being more selective about which indices we are refreshing, but this is no worse than the old behavior.
Rather than using the same index to find other types, find them via the model. This means the types don't need to be in the same index.
haarg
force-pushed
the
haarg/esconfig
branch
3 times, most recently
from
October 23, 2024 10:49
82860b2
to
0456203
Compare
Many parts of the code treated the index as the parent of all data, so it was the thing being passed around. That will no be true in the future. Instead, ESConfig can give the path (index+type) of each named document type. Convert most places passing around index to use es_doc_path.
Replaces the CPAN and User model classes. Removes magic namespace creation. Just returns the model object. Everything is trivially accessible from there.
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.
This adds a central module to configure all of the document types stored in Elasticsearch, allowing a config file to override values. It then adapts the rest of the code to use this module.
In the past, everything stored in Elasticsearch was stored in one index, with multiple types. Initially this was the
cpan
index, but later this was changed to usingcpan_v1_01
withcpan
being an alias. The idea was that we could have different versions of the index on the same server, and copy or switch between them. The index used would be passed around the code, acting as a single configurable value that would impact all document types. Some newer document types have been stored in separate indexes, but not all parts of the codebase accommodate this well.Going forward, we want every document type to be in a separate index. Initially this will be one type per index. Eventually, types will go away entirely. This is required to upgrade Elasticsearch. To facilitate this, this PR adds a new module
MetaCPAN::ESConfig
which lists all of the document types and which index and type they are using. These values can be overridden in the config file, meaning we can switch to a different Elasticsearch instance where the documents are stored in different places just by deploying a new config file.Everything that was previously holding a ElasticSearchX::Model index instance has been updated to instead use the ElasticSearchX::Model instance directly. The new
$model->doc($doc_type)
method is a replacement for$index->type($type)
, allowing accessing types that are in different indexes.Everything that was previously using a copied index name with a fixed type (often like
$es->search(index => $self->index->name, 'file')
) is now using the newes_doc_path
sub (like$es->search(es_doc_path('file'))
). This seemed the easiest way to integrate this throughout the codebase.There is a new
Catalyst::Model
namedESModel
. This replaces both theCPAN
andUser
models. It allows access to MetaCPAN::Model, and thus everything using ElasticSearchX::Model. TheCPAN
vsUser
split was related to the index their data was stored in, and is thus no longer relevant. The new model has less magic as well.Fixes #1297