簡體   English   中英

使用Python映射Elasticsearch

[英]Mapping Elasticsearch with Python

我有JSON文檔(以下稱為“ file_content”),其中包含我希望全部設置為not_analyzed的字符串。 我正在努力做到這一點:

if not es.indices.exists(index='telemfile'):
                es.indices.create('telemfile')                                                  #  Create the index to work with
                namapping = {
                    "mappings": {
                        "telemetry_file": {
                            "dynamic_templates": [{
                                "string_fields": {
                                    "match": "*",
                                    "match_mapping_type": "string",
                                    "mapping": {
                                        "type": "string",
                                        "index": "not_analyzed"
                                    }
                                }
                            }]
                        }
                    }
                }
                es.indices.put_mapping(index='telemfile', doc_type='telemetry_file', body=namapping)

            es.index(index='telemfile', doc_type='telemetry_file', body=file_content)

但出現以下錯誤:MapperParsingException [解析后的根類型映射不為空! 其余字段:[mappings:{telemetry_file = {dynamic_templates = [{string_fields = {mapping = {type = string,index = not_analyzed},match = *,match_mapping_type = string}}}}]]]] 誰能告訴我我在做什么錯?

我從上面刪除了“映射”:對象,並且它可以正常工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM