简体   繁体   English

在新索引上设置的映射将被忽略

[英]Mapping set on new index is ignored

Hi ! 嗨!

I just started to learn ElasticSearch, and my first steps wasn't too bad. 我刚开始学习ElasticSearch,但我的第一步还不错。 I put some data into with the help of the ES library available on Python with the following piece of code: 我使用以下代码在Python上可用的ES库的帮助下放入了一些数据:

from elasticsearch import Elasticsearch

jsondata(json.dumps("{
    "low": "5.9400",
    "high": "5.9600",
    "id": "555",
    "volume": 1171,
    "timestamp": "2016-08-15 19:01:03"
    }"
)
ES_HOST = {"host" : "localhost", "port" : 9200}
es = Elasticsearch(hosts = [ES_HOST])

    es.create(index="index_test",
              doc_type="tr",
              body=jsondata
          )

However, when I wanted to define each type of fields I put, ES just ignore it. 但是,当我想定义我输入的每种类型的字段时,ES只会忽略它。 I think the way I proceed isn't correct. 我认为我的做法不正确。 There is the piece of code I executed just before execute my Python script : 在执行Python脚本之前,我执行了一段代码:

curl -XPUT 'http://localhost:9200/index_test/' -d '"mappings": {
"tr": {
    "_source": {
        "enabled":true
    }
    "properties" : {
        "id" : { "type" : "integer" },
        "volume" : { "type" : "integer" },
        "high" : { "type" : "float" },
        "low" : { "type" : "float" },
        "timestamp" : { "type" : "date", "format" : "yyyy-MM-dd HH:mm:ss" }
    }
}
}'

By default, ES store the data with all fields set as string , except the volume field, set as number . 默认情况下,ES存储的数据中所有字段均设置为string ,但volume字段除外,所有字段均设置为number There is the JSON gave by ES via Kibana: ES通过Kibana提供了JSON:

{
  "_index": "index_test",
  "_type": "tr",
  "_id": "AVaPJj8Y0iDATupCtaXZ",
  "_score": 1,
  "_source": {
    "low": "5.9400",
    "high": "5.9600",
    "id": "555",
    "volume": 1171,
    "timestamp": "2016-08-15 19:01:03"
  }
}

Anything I forgot ? 我有什么忘了吗? Maybe I needed to add the settings part ? 也许我需要添加设置部分?

There it is ! 那里!

Ok, I've tried to do the following: 好的,我尝试执行以下操作:

$curl -XDELETE http://localhost:9200/index_test/
{"acknowledged":true}

$curl -XPUT 'http://localhost:9200/index_test/' -d conf/ESConf/ElasticSearchMapping.conf
{"acknowledged":true}

$curl -XGET 'http://localhost:9200/index_test/'
{"index_test":{"aliases":{},"mappings":{},"settings":{"index":  {"conf/ESConf/ElasticSearchMapping":{"conf":""},"creation_date":"1471283566621","number_of_shards":"5","number_of_replicas":"1","uuid":"EZoDAOJNQoiX4VQWs1Sx1w","version":{"created":"2030499"}}},"warmers":{}}}

So I forgot to add @ before my path, that's why it did not worked ^^": 所以我忘了在路径之前添加@,这就是为什么它不起作用^^“:

curl -XPUT 'http://localhost:9200/index_test/' -d @conf/ESConf/ElasticSearchMapping.conf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用映射创建新的ElasticSearch索引 - Creating a new ElasticSearch index with mapping 将列表更改映射到他们的新索引 Python - Mapping list changes to their new index Python 如何通过映射在新数据框中查找列表的索引? - How to find index of a list in a new dataframe by mapping? Buildout自定义索引被忽略 - Buildout custom Index ignored 重塑熊猫数据框,将现有列的值转换为新的较低级列,而忽略索引 - Reshaping pandas dataframe, converting values of an existing column into new lower level columns with index ignored 如何在pandas df中设置新索引并删除默认索引 - How to set new index and remove default index in pandas df 熊猫使用列拆分作为新索引设置索引 - pandas set index using split of column as new index 根据另一个张量中的索引将张量中的每个值映射到新值 - Mapping each value in a tensor to a new value depending on its index in another tensor 从系列或字典向数据帧添加一个新列,将我的系列索引和数据帧列映射到键熊猫 python - Add a new column to a dataframe from a Series or dictionary mapping my series index and a dataframe column to key pandas python Python-熊猫-从SubSelect蒙版设置新的DataFrame没有索引错误 - Python - Pandas - Set New DataFrame from SubSelect Mask Not Index Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM