Elasticsearch Date字段的默认值

Python爱好者

我正在使用以下方法在ES中创建动态映射:

{
  "template": "infobox*",
  "mappings": {
    "_default_": {
      "dynamic_templates": [
        {
          "string_fields": {
            "match": "*",
            "match_mapping_type": "string",
            "mapping": {
              "type": "string",
              "index": "analyzed",
              "analyzer": "my_completion_analyzer",
              "fielddata": {
                "format": "disabled"
              },
              "fields": {
                "raw": {
                  "type": "string",
                  "index": "not_analyzed",
                  "ignore_above": 256
                }
              }
            }
          }
        }
      ]
    }
  }
}

因此,每当我对具有date字段(birthYear的文档建立索引时,它都会自动创建birthYear具有date类型的字段(因此,每当没有a时birthYear,我都会发送一个空字符串'',然后引发异常mapper_parsing_exception, failed to parse [birthYear]

有什么办法可以解决这个问题?我可以指定默认值吗?

安德烈·斯特凡(Andrei Stefan)

您可以添加ignore_malformed: true到所有date字段,也可以全局设置:

date字段

  "dynamic_templates": [
    {
      "string_fields": {
        "match": "*",
        "match_mapping_type": "string",
        "mapping": {
          "type": "string",
          "index": "analyzed",
          "analyzer": "whitespace",
          "fielddata": {
            "format": "disabled"
          },
          "fields": {
            "raw": {
              "type": "string",
              "index": "not_analyzed",
              "ignore_above": 256
            }
          }
        }
      }
    },
    {
      "date_fields": {
        "match": "*",
        "match_mapping_type": "date",
        "mapping": {
          "type": "date",
          "ignore_malformed": true
        }
      }
    }
  ]

全局设置

{
  "settings": {
    "index.mapping.ignore_malformed": true
  }, 
  "mappings": {
    "_default_": {
      "dynamic_templates": [
        {
          "string_fields": {
            "match": "*",
            "match_mapping_type": "string",
            "mapping": {
              "type": "string",
              "index": "analyzed",
              "analyzer": "whitespace",
              "fielddata": {
                "format": "disabled"
              },
              "fields": {
                "raw": {
                  "type": "string",
                  "index": "not_analyzed",
                  "ignore_above": 256
                }
              }
            }
          }
        }
      ]
    }
  }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Elasticsearch Date字段的默认值

来自分类Dev

用于Elasticsearch统计方面的文档中缺少字段的默认值

来自分类Dev

为elasticsearch date字段提供空值

来自分类Dev

elasticsearch消息字段值

来自分类Dev

jQuery Mobile Date字段默认值未填充

来自分类Dev

使用logstash输入jdbc插件将从Mysql拉到Elasticsearch的Null值设置为默认值

来自分类Dev

Elasticsearch默认映射嵌套字段

来自分类Dev

django选择字段的默认值

来自分类Dev

计算字段中的默认值

来自分类Dev

原则:joinColumn字段的默认值

来自分类Dev

字段“区”没有默认值

来自分类Dev

字段没有默认值

来自分类Dev

实例在struct字段中的默认值

来自分类Dev

如何更改舞台字段的默认值

来自分类Dev

django选择字段的默认值

来自分类Dev

设置Bindy字段的默认值

来自分类Dev

不显示输入字段的默认值

来自分类Dev

Google表单嵌入字段的默认值

来自分类Dev

Django字段的默认值是多少?

来自分类Dev

在phpmyadmin中更改字段默认值

来自分类Dev

django:非空字段的默认值

来自分类Dev

字段没有默认值

来自分类Dev

空白字段的默认值

来自分类Dev

带默认字段的默认值的sqlite插入

来自分类Dev

搜索包含在值中的ElasticSearch字段

来自分类Dev

根据嵌套字段值修改Elasticsearch得分

来自分类Dev

根据字段值提升ElasticSearch结果

来自分类Dev

如何根据字段值过滤ElasticSearch结果?

来自分类Dev

基于布尔字段值促进Elasticsearch