elasticsearch Elasticsearch基本映射失败,elasticsearch,kibana,elasticsearch,Kibana" /> elasticsearch Elasticsearch基本映射失败,elasticsearch,kibana,elasticsearch,Kibana" />

elasticsearch Elasticsearch基本映射失败

elasticsearch Elasticsearch基本映射失败,elasticsearch,kibana,elasticsearch,Kibana,我已经为Elasticsearch 5.5.2和Kibana安装了Docker容器。我开始学习映射类型,并通过xcurl使用以下代码创建了索引: { "mappings": { "user": { "_all": { "enabled": false }, "properties": { "title": { "type": "text" }, "name": { "type": "text

我已经为Elasticsearch 5.5.2和Kibana安装了Docker容器。我开始学习映射类型,并通过xcurl使用以下代码创建了索引:

{
  "mappings": {
    "user": { 
      "_all":       { "enabled": false  }, 
      "properties": { 
        "title":    { "type": "text"  }, 
        "name":     { "type": "text"  }, 
        "age":      { "type": "integer" }  
      }
    }
}
索引创建成功,我决定插入一些数据。当我尝试将字符串添加到整数字段
中时,即{“age”:“hello”}
,Elastic显示一个错误(这意味着映射工作正常)。问题在于其他数据类型:

1.它接受字符串字段中的整数和浮点(我认为这可能是因为隐式强制转换)

2.在
age
字段中,它接受类似
22.4
的浮动(当我使用Kibana或xcurl搜索时,
age
字段内容显示为浮动,而不是整数,这意味着没有进行从浮动到整数的转换)


我做了什么坏事?

你试过禁用强制吗?这可以在现场级别完成:

   {
     "mappings": {
       "user": { 
         "_all":       { "enabled": false  }, 
         "properties": { 
           "title":    { "type": "text"  }, 
           "name":     { "type": "text"  }, 
           "age":      { "type": "integer",
                         "coerce": false}  
         }
       }
   }
或在所有字段的索引级别:

   "settings": {
       "index.mapping.coerce": false
     },
     "mappings": {
   ...

你试过禁用强制吗?这可以在现场级别完成:

   {
     "mappings": {
       "user": { 
         "_all":       { "enabled": false  }, 
         "properties": { 
           "title":    { "type": "text"  }, 
           "name":     { "type": "text"  }, 
           "age":      { "type": "integer",
                         "coerce": false}  
         }
       }
   }
或在所有字段的索引级别:

   "settings": {
       "index.mapping.coerce": false
     },
     "mappings": {
   ...

你能描述一下你是如何插入文件的吗
22.2
是一个完全有效的字符串。字符串不是普通的字母,它可以是任何东西。区别在于,
text
字段的分析和标记方式与其他字段不同。@aclook
curl-XPOST localhost:9200/my_index/user-d'{“title”:“a title”、“name”:“username”、“age”:223.5}'
它返回
{“my_index”、“\u type”:“user”、“\u id”:“AV4JO3pZh8gyIWsivJ6d”,“_version”:1,“result”:“created”;“_shards”:{“total”:2,“successful”:1,“failed”:0},“created”:true}
@MatsLindh,即使我没有用双引号指定它?我插入的是
22.2
而不是
“22.2”
,它接受该值。您能描述一下您是如何插入文档的吗?对于问题的第一部分
22.2
是一个完全有效的字符串。字符串不是普通的字母,它可以是任何东西。区别在于,
text
字段的分析和标记方式与其他字段不同。@aclook
curl-XPOST localhost:9200/my_index/user-d'{“title”:“a title”、“name”:“username”、“age”:223.5}'
它返回
{“my_index”、“\u type”:“user”、“\u id”:“AV4JO3pZh8gyIWsivJ6d”,“_version”:1,“result”:“created”;“_shards”:{“total”:2,“successful”:1,“failed”:0},“created”:true}
@MatsLindh,即使我没有用双引号指定它?我正在插入
22.2
而不是
“22.2”
,它接受该值。它运行正常。谢谢@Imma:)运行正常。谢谢@Imma:)