spring-elasticsearch-date 启动失败原因分析(mapping)

启动时候创建的 索引mapping

和save时候 创建的 索引mapping
之间的区别测试。

实体类

/**
 * @author river
 * @date 2019/2/27 14:47
 **/
@Data
@Document(indexName = "student-" + "#{ T(com.river.es.entity.Student).dateStr() }",

        type = "student",
        shards = 2,
        replicas = 1, refreshInterval = "-1")
public class Student {

    @Id
    private String id;

    @Field(type = FieldType.Keyword)
    private String name;

    @Field(type = FieldType.Integer)
    private Integer age;

    private String desc;

    public static String dateStr()
    {
        return DateUtil.now().replace(" ","");
    }
}

springboot 启动后创建的mapping为

{
  "student-2019-05-3109:18:49": {
    "mappings": {
      "student": {
        "properties": {
          "age": {
            "type": "integer"
          },
          "name": {
            "type": "keyword"
          }
        }
      }
    }
  }
}

save时候发现没有 自己(es)默认创建的

  "student-2019-05-3109:25:17": {
    "mappings": {
      "student": {
        "properties": {
          "age": {
            "type": "long"
          },
          "desc": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "name": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    }
  }

不一样,这个问题 可能导致,下次启动失败。因为es不支持 修改 mapping

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容