mirror of
https://gitee.com/dromara/easy-es.git
synced 2025-12-06 17:18:57 +08:00
v0.9.13
1.紧急修复1处or().in()导致的缺陷 2.自动托管索引支持异步阻塞和异步非阻塞的配置,默认为异步阻塞. 3.对框架中的日志打印做了优化,解决了部分异常情况下无法正确format日志参数的问题
This commit is contained in:
parent
29cd386fb4
commit
5aedc0bce9
@ -268,7 +268,7 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
||||
throw ExceptionUtils.eee("insert failed, result:%s entity:%s", indexResponse.getResult(), entity);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtils.eee("insert entity:%s exception", e, entity);
|
||||
throw ExceptionUtils.eee("insert entity:%s exception", e, entity.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -302,7 +302,7 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
||||
return ONE;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtils.eee("deleteById exception:%s, id:%s", e, id);
|
||||
throw ExceptionUtils.eee("deleteById exception, id:%s", e, id.toString());
|
||||
}
|
||||
return BaseEsConstants.ZERO;
|
||||
}
|
||||
@ -364,7 +364,7 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
||||
return ONE;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtils.eee("updateById exception,entity:%s", e, entity);
|
||||
throw ExceptionUtils.eee("updateById exception,entity:%s", e, entity.toString());
|
||||
}
|
||||
|
||||
return BaseEsConstants.ZERO;
|
||||
@ -476,7 +476,7 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
||||
public T selectOne(LambdaEsQueryWrapper<T> wrapper) {
|
||||
long count = this.selectCount(wrapper);
|
||||
if (count > ONE && wrapper.size > ONE) {
|
||||
throw ExceptionUtils.eee("fond more than one result: %d , please use limit function to limit 1", count);
|
||||
throw ExceptionUtils.eee("found more than one result: %d , please use limit function to limit 1", count);
|
||||
}
|
||||
|
||||
// 请求es获取数据
|
||||
@ -654,7 +654,7 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
||||
try {
|
||||
searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtils.eee("getSearchHitArray exception,searchRequest:%s", e, searchRequest);
|
||||
throw ExceptionUtils.eee("getSearchHitArray exception,searchRequest:%s", e, searchRequest.toString());
|
||||
}
|
||||
return parseSearchHitArray(searchResponse);
|
||||
}
|
||||
@ -675,7 +675,7 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
||||
try {
|
||||
response = client.search(searchRequest, RequestOptions.DEFAULT);
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtils.eee("getSearchHitArray IOException, searchRequest:%s", e, searchRequest);
|
||||
throw ExceptionUtils.eee("getSearchHitArray IOException, searchRequest:%s", e, searchRequest.toString());
|
||||
}
|
||||
return parseSearchHitArray(response);
|
||||
}
|
||||
@ -744,7 +744,7 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw ExceptionUtils.eee("buildJsonIndexSource exception, entity:%s", e, entity);
|
||||
throw ExceptionUtils.eee("buildJsonIndexSource exception, entity:%s", e, entity.toString());
|
||||
}
|
||||
});
|
||||
|
||||
@ -825,7 +825,7 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtils.eee("bulkRequest exception, msg:%s,cause:%s", e.getMessage(), e.getCause());
|
||||
throw ExceptionUtils.eee("bulkRequest exception", e);
|
||||
}
|
||||
return totalSuccess;
|
||||
}
|
||||
@ -840,7 +840,7 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
||||
return Optional.ofNullable(searchResponse)
|
||||
.map(SearchResponse::getHits)
|
||||
.map(SearchHits::getHits)
|
||||
.orElseThrow(() -> ExceptionUtils.eee("parseSearchHitArray exception, response:%s", searchResponse));
|
||||
.orElseThrow(() -> ExceptionUtils.eee("parseSearchHitArray exception"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -23,6 +23,10 @@ public class GlobalConfig {
|
||||
* process index mode Smoothly by default 索引处理模式 默认开启平滑模式
|
||||
*/
|
||||
private ProcessIndexStrategyEnum processIndexMode = ProcessIndexStrategyEnum.SMOOTHLY;
|
||||
/**
|
||||
* process index blocking main thread true by default 异步处理索引是否阻塞主线程 默认阻塞
|
||||
*/
|
||||
private boolean asyncProcessIndexBlocking = true;
|
||||
/**
|
||||
* is distributed environment true by default 是否分布式环境 默认为是
|
||||
*/
|
||||
|
||||
@ -37,7 +37,7 @@ public class EsQueryTypeUtil {
|
||||
setQueryBuilder(boolQueryBuilder, attachType, termQueryBuilder);
|
||||
} else if (Objects.equals(queryType, TERMS_QUERY.getType())) {
|
||||
// 此处处理由or转入shouldList的in参数
|
||||
TermsQueryBuilder termsQueryBuilder = QueryBuilders.termsQuery(field, value).boost(boost);
|
||||
TermsQueryBuilder termsQueryBuilder = QueryBuilders.termsQuery(field, (Collection<?>)value).boost(boost);
|
||||
setQueryBuilder(boolQueryBuilder, attachType, termsQueryBuilder);
|
||||
} else if (Objects.equals(queryType, MATCH_PHASE.getType())) {
|
||||
// 封装模糊分词查询参数(分词必须按原关键词顺序)
|
||||
|
||||
@ -56,7 +56,7 @@ public class IndexUtils {
|
||||
try {
|
||||
return client.indices().exists(request, RequestOptions.DEFAULT);
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtils.eee("existsIndex exception", indexName, e);
|
||||
throw ExceptionUtils.eee("existsIndex exception indexName: %s", e, indexName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ public class IndexUtils {
|
||||
CreateIndexResponse createIndexResponse = client.indices().create(createIndexRequest, RequestOptions.DEFAULT);
|
||||
return createIndexResponse.isAcknowledged();
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtils.eee("create index exception ", createIndexRequest, e);
|
||||
throw ExceptionUtils.eee("create index exception createIndexRequest: %s ", e, createIndexRequest.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ public class IndexUtils {
|
||||
try {
|
||||
getIndexResponse = client.indices().get(request, RequestOptions.DEFAULT);
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtils.eee("getIndex exception", indexName, e);
|
||||
throw ExceptionUtils.eee("getIndex exception indexName: %s", e, indexName);
|
||||
}
|
||||
return parseGetIndexResponse(getIndexResponse, indexName);
|
||||
}
|
||||
@ -152,7 +152,7 @@ public class IndexUtils {
|
||||
try {
|
||||
client.indices().updateAliases(indicesAliasesRequest, RequestOptions.DEFAULT);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LogUtils.warn("addDefaultAlias exception", e.toString());
|
||||
}
|
||||
|
||||
}
|
||||
@ -180,7 +180,7 @@ public class IndexUtils {
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtils.eee("reindex exception", oldIndexName, releaseIndexName, e);
|
||||
throw ExceptionUtils.eee("reindex exception oldIndexName:%s, releaseIndexName: %s", e, oldIndexName, releaseIndexName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -349,7 +349,7 @@ public class IndexUtils {
|
||||
RequestOptions.DEFAULT);
|
||||
return acknowledgedResponse.isAcknowledged();
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtils.eee("changeAlias exception", oldIndexName, releaseIndexName, e);
|
||||
throw ExceptionUtils.eee("changeAlias exception oldIndexName: %s, releaseIndexName: %s", e, oldIndexName, releaseIndexName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -367,7 +367,7 @@ public class IndexUtils {
|
||||
AcknowledgedResponse acknowledgedResponse = client.indices().delete(deleteIndexRequest, RequestOptions.DEFAULT);
|
||||
return acknowledgedResponse.isAcknowledged();
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtils.eee("deleteIndex exception", indexName, e);
|
||||
throw ExceptionUtils.eee("deleteIndex exception indexName: %s", e, indexName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -498,7 +498,7 @@ public class IndexUtils {
|
||||
* @param client RestHighLevelClient
|
||||
*/
|
||||
public static void supplyAsync(BiFunction<Class<?>, RestHighLevelClient, Boolean> biFunction, Class<?> entityClass, RestHighLevelClient client) {
|
||||
CompletableFuture.supplyAsync(() -> {
|
||||
CompletableFuture<Boolean> completableFuture = CompletableFuture.supplyAsync(() -> {
|
||||
GlobalConfig globalConfig = GlobalConfigCache.getGlobalConfig();
|
||||
if (!globalConfig.isDistributed()) {
|
||||
// 非分布式项目, 直接处理
|
||||
@ -524,7 +524,14 @@ public class IndexUtils {
|
||||
} else {
|
||||
LogUtils.warn("===> Unfortunately, auto process index by Easy-Es failed, please check your configuration");
|
||||
}
|
||||
}).join();
|
||||
});
|
||||
|
||||
// 是否开启阻塞 默认开启 运行测试模块时建议开启阻塞,否则测试用例跑完后,主线程退出,但异步线程可能还没跑完,可能出现死锁
|
||||
// 生产环境或迁移数据量比较大的情况下,可以配置开启非阻塞,这样服务启动更快
|
||||
GlobalConfig globalConfig = GlobalConfigCache.getGlobalConfig();
|
||||
if (globalConfig.isAsyncProcessIndexBlocking()) {
|
||||
completableFuture.join();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,9 +6,11 @@ easy-es:
|
||||
password: WG7WVmuNMtM4GwNYkyWH
|
||||
global-config:
|
||||
process-index-mode: smoothly
|
||||
async-process-index-blocking: true
|
||||
print-dsl: true
|
||||
db-config:
|
||||
map-underscore-to-camel-case: false
|
||||
# table-prefix: dev_
|
||||
id-type: customize
|
||||
field-strategy: not_empty
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user