-
2020-10-26 21:51:42
TIDB海量数据新增索引
由于创建索引在扫表回填索引的时候会消耗大量资源,甚至与一些频繁更新的字段会发生冲突导致正常业务受到影响。大表创建索引的过程往往会持续很长时间,所以要尽可能地平衡执行时间和集群性能之间的关系,比如选择非高频更新时间段
参数调整:
目前主要使用
tidb_ddl_reorg_worker_cnt
和tidb_ddl_reorg_batch_size
这两个参数来动态调整索引创建速度,通常来说它们的值越小对系统影响越小,但是执行时间越长。一般情况下,先将值保持为默认的 4 和 256 ,观察集群资源使用情况和响应速度,再逐渐调大
tidb_ddl_reorg_worker_cnt
参数来增加并发,观察监控如果系统没有发生明显的抖动,再逐渐调大tidb_ddl_reorg_batch_size
参数,但如果索引涉及的列更新很频繁的话就会造成大量冲突造成失败重试。另外还可以通过调整参数
tidb_ddl_reorg_priority
为PRIORITY_HIGH
来让创建索引的任务保持高优先级来提升速度,但在通用 OLTP 系统上,一般建议保持默认。例:生产1亿数据:
SET GLOBAL tidb_ddl_reorg_worker_cnt = 16; SET GLOBAL tidb_ddl_reorg_batch_size = 10240;
更多相关内容 -
elasticsearch新增索引、添加数据、批量添加
2021-02-26 19:34:44文章目录前言一、新增索引二、添加文档三、批量导入四、删除文档五、删除索引总结 前言 提示:以下是本篇文章正文内容,下面案例可供参考 一、新增索引 代码如下(示例): public CreateIndexResponse ...
前言
提示:以下是本篇文章正文内容,下面案例可供参考
一、新增索引
代码如下(示例):
/** * 功能描述: 新增索引 * @param indexName 索引名字 * @param mapping 映射 * @param replicas 副本 * @param shards 分片 * @return : void */ public CreateIndexResponse indexCreation(String indexName, String mapping, Integer replicas, Integer shards) throws IOException, IndexException { //1.使用client获取操作索引对象 GetIndexRequest getIndexRequest = new GetIndexRequest(indexName); IndicesClient indices = restHighLevelClient.indices(); boolean exists = indices.exists(getIndexRequest, RequestOptions.DEFAULT); if (exists) { log.error(String.valueOf(ResponseEnum.INDEX_EXISTENCE)); throw new IndexException(ResponseEnum.INDEX_EXISTENCE); } //2.1 设置索引名称 你要添加的数据库名称 CreateIndexRequest request = new CreateIndexRequest(indexName);//这里数据库名不能小写大写一块用 Map map = new HashMap(); map.put("number_of_replicas", replicas); map.put("number_of_shards", shards); request.settings(map); request.mapping(mapping, XContentType.JSON); CreateIndexResponse createIndexResponse = null; try { createIndexResponse = indices.create(request, RequestOptions.DEFAULT); } catch (Exception e) { e.printStackTrace(); log.error("创建索引失败--{}", e); } return createIndexResponse; }
controller
public BaseResponse indexCreation(@RequestParam("indexName") String indexName, @RequestBody String mapping, @RequestParam("replicas") Integer replicas, @RequestParam("shards") Integer shards) throws IOException, IndexException { CreateIndexResponse createIndexResponse = searchService.indexCreation(indexName, mapping, replicas, shards); if (createIndexResponse == null) { BaseResponse baseResponse = new BaseResponse(ResponseEnum.INDEX_FAIL.getCode(), false, ResponseEnum.INDEX_FAIL.getMsg(), null); return baseResponse; } if (createIndexResponse.isShardsAcknowledged() && createIndexResponse.isAcknowledged()) { return ok(createIndexResponse); } return error(createIndexResponse); }
二、添加文档
代码如下(示例):
serviceImpl
/** * 功能描述: 添加文档 * @param jsonObject 存的数据字符串 * @param indexName 索引名 * @return : void */ public IndexResponse contextLoads(String jsonObject, String indexName,String idColumn) throws IndexException { Map<String, Object> map = (Map<String, Object>) JSONObject.parse(jsonObject); String id = (String) map.get(idColumn); if (StringUtils.isEmpty(id)) { log.error(String.valueOf(ResponseEnum.ID_NULL)); throw new IndexException(ResponseEnum.ID_NULL); } IndexRequest indexRequest = new IndexRequest(indexName).id(id).source(map); //操作对象直接存入 IndexResponse indexResponse = null; try { indexResponse = restHighLevelClient.index(indexRequest, RequestOptions.DEFAULT); } catch (IOException e) { e.printStackTrace(); log.error("文档添加失败--{}", e); throw new IndexException(ResponseEnum.DOCUMENT_FAIL); } return indexResponse; }
controller
public BaseResponse contextLoads(@RequestBody String jsonObject, @RequestParam("indexName") String indexName,@RequestParam("idColumn") String idColumn) throws IndexException { IndexResponse indexResponse = searchService.contextLoads(jsonObject, indexName,idColumn); return ok(indexResponse.getResult()); }
代码如下(示例):
三、批量导入
serviceImpl
/** * 功能描述: 批量导入 * @param jsonObjectList json形式的List集合 * @param indexName 索引名 * @return : void */ public BulkResponse batchContextLoads(JSONArray jsonObjectList, String indexName,@RequestParam("idColumn") String idColumn) throws IndexException { BulkRequest bulkRequest = new BulkRequest(); log.info("jsonObjectList数据为:"+jsonObjectList.toString()); for (int i = 0 ; i < jsonObjectList.size() ; i ++){ Map<String, Object> map = (Map<String, Object>)jsonObjectList.get(i); String id = String.valueOf(map.get(idColumn)); if (StringUtils.isEmpty(id)) { log.error(String.valueOf(ResponseEnum.ID_NULL)); throw new IndexException(ResponseEnum.ID_NULL); } IndexRequest source = new IndexRequest(indexName).id(id).source(map); bulkRequest.add(source); } BulkResponse bulkResponse = null; try { bulkResponse = restHighLevelClient.bulk(bulkRequest, RequestOptions.DEFAULT); } catch (Exception e) { log.error("批量添加失败-->{}", e); e.printStackTrace(); } return bulkResponse; }
controller
public BaseResponse batchContextLoads(@RequestBody JSONArray jsonObjectList, @RequestParam("indexName") String indexName, @RequestParam("idColumn") String idColumn) throws IndexException { BulkResponse bulkItemResponses = searchService.batchContextLoads(jsonObjectList, indexName,idColumn); if (bulkItemResponses == null) { BaseResponse baseResponse = new BaseResponse(ResponseEnum.BULK_FAIL.getCode(), false, ResponseEnum.BULK_FAIL.getMsg(), null); return baseResponse; } if (bulkItemResponses.hasFailures()) { List<BulkItemResponse.Failure> failureList = new ArrayList<>(); for (BulkItemResponse bulkItemResponse : bulkItemResponses) { if (bulkItemResponse.isFailed()) { BulkItemResponse.Failure failure = bulkItemResponse.getFailure(); failureList.add(failure); } } return error(failureList); } return ok(bulkItemResponses.getIngestTook()); }
四、删除文档
serviceImpl
/** * 功能描述: 删除文档 * @param id 文档id * @param indexName 索引名 */ public DeleteResponse deleteById(String indexName, String id) { DeleteResponse deleteResponse = null; try { DeleteRequest deleteRequest = new DeleteRequest(indexName,id); deleteResponse = restHighLevelClient.delete(deleteRequest,RequestOptions.DEFAULT); }catch (Exception e){ log.error("删除文档失败-->{}", e); e.printStackTrace(); } return deleteResponse; }
这里需要注意的一点就是如果你要删除的的索引不存在的话,这里返回的DeleteResponse 就为null。注意处理好就可以。
controllerpublic BaseResponse deleteById(@RequestParam(value = "indexName")String indexName,@RequestParam(value = "id")String id) throws Exception{ if (StringUtils.isNotBlank(indexName) && StringUtils.isNotBlank(id)){ DeleteResponse deleteResponse = searchService.deleteById(indexName,id); if (deleteResponse == null){ BaseResponse baseResponse = new BaseResponse(ResponseEnum.DELETE_FAIL.getCode(), false, ResponseEnum.DELETE_INDEX_NULL.getMsg(), null); return baseResponse; }else { return ok(deleteResponse.getResult()); } }else { BaseResponse baseResponse = new BaseResponse(ResponseEnum.DELETEBYID_FAIL.getCode(), false, ResponseEnum.DELETEBYID_FAIL.getMsg(), null); return baseResponse; } }
五、删除索引
serviceImpl
/** * 功能描述: 删除索引 * @param indexName 索引名 */ public AcknowledgedResponse delete(String indexName) { org.elasticsearch.action.support.master.AcknowledgedResponse acknowledgedResponse = null; try { IndicesClient indicesClient = restHighLevelClient.indices(); DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(indexName); acknowledgedResponse = indicesClient.delete(deleteIndexRequest,RequestOptions.DEFAULT); }catch (Exception e){ log.error("删除索引失败-->{}", e); e.printStackTrace(); } return acknowledgedResponse; }
这里需要注意的一点就是如果你要删除的的索引不存在的话,这里返回的DeleteResponse 就为null。注意处理好就可以。
controllerpublic BaseResponse delete(@RequestParam(value = "indexName")String indexName) throws Exception{ if (StringUtils.isNotBlank(indexName)){ AcknowledgedResponse acknowledgedResponse = searchService.delete(indexName); if (acknowledgedResponse == null){ BaseResponse baseResponse = new BaseResponse(ResponseEnum.DELETE_FAIL.getCode(), false, ResponseEnum.DELETE_INDEX_NULL.getMsg(), null); return baseResponse; }else { return ok(acknowledgedResponse.isAcknowledged()); } }else { BaseResponse baseResponse = new BaseResponse(ResponseEnum.DELETE_FAIL.getCode(), false, ResponseEnum.DELETE_FAIL.getMsg(), null); return baseResponse; } }
总结
下一篇来看下查询的一些方法及骚操作。。。。。
-
SpringBoot2.3+ ElasticsearchRestTemplate es7.x增删改查、修改别名、自定义索引名称新增索引
2021-09-22 09:54:50Spring Boot对应es版本 点击进入Spring Data Elasticsearch官方文档各个版本地址 <dependency> <groupId>org.springframework.boot</groupId>...spring-boot-starter-data-elasticsearch<...1、Spring Boot对应es版本
点击进入Spring Data Elasticsearch官方文档各个版本地址
jar包<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-elasticsearch</artifactId> <!-- 防止与引入的fastjson冲突 --> <exclusions> <exclusion> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-smile</artifactId> </exclusion> <exclusion> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-cbor</artifactId> </exclusion> <exclusion> <groupId>net.sf.jopt-simple</groupId> <artifactId>jopt-simple</artifactId> </exclusion> </exclusions> </dependency>
2、setting
我的示例setting,根据实际情况自行修改
{ "index": { "max_result_window": "500000", "analysis": { "filter": { "limit_len": { "type": "length", "min": "1" } }, "analyzer": { "ik_max_custom": { "filter": [ "limit_len" ], "char_filter": [ "html_strip" ], "tokenizer": "ik_max_word" }, "ik_smart_custom": { "type": "custom", "tokenizer": "ik_smart", "char_filter": [], "filter": [ "limit_len" ] }, "default_pattern_analyzer": { "type":"pattern" } } } } }
存放目录
3、ElasticsearchRestTemplate 常用方法 对应es7.6+
代码示例,查询列表其实可以抽离,因为查询是独立的,可以单独一个类继承CommonESRepository,或者更全面的封装一下查询方法
import com.alibaba.fastjson.JSON; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.TermQueryBuilder; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.Resource; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.data.elasticsearch.core.SearchHit; import org.springframework.data.elasticsearch.core.SearchHits; import org.springframework.data.elasticsearch.core.document.Document; import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; import org.springframework.data.elasticsearch.core.query.AliasQuery; import org.springframework.data.elasticsearch.core.query.IndexQuery; import org.springframework.data.elasticsearch.core.query.NativeSearchQuery; import org.springframework.data.elasticsearch.core.query.UpdateQuery; import org.springframework.stereotype.Component; import java.io.IOException; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.List; @Slf4j @Component public class CommonESRepository { /** * 索引的setting */ @Value("classpath:json/es-setting.json") private Resource esSetting; private final ElasticsearchRestTemplate elasticsearchRestTemplate; public CommonESRepository(ElasticsearchRestTemplate elasticsearchRestTemplate) { this.elasticsearchRestTemplate = elasticsearchRestTemplate; } /** * 判断索引是否存在 * @param indexName 索引名称 * @return boolean */ public boolean indexExist(String indexName){ if(StringUtils.isBlank(indexName)){ return false; } IndexCoordinates indexCoordinates = IndexCoordinates.of(indexName); return elasticsearchRestTemplate.indexOps(indexCoordinates).exists(); } /** * 判断index是否存在 不存在创建index * @param index 索引实体 * @param indexName 创建索引的名称 */ public void indexCreate(Class index,String indexName){ if(null == index || StringUtils.isBlank(indexName)){ return; } IndexCoordinates indexCoordinates = IndexCoordinates.of(indexName); if(!elasticsearchRestTemplate.indexOps(indexCoordinates).exists()){ // 根据索引实体,获取mapping字段 Document mapping = elasticsearchRestTemplate.indexOps(indexCoordinates).createMapping(index); // 创建索引 String esSettingStr = null; try { // 读取setting配置文件 esSettingStr = IOUtils.toString(esSetting.getInputStream(), Charset.forName("utf-8")); } catch (IOException e) { log.error("读取setting配置文件错误", e); } // setting Document setting = Document.parse(esSettingStr); elasticsearchRestTemplate.indexOps(indexCoordinates).create(setting); // 创建索引mapping elasticsearchRestTemplate.indexOps(indexCoordinates).putMapping(mapping); } } /** * 根据索引名称,删除索引 * @param index 索引类 */ public void indexDelete(String index){ elasticsearchRestTemplate.indexOps(IndexCoordinates.of(index)).delete(); } /** * 索引添加别名 * @param indexName 索引名 * @param aliasName 别名 */ public boolean indexAddAlias(String indexName,String aliasName){ if(StringUtils.isBlank(indexName) || StringUtils.isBlank(aliasName)){ return false; } // 索引封装类 IndexCoordinates indexCoordinates = IndexCoordinates.of(indexName); // 判断索引是否存在 if(elasticsearchRestTemplate.indexOps(indexCoordinates).exists()){ // 索引别名 AliasQuery query = new AliasQuery(aliasName); // 添加索引别名 boolean bool = elasticsearchRestTemplate.indexOps(indexCoordinates).addAlias(query); return bool; } return false; } /** * 索引别名删除 * @param indexName 索引名 * @param aliasName 别名 */ public boolean indexRemoveAlias(String indexName,String aliasName){ if(StringUtils.isBlank(indexName) || StringUtils.isBlank(aliasName)){ return false; } // 索引封装类 IndexCoordinates indexCoordinates = IndexCoordinates.of(indexName); // 判断索引是否存在 if(elasticsearchRestTemplate.indexOps(indexCoordinates).exists()){ // 索引别名 AliasQuery query = new AliasQuery(aliasName); // 删除索引别名 boolean bool = elasticsearchRestTemplate.indexOps(indexCoordinates).removeAlias(query); return bool; } return false; } /** * 索引新增数据 * @param t 索引类 * @param <T> 索引类 */ public <T> void save(T t){ // 根据索引实体名新增数据 elasticsearchRestTemplate.save(t); } /** * 批量插入数据 * @param queries 数据 * @param index 索引名称 */ public void bulkIndex(List<IndexQuery> queries, String index){ // 索引封装类 IndexCoordinates indexCoordinates = IndexCoordinates.of(index); // 批量新增数据,此处数据,不要超过100m,100m是es批量新增的筏值,修改可能会影响性能 elasticsearchRestTemplate.bulkIndex(queries,indexCoordinates); } /** * 根据条件删除对应索引名称的数据 * @param c 索引类对象 * @param filedName 索引中字段 * @param val 删除条件 * @param index 索引名 */ public void delete(Class c,String filedName,Object val,String index){ // 匹配文件查询 TermQueryBuilder termQueryBuilder = QueryBuilders.termQuery(filedName, val); NativeSearchQuery nativeSearchQuery = new NativeSearchQuery(termQueryBuilder); // 删除索引数据 elasticsearchRestTemplate.delete(nativeSearchQuery,c, IndexCoordinates.of(index)); } /** * 根据数据id删除索引 * @param id 索引id * @param index */ public void deleteById(Object id,String index){ if(null != id && StringUtils.isNotBlank(index)){ // 根据索引删除索引id数据 elasticsearchRestTemplate.delete(id.toString(),IndexCoordinates.of(index)); } } /** * 根据id更新索引数据,不存在则创建索引 * @param t 索引实体 * @param id 主键 * @param index 索引名称 * @param <T> 索引实体 */ public <T> void update(T t,Integer id,String index){ // 查询索引中数据是否存在 Object data = elasticsearchRestTemplate.get(id.toString(), t.getClass(), IndexCoordinates.of(index)); if(data != null){ // 存在则更新 UpdateQuery build = UpdateQuery.builder(id.toString()).withDocument(Document.parse(JSON.toJSONString(t))).build(); elasticsearchRestTemplate.update(build,IndexCoordinates.of(index)); }else { // 不存在则创建 elasticsearchRestTemplate.save(t); } } /** * 查询数据根据实际情况自行修改 * @param c * @param search * @param index * @param <T> * @return */ public <T> List<T> getList(Class<T> c,String search,String index){ TermQueryBuilder termQueryBuilder = QueryBuilders.termQuery("title", search); NativeSearchQuery nativeSearchQuery = new NativeSearchQuery(termQueryBuilder); nativeSearchQuery.addSort(Sort.by(Sort.Direction.DESC,"_score")); nativeSearchQuery.setTrackTotalHits(true); SearchHits<T> tax_knowledge_matter = elasticsearchRestTemplate.search(nativeSearchQuery, c, IndexCoordinates.of(index)); List<SearchHit<T>> searchHits = tax_knowledge_matter.getSearchHits(); List<T> returnResult = new ArrayList<>(); searchHits.forEach(item -> { T content = item.getContent(); returnResult.add(content); }); return returnResult; } public <T> List<T> getList(Class<T> c,String search,int page,int size,Integer siteId,String index){ BoolQueryBuilder title = QueryBuilders.boolQuery(). must(QueryBuilders.matchQuery("title", search)). must(QueryBuilders.termQuery("siteId", siteId)); NativeSearchQuery nativeSearchQuery = new NativeSearchQuery(title); // nativeSearchQuery.addSort(Sort.by(Sort.Direction.DESC,"_score")); nativeSearchQuery.setPageable(PageRequest.of(page,size,Sort.by(Sort.Direction.DESC,"_score"))); nativeSearchQuery.setTrackTotalHits(true); SearchHits<T> tax_knowledge_matter = elasticsearchRestTemplate.search(nativeSearchQuery, c, IndexCoordinates.of(index)); List<SearchHit<T>> searchHits = tax_knowledge_matter.getSearchHits(); List<T> returnResult = new ArrayList<>(); searchHits.forEach(item -> { T content = item.getContent(); returnResult.add(content); }); return returnResult; } }
-
es 基于postman 删除、新增索引
2020-10-29 16:47:562、postman 新增es 索引 Put 请求 http://192.168.1.10:9200/ucas_gis #ucas_gis索引名称 3、postman es 指定索引添加mapping 结构定义 Put 请求 http://192.168.1.10:9200/ucas_gis/gisCertificate/_m.1、postman 删除es 指定索引
Delete请求 http://192.168.1.10:9200/ucas_gis #ucas_gis索引名称
2、postman 新增es 索引
Put 请求 http://192.168.1.10:9200/ucas_gis #ucas_gis索引名称
3、postman es 指定索引添加mapping 结构定义
Put 请求 http://192.168.1.10:9200/ucas_gis/gisCertificate/_mapping # 其中ucas_gis 索引库 gisCertificate索引实体
请求参数mapping:
{ "gisCertificate": { "properties": { "archTitle": { "type": "text", "fields": { "keyword": { "type": "keyword" } }, "analyzer": "ik_max_word" }, "archiveYear": { "type": "text", "store": true, "fields": { "keyword": { "type": "keyword" } } }, "assortNum": { "type": "text", "store": true, "fields": { "keyword": { "type": "keyword" } } }, "createdDt": { "type": "date" }, "devOrgName": { "type": "text", "fields": { "keyword": { "type": "keyword" } }, "analyzer": "ik_max_word" }, "fieldName": { "type": "text", "store": true }, "fieldValue": { "type": "text", "fields": { "keyword": { "type": "keyword" } }, "analyzer": "ik_max_word" }, "individualProjAdd": { "type": "text", "store": true, "fields": { "keyword": { "type": "keyword" } }, "analyzer": "ik_max_word" }, "individualProjName": { "type": "text", "fields": { "keyword": { "type": "keyword" } }, "analyzer": "ik_max_word" }, "individualProjRefenceno": { "type": "text", "fields": { "keyword": { "type": "keyword" } }, "analyzer": "ik_max_word" }, "organizationCode": { "type": "text", "store": true, "fields": { "keyword": { "type": "keyword" } } }, "sid": { "type": "text", "fields": { "keyword": { "type": "keyword" } }, "analyzer": "ik_max_word" } } } }
-
Elasticsearch索引新增字段
2020-12-19 20:24:24最近公司做的一个需求,需要将现已有的50+万数据的索引新增一个字段,之前没有在索引中加过字段,记录一下新增字段的方法。 首先需要有一个已经存在的索引,下面先创建一个索引skus PUT /skus { "settings": { ... -
oracle新增、删除索引以及主键修改
2020-03-03 17:19:28--根据索引名,查询表索引字段 select * from user_ind_columns where index_name='索引名'; --根据表名,查询一张表的索引 select * from user_indexes where table_name='表名'; --根据索引名,查询属于哪张表 ... -
mysql新增索引不锁表
2020-02-19 16:10:04以前每次更新索引 都要十多分钟 后来同事告诉了我一个方法 更新索引不影响查询 我试了一下 还真不锁表 我测试的mysql版本 5.6.27 方法:ALTER TABLE tableName ADD INDEX index_column (column1,column2), ALGORITHM... -
Oracle在线新增索引
2018-10-17 11:55:00Oracle新增索引语法很简单,如果是普通索引的话: create Index IDX_T_WLF on T_WLF(ACTIVITYID,ACTIVETIME) tablespace TBS_VCODE_IDX; 如果是唯一索引的话: create unique Index IDX_T_WLF on T_WLF... -
Solr 新增、更新、删除索引
2019-10-25 09:07:07solr-admin新增索引 [索引中无则新增,有则更新] 第一种方式:在doc标签和field标签中增加权重(boost),增加权重后,可以在搜索的时候做权重过滤。 1 2 3 4 ... -
mysql怎样新增和删除索引
2018-09-13 10:04:58----新增索引 新增语法: 1.使用alter table关键字 create index index_name on table_name (column_list) ; create unique index index_name on table_name (column_list) ; 例子: alter table op_report_cp_... -
elasticsearch使用es-head在已有索引中新增字段以及更新记录
2022-04-18 09:20:221、向索引idx_resource添加image_analyse字段,类型为text 语句: { “properties”:{ "image_analyse":{ "type":"text" } } } 2、向索引中更新某条数据的某个字段 :http://localhost:9200/index/type/id... -
mysql 添加索引 mysql 如何创建和删除索引
2021-12-16 06:20:571.添加PRIMARY KEY(主键索引) mysql>ALTER TABLE table_name ADD PRIMARY KEY ( column ) 2.添加UNIQUE(唯一索引) mysql>ALTER TABLE table_name ADD UNIQUE (column ) 3.添加INDEX(普通索引) mysql>ALTER ... -
mysql添加索引
2021-11-15 02:28:421.添加PRIMARY KEY(主键索引) ALTER TABLE `table_name` ADD PRIMARY KEY (`column`); 2.添加UNIQUE(唯一索引) ALTER TABLE `table_name` ADD UNIQUE (`column`); 3.添加INDEX(普通索引) ALTER TABLE `... -
es -索引的新增删除及更新的原理
2021-01-19 10:03:25世界上并没有完美的程序,但是我们并不因此而沮丧,因为写程序...对要新增的文档分词 遍历所有分词,在索引中查找 如果索引中含有该分词,则在该分词字段增加新文档(即文档id、文档包含字段数即字段在文档中所有位置下. -
sql添加索引
2022-05-31 09:42:21添加索引 -
es新建索引,搜索
2021-11-01 17:22:09} /** * 新增数据到es * * @param indexName 索引名称 * @param data 对象 * @param indexId 索引id */ public boolean add(String indexName, Object data, String indexId) { if (indexName == null || data == ... -
mysql 添加索引语句
2021-01-25 12:23:221.PRIMARYKEY(主键索引)mysql>ALTERTABLE`table_name`ADDPRIMARYKEY (`column`)2.UNIQUE(唯一索引)mysql>ALTERTABLE`table_name`ADDUNIQUE (`column` )3.INDEX(普通索引)mysql>ALTERTABLE`... -
千呼万唤始出来,MySQL 8.0索引三剑客之函数索引
2022-04-10 17:51:33普通索引是对列值或列的前缀值进行索引,而MySQL 8.0.13之后支持函数索引,函数索引是对表中的列执行表达式计算后的结构进行索引,而不是对列或列前缀值。使用函数索引可以对未直接存储在表中的数据进行索引。 函数... -
Oracle 创建索引
2020-12-03 16:07:57Oracle 创建索引 -
Kibana如何添加索引
2021-10-27 14:56:40但是我们在Kinaba上看到的索引(你也可以理解每一份对应的日志)上没有你想要的,你该如何去建立索引去查找日志,具体操作过程如下: 这里假设你的数据都已经添加进去或者是自动收集的,你要做的就是创建一个索引... -
ElasticSearch 使用java代码,实现批量新增、修改、构建索引 Api操作
2020-10-03 18:31:05spring.data.elasticsearch.cluster-name=my-es spring.data.elasticsearch.cluster-nodes=ip:9300 (三) 测试创建索引和删除索引 @Resource private ElasticsearchTemplate esTemplate; @Test public void ... -
MongoDB添加索引的方法
2022-01-20 15:04:08用过数据库的都知道,数据库索引与书籍的索引类似,都是用来帮助快速查找的。 MongoDB的索引跟关系型数据库的索引几乎一致。 1. 索引的创建 mongodb采用ensureIndex来创建索引,如: db.user.... -
oracle的常用sql 表的新增,修改,唯一,索引,主键,备注
2019-09-18 21:17:234.建索引 create index N_APP21_1 on APP21 (AKB020) tablespace DATA pctfree 10 initrans 2 maxtrans 255; 5.eate/Recreate primary, unique and foreign key constraints alter table APP21 ... -
MySQL 8中新增的这三大索引,直接让MySQL起飞了,你竟然还不知道!!(建议收藏)
2021-08-06 08:22:48全网首个透彻讲解MySQL8中隐藏索引、降序索引和函数索引的文章,冰河强烈建议收藏!! -
MySQL添加索引的五种方法
2022-04-27 10:51:52MySQL添加索引的五种方法 索引(Index)是帮助MySQL高效获取数据的数据结构。MySQL索引的建立对于MySQL的高效运行是很重要的,索引可以大大提高MySQL的检索速度。 数据库查询是数据库的最主要功能之一。我们都希望... -
mysql怎么添加索引
2021-02-08 09:03:52在mysql中可以通过使用alter table这个SQL语句来为表中的字段添加索引。1、添加PRIMARY KEY(主键索引)mysql>ALTER TABLE `table_name` ADD PRIMARY KEY ( `column` )2、添加UNIQUE(唯一索引)mysql>ALTER TABLE... -
ES如何创建索引
2022-01-08 10:11:36创建索引 1、创建新的索引(index) PUT indexTest001 2、索引设置 ES 默认提供了好多索引配置选项,参考https://www.elastic.co/guide/en/elasticsearch/reference/5.6/index-modules.html 修改索引设置参考:... -
Spring Boot elasticsearch7.6.2基础操作:创建索引、新增数据、查询数据
2022-04-29 10:47:49Spring Boot elasticsearch7.6.2基础操作:创建索引、新增数据、查询数据 -
mysql添加索引命令
2021-02-03 05:56:371.PRIMARYKEY(主键索引)mysql>ALTERTABLE`table_name`ADDPRIMARYKEY (`column`)2.UNIQUE(唯一索引)mysql>ALTERTABLE`table_name`ADDUNIQUE (`column` )3.INDEX(普通索引)mysql>ALTERTABLE`...