问题描述
以下映射中的字段版本的类型是日期。但是在groups / _mapping上列出的版本类型是文本。映射或设置有什么问题吗?谢谢。
映射:
PUT组
{
settings:{
index.mapping.ignore_malformed:true
},
mappings:{
shop:{
_all:{启用:false},
动态: false,
date_detection:false,
属性:{
sid:{ type:关键字},
version:{
type: date,
format: yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || epoch_millis
}
}
}
}
}
其结果是。
{
已确认:是,
shards_acknowledged:确实是
}
来自
The type of field version in following mapping is date. But the type of version listed on groups/_mapping is text. Is there anything wrong about the mapping or settings ? Thanks.
mapping:
PUT groups
{
"settings": {
"index.mapping.ignore_malformed": true
},
"mappings": {
"shop": {
"_all": { "enabled": false },
"dynamic": "false",
"date_detection" : false,
"properties": {
"sid": { "type": "keyword"},
"version": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
}
}
}
}
}
the result for this is.
{
"acknowledged": true,
"shards_acknowledged": true
}
result from http://host:9200/groups/_mapping
{
"groups": {
"mappings": {
"shop": {
"properties": {
"sid": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"version": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
Insert data as follow:
{'sid': '772634b9b9a8437f9cbfaec2b546f8af', 'version': '20131209 15:19:04'}
The response:
{
'_id': '772634b9b9a8437f9cbfaec2b546f8af',
'_index': 'groups_version',
'_shards': {'failed': 0, 'successful': 2, 'total': 2},
'_type': 'shop',
'_version': 1,
'result': 'created',
}
the asdas
I think I might know what is going on - in Kibana when you put an empty line between PUT group
and the body {}
it does not append the body to the reguest and the only request that is sent is:
curl -XPUT "http://localhost:9200/groups"
That is why you got standard mapping with text
. But if you remove the empty line everythnig is fine and this request is sent:
curl -XPUT "http://localhost:9200/groups" -H 'Content-Type: application/json' -d'
{ "body": {
"settings": {
"index.mapping.ignore_malformed": true
},
"mappings": {
"shop": {
"_all": { "enabled": false },
"dynamic": "false",
"date_detection" : false,
"properties": {
"sid": { "type": "keyword"},
"version": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
}
}
}
}
}
}'
It is easy to check what is really sent when you click the "wrench" button, then "Copy as cURL" and paste it somewhere:
这篇关于类型日期已在Elasticsearch(v5.4.0)中隐藏为文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!