def test_cloned_index_has_copied_settings_and_using(): client = object() i = Index('my-index', using=client) i.settings(number_of_shards=1) i2 = i.clone('my-other-index') assert 'my-other-index' == i2._name assert client is i2._using assert i._settings == i2._settings assert i._settings is not i2._settings
def test_cloned_index_has_analysis_attribute(): """ Regression test for Issue #582 in which `Index.clone()` was not copying over the `_analysis` attribute. """ client = object() i = Index('my-index', using=client) random_analyzer_name = ''.join((choice(string.ascii_letters) for _ in range(100))) random_analyzer = analyzer(random_analyzer_name, tokenizer="standard", filter="standard") i.analyzer(random_analyzer) i2 = i.clone('my-clone-index') assert i.to_dict()['settings']['analysis'] == i2.to_dict()['settings']['analysis']
'mapping': { 'type': 'keyword', 'normaliser': basic_normalizer } } } analysis = {'normalizer': basic_normalizer} default_mapping = Mapping() default_mapping.meta('dynamic_templates', **dynamic_template) public_sources = Index('public_sources') public_sources.mapping(default_mapping) public_sources.settings(analysis=analysis) full_sources = public_sources.clone('full_sources') @public_sources.document class PublicSourceBase(Document): join_field = JoinField(public=True) @full_sources.document class FullSourceBase(Document): join_field = JoinField() @registry.register_document class PublicSource(PublicSourceBase): id = fields.KeywordField(attr='id')
from elasticsearch_dsl import Index, DocType, Text, analyzer, connections from doctype import Movies connections.create_connection(hosts=['localhost']) single_shard_movies = Index('single_shard_movies') single_shard_movies.settings(number_of_shards=1, number_of_replicas=0) single_shard_movies.doc_type(Movies) multi_shard_movies = single_shard_movies.clone('multi_shard_movies') multi_shard_movies.settings(number_of_shards=3, number_of_replicas=0) single_shard_movies.create() multi_shard_movies.create()