首页 > 解决方案 > 映射整数在 ElasticSearch 中不起作用

问题描述

我创建了一个索引“活动”并从 csv 中批量处理所有数据。然而,一切都是“文本”类型,一些值应该是“整数”、“长”、“双”类型。我尝试了以下但没有成功。我究竟做错了什么?

es.indices.create(index='activities')

#mapping datatype
es.indices.put_mapping(
    index="activities",
    include_type_name=True,
    doc_type="activity_body",
    body={
        "activity_body":{
        "properties": {"ActivitatID": {"type": "long"},
                       "Assignaturas": {"type": "text"},
                       "Competencias": {"type": "text"},
                       "Descripcion": {"type": "text"}, 
                       "EdadMaxima": {"type": "integer"},
                       "EdadMinima": {"type": "integer"},
                       "Guardados": {"type": "integer"},
                       "Idioma": {"type": "text"}, 
                       "Link": {"type": "text"},
                       "Nombre": {"type": "text"}, 
                       "Puntuacion": {"type": "double"},
                       "Tags": { "type": "text"},
                       "Votos": {"type": "integer"},
                       "Tipo": {"type": "text"}
                      }
        }
    }
)

#open file and load all data to elasticsearch
with open(file_path) as f:
    reader = csv.DictReader(f)
    helpers.bulk(es, reader, index="activities")

谢谢

标签: pythonelasticsearchmapping

解决方案


推荐阅读