Skip to content
Snippets Groups Projects
0-setup-session.py 1.61 KiB
Newer Older
  • Learn to ignore specific revisions
  • from elasticsearch import Elasticsearch
    
    
    if __name__ == '__main__':
    
        import yaml
    
        with open("config.yaml", 'r') as yamlfile:
            cfg = yaml.load(yamlfile)
    
        es = Elasticsearch([cfg['indexer']['url']], timeout=60)
        es_index = cfg['indexer']['index']
    
        es_body = { "settings" : {
                        "number_of_shards" : 1,
                        "number_of_replicas" : 0,
                        "index.mapping.total_fields.limit": 10000,
                        "refresh_interval": "30s"
                        },
                    "mappings": {
                        "_doc": {
                            "dynamic_templates": [ # priority is given by order!
                                {
                                    "uuid" : {
                                        "path_match": "uuid",
                                        "mapping": {
                                            "type": "keyword",
                                            }
                                        }
                                },
                                {
                                    "default" : {
                                        "path_match": "*",
                                        "mapping": {
                                            "enabled": "false"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
        #es_body.update({"mappings": {"_doc": {"dynamic_date_formats": ["strict_date_optional_time"]}}})
    
        try:
            rep = es.indices.create(es_index, es_body)#, wait_for_active_shards=0)
        except:
            pass