Skip to content
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

SNO-124-make-elasticsearch-shards-configurable #295

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions base.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ retry.attempts = 3
file_upload_bucket = snowflakes-files-dev
file_upload_profile_name = snowflakes-files-upload
elasticsearch.server = localhost:9201
elasticsearch.shards.primary = 1
elasticsearch.shards.replicate = 0
Comment on lines +8 to +9
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keenangraham @Bek I think we should start with adding the ability to configure the shards without actually changing it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With version 5, we don’t have the total shards limit and we can leave the default number as before. We should still change it to minimum for single machine demos, what do you think? I will look to it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it matters much on a single-node demo; they already index just as fast and they have a low search load. What difference do you think it would make?

aws_ip_ranges_path = %(here)s/aws-ip-ranges.json
download_proxy = https://download.encodeproject.org/
annotations_path = %(here)s/annotations.json
Expand Down
14 changes: 8 additions & 6 deletions src/snovault/elasticsearch/create_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ def schema_mapping(name, schema):
}


def index_settings():
def index_settings(primary_shards=3, replicate_shards=1):
return {
'settings': {
'index.max_result_window': 99999,
'index.mapping.total_fields.limit': 5000,
'index.number_of_shards': 5,
'index.number_of_replicas': 2,
'index.number_of_shards': primary_shards,
'index.number_of_replicas': replicate_shards,
'analysis': {
'filter': {
'substring': {
Expand Down Expand Up @@ -325,7 +325,7 @@ def es_mapping(mapping):
}
},
},
}
},
],
'properties': {
'uuid': {
Expand Down Expand Up @@ -487,6 +487,8 @@ def create_snovault_index_alias(es, indices):
def run(app, collections=None, dry_run=False):
index = app.registry.settings['snovault.elasticsearch.index']
registry = app.registry
primary_shards = registry.settings.get('elasticsearch.shards.primary', 3)
replicate_shards = registry.settings.get('elasticsearch.shards.replicate', 1)
if not dry_run:
es = app.registry[ELASTIC_SEARCH]
print('CREATE MAPPING RUNNING')
Expand All @@ -507,9 +509,9 @@ def run(app, collections=None, dry_run=False):
if mapping is None:
continue # Testing collections
if dry_run:
print(json.dumps(sorted_dict({index: {doc_type: mapping}}), indent=4))
print(json.dumps(sorted_dict({index: {collection_name: mapping}}), indent=4))
continue
create_elasticsearch_index(es, index, index_settings())
create_elasticsearch_index(es, index, index_settings(primary_shards, replicate_shards))
set_index_mapping(es, index, doc_type, {doc_type: mapping})
if collection_name != 'meta':
indices.append(index)
Expand Down