[英]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.