# elasticsearch工具类 **Repository Path**: CodeLiQing/OSSRH-80613 ## Basic Information - **Project Name**: elasticsearch工具类 - **Description**: 帮助开发者快速使用es - **Primary Language**: Java - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2022-04-08 - **Last Updated**: 2022-06-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # elasticsearch工具类 #### 介绍 封装调用elasticseatch的繁杂调用提高开发效率 冲冲冲 方法解释: ``` /** * 创建索引 * * @param indexName 索引名 * @return */ public boolean createIndex(String indexName) /** ``` ``` * 删除索引 * * @param indexName 索引名 * @return */ public boolean deleteIndex(String indexName) ``` ``` /** * 判断索引是否存在 * * @doesTheIndexExist IOException */ public boolean doesTheIndexExist(String nameIndex) ``` ``` /** * 创建文档 * 规则 put /kuang_index/_doc/1 * * @param indexName 索引 * @param obj 存储的对象 * @return */ public boolean addDocuments(String indexName, Object obj, Object id) ``` ``` /** * 创建文档 规则 put /kuang_index/_doc/1 * * @param indexName 索引名 * @param obj 存储的数据 * @param id 唯一id * @param Millis 超时分钟 * @return */ public boolean addDocuments(String indexName, Object obj, Object id, String Millis) ``` ``` /** * 判断当前文档是个存在 * * @param indexName 索引名 * @param id 唯一id * @return */ public boolean doesTheDocumentExist(String indexName, Object id) ``` ``` /** * 获取文档信息 * * @param indexName 索引名 * @param id 唯一id * @return */ public Object getDocumentation(String indexName, Object id) ``` ``` /** * 增强版 获取文档信息 * * @param indexName 索引名 * @param id 唯一id * @param clAss 实体类的class * @return */ public Object getDocumentation(String indexName, Object id, Class clAss) ``` ``` /** * 修改文档 * * @param indexName 创建索引名 * @param obj 更新后的数据 * @param id id * @return */ public boolean modifyTheDocument(String indexName, Object obj, Object id) ``` ``` /** * 删除文档 * * @param indexName 创建索引 * @param id id * @return */ public boolean deleteDocument(String indexName, Object id) ``` ``` /** * 数据的批量插入 //特殊的 真的项目一般都会批量插入数据 * * @param indexName 创建索引名 * @param list 数据集 * @param Millis 超时时长 */ public boolean bulkInsertData(String indexName, List list, long Millis) ``` ``` /** * 条件查询 * * @param indexName 索引名 * @param map 条件构造 * @param startPage 从那一页开始 * @param endPage 结束页 * @return */ public List includeQuery(String indexName, Map map, Integer startPage, Integer endPage, Class dataClass) ``` ``` /** * * 复杂查询 * * searchRequest 搜索请求 * * SearchSourceBuilder 条件构造 * * HighlightBuilder 构造高亮 * * TermQueryBuilder 精确查询 * * xxx QueryBuilder * * @param indexName 索引名 * @param map 查询条件 * @param numericField 高亮字段 * @param startPage 第几个开始 * @param endPage 个数 * @param startTag 开头标签 * @param endTag 结束标签 */ public List highlightConditionQuery(String indexName, Map map, List numericField, Integer startPage, Integer endPage, String startTag, String endTag , Class dataClass) ```