You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dsl3/mapper/ElasticsearchMapper.java

26 lines
1.7 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.aurora.mapper;
// 导入项目内定义的ArticleSearchDTO类该类作为Elasticsearch文档的实体映射用于搜索结果的传输
import com.aurora.model.dto.ArticleSearchDTO;
// 导入Spring Data Elasticsearch提供的核心接口ElasticsearchRepository它封装了基本的Elasticsearch操作
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;
/**
* @author 花未眠
* elasticsearch
*/
// @Repository注解将本接口标识为数据访问层DAO组件让Spring能够扫描并管理其实例如依赖注入
// 该注解是@Component的特殊化表明其主要职责是与数据库此处为Elasticsearch交互
@Repository
// 定义ElasticsearchMapper接口继承自ElasticsearchRepository接口
// ElasticsearchRepository是Spring Data Elasticsearch提供的基础仓库核心接口提供了丰富的CRUD和搜索方法
// 内置了和Elasticsearch交互的基础方法比如全文搜索、数据新增/删除到ES索引等
// 泛型参数说明:
// - ArticleSearchDTO指定该Repository管理的实体类型即Elasticsearch中文档对应的Java对象用于ES搜索的文章数据传输对象包含文章标题、内容、标签等用于搜索的字段
// 该类应使用@Document等注解配置索引映射如索引名、类型等
// - IntegerDTO对应数据指定实体主键ID的数据类型。在Elasticsearch中每个文档都有一个唯一ID这里使用Integer类型。
public interface ElasticsearchMapper extends ElasticsearchRepository<ArticleSearchDTO,Integer> {//基于文章搜索模块的数据访问层接口
}