覆盖Elasticsearch中索引的默认设置

时间:2019-04-12 05:32:43

标签: python-3.x elasticsearch amazon-ec2 full-text-search text-classification

弹性搜索服务器版本6.7.1 python驱动程序版本6.3.1

request_body = {
    "settings": {
        "index" : {"number_of_shards" : 1, "number_of_replicas" : 0 
      }},
    "mappings": {
        "document": {"dynamic": "strict","properties": {
                "doc_name": { "type": "text"},                   
                "doc_location" : { "type" : "text" },
                "doc_keywords": { "type": "nested","properties": {
                        "dynamic": "true","tag": {"type": "text"},
                        "score": {"type": "text"}
                    } } }} }}
 es_object.indices.create(index="tutorial",ignore=400,body=request_body)

通过python客户端创建索引,但默认设置为主碎片5和副本1。 curl命令使用正确的设置索引了数据。我有什么需要设置的吗?

curl -XPUT 'http://server_ip:9200/documentrepository/' -H 'Content-Type: application/json' -d '{
    "settings": {
            "number_of_shards": 1,
            "number_of_replicas": 0
        },
        "mappings": {
            "document": {
                "dynamic": "strict",
                "properties": {
                    "doc_name": { "type": "text"},                   
                    "doc_s3_location" : { "type" : "text" },
                    "doc_keywords": {
                        "type": "nested",
                        "properties": {"tag": {"type": "text"},"score": {"type": "text"}
                        }
                  }
              }
           }
       }
}'

enter image description here

0 个答案:

没有答案