Repository: elastic/elasticsearch-dsl-py

Issue:
Index.clone() does not copy Index._analysis
I am not sure if it's intended or not but `Index.clone()` does not copy `_analysis` attribute.

Discussion:

Patch:
diff --git a/elasticsearch_dsl/index.py b/elasticsearch_dsl/index.py
index 3d6af0e..9237377 100644
--- a/elasticsearch_dsl/index.py
+++ b/elasticsearch_dsl/index.py
@@ -31,7 +31,8 @@ class Index(object):
         :arg using: connection alias to use, defaults to ``'default'``
         """
         i = Index(name, using=using or self._using)
-        for attr in ('_doc_types', '_mappings', '_settings', '_aliases'):
+        for attr in ('_doc_types', '_mappings', '_settings', '_aliases',
+                     '_analysis'):
             setattr(i, attr, getattr(self, attr).copy())
         return i
 
diff --git a/setup.py b/setup.py
index 661276a..bdf9a33 100644
--- a/setup.py
+++ b/setup.py
@@ -60,4 +60,6 @@ setup(
 
     test_suite = "test_elasticsearch_dsl.run_tests.run_all",
     tests_require=tests_require,
+
+    extras_require={'develop': tests_require},
 )


Test patch:
diff --git a/test_elasticsearch_dsl/test_index.py b/test_elasticsearch_dsl/test_index.py
index d2faaad..17aa6b7 100644
--- a/test_elasticsearch_dsl/test_index.py
+++ b/test_elasticsearch_dsl/test_index.py
@@ -27,6 +27,24 @@ def test_cloned_index_has_copied_settings_and_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']
+
+
 def test_settings_are_saved():
     i = Index('i')
     i.settings(number_of_replicas=0)