ElasticSearch8.X 整合Springboot3.X Timestamp映射问题 没办法解决,只能灰头改成Date……

{
    "mappings": {
        "properties": {
            "id": {
                "type": "long"
            },
            "title": {
                "type": "text",
                "analyzer": "ik_smart"
            },
            "subTitle": {
                "type": "text",
                "analyzer": "ik_smart"
            },
            "tag": {
                "type": "text",
                "analyzer": "ik_smart"
            },
            "content": {
                "type": "text",
                "analyzer": "ik_smart"
            },
            "userId": {
                "type": "long"
            },
            "createTime": {
                "type": "date",
                "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
            }
        }
    }
}这是我的索引

@Data
@TableName("post")
@Document(indexName = "posts")
public class Post {
    @TableId(value = "id",type = IdType.ASSIGN_ID)
    @Id
    private Long id;
    …

        …
    @TableField(fill = FieldFill.INSERT)
    @Field(type = FieldType.Date, format = DateFormat.epoch_millis)
    private Timestamp createTime;
}
这是我的实体类

ERROR 14400 --- [nio-8080-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.util.Date] to type [java.sql.Timestamp]] with root cause

org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.util.Date] to type [java.sql.Timestamp]

这是我的报错,就是ES存储时间戳是可以的,但是search读取时映射出现问题  

 // 搜索帖子
    @GetMapping("/search")
    public List<Post> searchPosts(@RequestParam String keyword) {
        return postServiceImpl.searchPosts(keyword);
    }  

 // 搜索帖子(基于Elasticsearch)
    public List<Post> searchPosts(String keyword) {
        // 使用 Elasticsearch 的全文搜索功能
        return postRepository.findByTitleContaining(keyword);
    }

public interface PostRepository extends ElasticsearchRepository<Post,Long> {

    // 可以扩展自定义查询方法,例如按标题搜索
    List<Post> findByTitleContaining(String keyword);
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值