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

Index options not picked up #29

Open
BeardyC opened this issue May 24, 2021 · 5 comments
Open

Index options not picked up #29

BeardyC opened this issue May 24, 2021 · 5 comments

Comments

@BeardyC
Copy link

BeardyC commented May 24, 2021

Hi,

I'm trying to override the index config defaults using the below:

docker run --rm -it --network host oliver006/es-test-data  --es_url=http://... --batch_size=1000 --num_of_shards=1 --num_of_replicas=2 --index_name=test_data4

However it seems to ignore the options for shards & replicas

curl http://.../test_data4/  |  jq
{
  "test_data4": {
    "aliases": {},
    "mappings": {
      "properties": {
        "age": {
          "type": "long"
        },
        "last_updated": {
          "type": "long"
        },
        "name": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        }
      }
    },
    "settings": {
      "index": {
        "creation_date": "1621856375498",
        "number_of_shards": "1",
        "number_of_replicas": "1",
        "uuid": "_LBis-bSTmOqmEIi2lnJNQ",
        "version": {
          "created": "7040199"
        },
        "provided_name": "test_data4"
      }
    }
  }
}

Can you confirm that this is working? Am I missing something?

@BeardyC BeardyC changed the title Index options not used Index options not picked up May 24, 2021
@oliver006
Copy link
Owner

Thanks for the question. There's a good chance that the ES options have changed over time, this repo probably hasn't caught up with how things are done these days.

@kbiernat
Copy link

kbiernat commented Jun 3, 2021

It works fine on old ES (tried 5.5 first). On the new ES (7.2), with the index not being there, so it should create a new one, the output is (added printing the HTTP Error exception, hence HTTP 400):

[I 210603 11:33:30 es_test_data:55] Trying to create index http://localhost:9200/test_data
HTTP 400: Bad Request
[I 210603 11:33:30 es_test_data:61] Looks like the index exists already

@tuapuikia
Copy link

tuapuikia commented Aug 6, 2021

The refresh option is not available in ES 7 and the scheme require new index field.

diff --git a/es_test_data.py b/es_test_data.py
index 403d3f2..294ac20 100755
--- a/es_test_data.py
+++ b/es_test_data.py
@@ -43,10 +43,11 @@ def delete_index(idx_name):
 def create_index(idx_name):
     schema = {
         "settings": {
-            "number_of_shards":   tornado.options.options.num_of_shards,
-            "number_of_replicas": tornado.options.options.num_of_replicas
-        },
-        "refresh": True
+            "index": {
+                "number_of_shards":   tornado.options.options.num_of_shards,
+                "number_of_replicas": tornado.options.options.num_of_replicas
+            }
+        }
     }
 
     body = json.dumps(schema)

@oliver006
Copy link
Owner

That's a great find @tuapuikia - could you open a PR?

@ViggoC
Copy link

ViggoC commented Aug 7, 2021

@tuapuikia According to the reference of Create index API, the index field is optional for both 6.x and 7.x version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants