发布
社区首页 >问答首页 >ElasticSearch2.3放置映射(试图覆盖日期字段类型)错误

ElasticSearch2.3放置映射(试图覆盖日期字段类型)错误
EN

Stack Overflow用户
提问于 2016-05-26 22:45:34
回答 1查看 516关注 0票数 1

我有一些birth_dates,我想将其存储为字符串。我不打算对数据进行任何查询或分析,我只是想存储它。

我得到的输入数据有很多不同的随机格式,有些甚至包括(approximate)这样的字符串。弹性已确定这应该是一个日期字段的日期格式,这意味着当弹性收到日期,如1981 (approx),它会抓狂,并说输入是无效的格式。

我不想更改输入日期,而是将日期类型更改为string。

我已经看过文档,并且一直试图用PUT映射API更新映射,但是弹性一直在返回解析错误。

根据这里的文件:

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html

我试过:

代码语言:javascript
代码运行次数:0
复制
PUT /sanctions_lists/eu_financial_sanctions/_mapping
{
    "mappings":{
        "eu_financial_sanctions":{
         "properties": {
             "birth_date": {
                 "type": "string", "index":"not_analyzed"
             }
         }
       }
    }
 }

但返回:

代码语言:javascript
代码运行次数:0
复制
{
   "error": {
      "root_cause": [
         {
            "type": "mapper_parsing_exception",
            "reason": "Root mapping definition has unsupported parameters:  [mappings : {eu_financial_sanctions={properties={birth_date={type=string, index=not_analyzed}}}}]"
         }
      ],
      "type": "mapper_parsing_exception",
      "reason": "Root mapping definition has unsupported parameters:  [mappings : {eu_financial_sanctions={properties={birth_date={type=string, index=not_analyzed}}}}]"
   },
   "status": 400
}

问题摘要

是否可以重写elasticsearch的自动确定日期字段,强制字符串作为字段类型?

注意事项

我正在使用插件发送请求

弹性搜索版本为2.3

EN

回答 1

Stack Overflow用户

发布于 2016-05-27 01:47:19

只需从url中移除类型引用和映射,您就可以在请求正文中找到它们。更多的例子。

代码语言:javascript
代码运行次数:0
复制
PUT /sanctions_lists
{
    "mappings":{
        "eu_financial_sanctions":{
         "properties": {
             "birth_date": {
                 "type": "string", "index":"not_analyzed"
             }
         }
       }
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37472252

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档