mirror of
https://gitee.com/dromara/easy-es.git
synced 2025-12-06 17:18:57 +08:00
v2.0.0-beta4
提供多个强大新特性及ISSUE修复
This commit is contained in:
parent
522a4dc89b
commit
db8c94495e
@ -20,9 +20,9 @@ import static org.dromara.easyes.annotation.rely.AnnotationConstants.*;
|
|||||||
@Target(ElementType.FIELD)
|
@Target(ElementType.FIELD)
|
||||||
public @interface HighLight {
|
public @interface HighLight {
|
||||||
/**
|
/**
|
||||||
* 指定的高亮字段名称
|
* 高亮内容映射字段的名称
|
||||||
*
|
*
|
||||||
* @return 高亮字段名称
|
* @return 高亮内容映射字段的名称
|
||||||
*/
|
*/
|
||||||
String mappingField() default "";
|
String mappingField() default "";
|
||||||
|
|
||||||
@ -33,6 +33,13 @@ public @interface HighLight {
|
|||||||
*/
|
*/
|
||||||
int fragmentSize() default DEFAULT_FRAGMENT_SIZE;
|
int fragmentSize() default DEFAULT_FRAGMENT_SIZE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索返回的高亮片段数量,默认全部返回
|
||||||
|
*
|
||||||
|
* @return 高亮片段数量
|
||||||
|
*/
|
||||||
|
int numberOfFragments() default -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 高亮前置标签
|
* 高亮前置标签
|
||||||
*
|
*
|
||||||
|
|||||||
@ -86,6 +86,13 @@ public @interface IndexField {
|
|||||||
*/
|
*/
|
||||||
int ignoreAbove() default -1;
|
int ignoreAbove() default -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于指定浮点数字段的缩放因子 缩放因子用于将浮点数值映射到整数值以进行存储和索引,取值范围是 1 到 10000 针对BigDecimal类型字段,不指定时默认值为 100
|
||||||
|
*
|
||||||
|
* @return 缩放因子
|
||||||
|
*/
|
||||||
|
int scalingFactor() default -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 默认嵌套类
|
* 默认嵌套类
|
||||||
*
|
*
|
||||||
|
|||||||
@ -85,6 +85,7 @@ public @interface IndexName {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据刷新策略
|
* 数据刷新策略
|
||||||
|
*
|
||||||
* @return 具体策略
|
* @return 具体策略
|
||||||
*/
|
*/
|
||||||
RefreshPolicy refreshPolicy() default RefreshPolicy.GLOBAL;
|
RefreshPolicy refreshPolicy() default RefreshPolicy.GLOBAL;
|
||||||
|
|||||||
@ -12,9 +12,9 @@ import org.dromara.easyes.annotation.rely.FieldType;
|
|||||||
**/
|
**/
|
||||||
public @interface InnerIndexField {
|
public @interface InnerIndexField {
|
||||||
/**
|
/**
|
||||||
* 内部字段的前缀,必须指定,否则无存在意义,且不可重名,重名则以首次出现的为准
|
* 内部字段的后缀,必须指定,否则无存在意义,且不可重名,重名则以首次出现的为准
|
||||||
*
|
*
|
||||||
* @return 内部字段的前缀
|
* @return 内部字段的后缀
|
||||||
*/
|
*/
|
||||||
String suffix();
|
String suffix();
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import java.util.Arrays;
|
|||||||
**/
|
**/
|
||||||
public enum FieldType {
|
public enum FieldType {
|
||||||
/**
|
/**
|
||||||
* none Required inside the framework, do not use 框架内部需要,切勿使用,若不慎使用则会被当做keyword类型
|
* none Required inside the framework, do not use 框架内部需要,切勿使用,若不慎使用则会被当做keyword&text类型
|
||||||
*/
|
*/
|
||||||
NONE("none"),
|
NONE("none"),
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -7,7 +7,7 @@ package org.dromara.easyes.annotation.rely;
|
|||||||
**/
|
**/
|
||||||
public enum RefreshPolicy {
|
public enum RefreshPolicy {
|
||||||
/**
|
/**
|
||||||
* 使用全局设置: easy-es.global-config.db-config.refresh-policy
|
* 使用全局设置: easy-es.global-config.db-config.refresh-policy 全局设置默认为不刷新
|
||||||
*/
|
*/
|
||||||
GLOBAL(""),
|
GLOBAL(""),
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -240,4 +240,13 @@ public interface BaseEsConstants {
|
|||||||
String CUSTOM_FILTER = "index.analysis.normalizer.lowercase_normalizer.filter";
|
String CUSTOM_FILTER = "index.analysis.normalizer.lowercase_normalizer.filter";
|
||||||
String NORMALIZER = "normalizer";
|
String NORMALIZER = "normalizer";
|
||||||
String LOWERCASE_NORMALIZER = "lowercase_normalizer";
|
String LOWERCASE_NORMALIZER = "lowercase_normalizer";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认缩放因子
|
||||||
|
*/
|
||||||
|
Integer DEFAULT_SCALING_FACTOR = 100;
|
||||||
|
/**
|
||||||
|
* 缩放因子索引字段名称
|
||||||
|
*/
|
||||||
|
String SCALING_FACTOR_FIELD = "scaling_factor";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,6 +36,10 @@ public class EntityFieldInfo {
|
|||||||
* es中的字段名
|
* es中的字段名
|
||||||
*/
|
*/
|
||||||
private String mappingColumn;
|
private String mappingColumn;
|
||||||
|
/**
|
||||||
|
* 缩放因子
|
||||||
|
*/
|
||||||
|
private Integer scalingFactor;
|
||||||
/**
|
/**
|
||||||
* 字段在es中的存储类型
|
* 字段在es中的存储类型
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -27,6 +27,10 @@ public class EsIndexParam {
|
|||||||
* 对 text 字段进行聚合处理
|
* 对 text 字段进行聚合处理
|
||||||
*/
|
*/
|
||||||
private Boolean fieldData;
|
private Boolean fieldData;
|
||||||
|
/**
|
||||||
|
* 浮点数字段的缩放因子
|
||||||
|
*/
|
||||||
|
private Integer scalingFactor;
|
||||||
/**
|
/**
|
||||||
* 分词器
|
* 分词器
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
package org.dromara.easyes.core.biz;
|
package org.dromara.easyes.core.biz;
|
||||||
|
|
||||||
import org.dromara.easyes.annotation.rely.HighLightTypeEnum;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import org.dromara.easyes.annotation.rely.HighLightTypeEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 高亮参数
|
* 高亮参数
|
||||||
@ -10,12 +10,16 @@ import lombok.Data;
|
|||||||
* Copyright © 2021 xpc1024 All Rights Reserved
|
* Copyright © 2021 xpc1024 All Rights Reserved
|
||||||
**/
|
**/
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@Accessors(chain = true)
|
||||||
public class HighLightParam {
|
public class HighLightParam {
|
||||||
/**
|
/**
|
||||||
* 高亮字段截取长度,默认为100
|
* 高亮字段截取长度,默认为100
|
||||||
*/
|
*/
|
||||||
private int fragmentSize;
|
private Integer fragmentSize;
|
||||||
|
/**
|
||||||
|
* 搜索返回的高亮片段数量 默认全部返回
|
||||||
|
*/
|
||||||
|
private Integer numberOfFragments;
|
||||||
/**
|
/**
|
||||||
* 前置标签
|
* 前置标签
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -4,8 +4,8 @@ package org.dromara.easyes.core.config;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.dromara.easyes.annotation.rely.FieldStrategy;
|
import org.dromara.easyes.annotation.rely.FieldStrategy;
|
||||||
import org.dromara.easyes.annotation.rely.IdType;
|
import org.dromara.easyes.annotation.rely.IdType;
|
||||||
import org.dromara.easyes.common.enums.ProcessIndexStrategyEnum;
|
|
||||||
import org.dromara.easyes.annotation.rely.RefreshPolicy;
|
import org.dromara.easyes.annotation.rely.RefreshPolicy;
|
||||||
|
import org.dromara.easyes.common.enums.ProcessIndexStrategyEnum;
|
||||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||||
|
|
||||||
import static org.dromara.easyes.common.constants.BaseEsConstants.EMPTY_STR;
|
import static org.dromara.easyes.common.constants.BaseEsConstants.EMPTY_STR;
|
||||||
@ -86,6 +86,10 @@ public class GlobalConfig {
|
|||||||
* Batch update threshold 10000 by default 批量更新阈值 默认值为1万
|
* Batch update threshold 10000 by default 批量更新阈值 默认值为1万
|
||||||
*/
|
*/
|
||||||
private Integer batchUpdateThreshold = 10000;
|
private Integer batchUpdateThreshold = 10000;
|
||||||
|
/**
|
||||||
|
* Whether to turn on aggregation to return result set data, and turning off aggregation by default, to return only the aggregation results in the bucket can improve query efficiency. 是否开启聚合返回结果集数据,默认关闭 聚合仅返回桶中的聚合结果 可以提升查询效率
|
||||||
|
*/
|
||||||
|
private boolean enableAggHits = false;
|
||||||
/**
|
/**
|
||||||
* Whether to intelligently add the. keyword suffix to the field. This configuration is enabled by default. The field type is KEYWORD only for annotation configuration_ The String field of TEXT or unconfigured type takes effect and only takes effect when the query requires that the field be of keyword type, so it is called smart! 是否智能为字段添加.keyword后缀 默认开启 此配置仅对注解配置字段类型为KEYWORD_TEXT或未配置类型的String字段生效,并且只会在查询要求该字段必须为keyword类型的查询中才生效,因此谓之智能!
|
* Whether to intelligently add the. keyword suffix to the field. This configuration is enabled by default. The field type is KEYWORD only for annotation configuration_ The String field of TEXT or unconfigured type takes effect and only takes effect when the query requires that the field be of keyword type, so it is called smart! 是否智能为字段添加.keyword后缀 默认开启 此配置仅对注解配置字段类型为KEYWORD_TEXT或未配置类型的String字段生效,并且只会在查询要求该字段必须为keyword类型的查询中才生效,因此谓之智能!
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -10,10 +10,10 @@ import lombok.SneakyThrows;
|
|||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
import org.dromara.easyes.annotation.rely.FieldStrategy;
|
import org.dromara.easyes.annotation.rely.FieldStrategy;
|
||||||
import org.dromara.easyes.annotation.rely.IdType;
|
import org.dromara.easyes.annotation.rely.IdType;
|
||||||
|
import org.dromara.easyes.annotation.rely.RefreshPolicy;
|
||||||
import org.dromara.easyes.common.constants.BaseEsConstants;
|
import org.dromara.easyes.common.constants.BaseEsConstants;
|
||||||
import org.dromara.easyes.common.enums.EsQueryTypeEnum;
|
import org.dromara.easyes.common.enums.EsQueryTypeEnum;
|
||||||
import org.dromara.easyes.common.enums.MethodEnum;
|
import org.dromara.easyes.common.enums.MethodEnum;
|
||||||
import org.dromara.easyes.annotation.rely.RefreshPolicy;
|
|
||||||
import org.dromara.easyes.common.utils.*;
|
import org.dromara.easyes.common.utils.*;
|
||||||
import org.dromara.easyes.core.biz.*;
|
import org.dromara.easyes.core.biz.*;
|
||||||
import org.dromara.easyes.core.cache.BaseCache;
|
import org.dromara.easyes.core.cache.BaseCache;
|
||||||
@ -390,7 +390,7 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
|||||||
DeleteByQueryRequest request = new DeleteByQueryRequest(getIndexNames(wrapper.indexNames));
|
DeleteByQueryRequest request = new DeleteByQueryRequest(getIndexNames(wrapper.indexNames));
|
||||||
EntityInfo entityInfo = EntityInfoHelper.getEntityInfo(entityClass);
|
EntityInfo entityInfo = EntityInfoHelper.getEntityInfo(entityClass);
|
||||||
Optional.ofNullable(entityInfo)
|
Optional.ofNullable(entityInfo)
|
||||||
.flatMap(i->Optional.ofNullable(i.getMaxResultWindow()))
|
.flatMap(i -> Optional.ofNullable(i.getMaxResultWindow()))
|
||||||
.ifPresent(request::setBatchSize);
|
.ifPresent(request::setBatchSize);
|
||||||
if (RefreshPolicy.IMMEDIATE.getValue().equals(getRefreshPolicy())) {
|
if (RefreshPolicy.IMMEDIATE.getValue().equals(getRefreshPolicy())) {
|
||||||
request.setRefresh(true);
|
request.setRefresh(true);
|
||||||
@ -1058,7 +1058,7 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
|||||||
Map<String, String> highlightFieldMap = getHighlightFieldMap();
|
Map<String, String> highlightFieldMap = getHighlightFieldMap();
|
||||||
Map<String, HighlightField> highlightFields = searchHit.getHighlightFields();
|
Map<String, HighlightField> highlightFields = searchHit.getHighlightFields();
|
||||||
highlightFields.forEach((key, value) -> {
|
highlightFields.forEach((key, value) -> {
|
||||||
String highLightValue = Arrays.stream(value.getFragments()).findFirst().map(Text::string).orElse(BaseEsConstants.EMPTY_STR);
|
String highLightValue = Arrays.stream(value.getFragments()).map(Text::string).collect(Collectors.joining());
|
||||||
setHighlightValue(entity, highlightFieldMap.get(key), highLightValue);
|
setHighlightValue(entity, highlightFieldMap.get(key), highLightValue);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1495,7 +1495,9 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
|||||||
* @return 刷新策略
|
* @return 刷新策略
|
||||||
*/
|
*/
|
||||||
private String getRefreshPolicy() {
|
private String getRefreshPolicy() {
|
||||||
return EntityInfoHelper.getEntityInfo(entityClass).getRefreshPolicy().getValue();
|
// 防止傻狍子用户在全局中把刷新策略修改为GLOBAL
|
||||||
|
final RefreshPolicy refreshPolicy = EntityInfoHelper.getEntityInfo(entityClass).getRefreshPolicy();
|
||||||
|
return refreshPolicy.equals(RefreshPolicy.GLOBAL) ? RefreshPolicy.NONE.getValue() : refreshPolicy.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -416,6 +416,7 @@ public class WrapperProcessor {
|
|||||||
highlightBuilder.fragmentSize(highLightParam.getFragmentSize());
|
highlightBuilder.fragmentSize(highLightParam.getFragmentSize());
|
||||||
highlightBuilder.preTags(highLightParam.getPreTag());
|
highlightBuilder.preTags(highLightParam.getPreTag());
|
||||||
highlightBuilder.postTags(highLightParam.getPostTag());
|
highlightBuilder.postTags(highLightParam.getPostTag());
|
||||||
|
Optional.ofNullable(highLightParam.getNumberOfFragments()).ifPresent(highlightBuilder::numOfFragments);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
searchSourceBuilder.highlighter(highlightBuilder);
|
searchSourceBuilder.highlighter(highlightBuilder);
|
||||||
@ -534,6 +535,11 @@ public class WrapperProcessor {
|
|||||||
|
|
||||||
}
|
}
|
||||||
Optional.ofNullable(root).ifPresent(searchSourceBuilder::aggregation);
|
Optional.ofNullable(root).ifPresent(searchSourceBuilder::aggregation);
|
||||||
|
|
||||||
|
if (!GlobalConfigCache.getGlobalConfig().getDbConfig().isEnableAggHits()) {
|
||||||
|
// 配置关闭了聚合返回结果集Hits, 可提升查询效率
|
||||||
|
wrapper.size = ZERO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -310,6 +310,11 @@ public class EntityInfoHelper {
|
|||||||
mappingColumn = initMappingColumnMapAndGet(dbConfig, entityInfo, field);
|
mappingColumn = initMappingColumnMapAndGet(dbConfig, entityInfo, field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 缩放因子
|
||||||
|
if (MINUS_ONE != indexField.scalingFactor()) {
|
||||||
|
entityFieldInfo.setScalingFactor(indexField.scalingFactor());
|
||||||
|
}
|
||||||
|
|
||||||
// 日期格式化
|
// 日期格式化
|
||||||
if (StringUtils.isNotBlank(indexField.dateFormat())) {
|
if (StringUtils.isNotBlank(indexField.dateFormat())) {
|
||||||
entityFieldInfo.setDateFormat(indexField.dateFormat());
|
entityFieldInfo.setDateFormat(indexField.dateFormat());
|
||||||
@ -390,8 +395,15 @@ public class EntityInfoHelper {
|
|||||||
entityInfo.getHighlightFieldMap().putIfAbsent(realHighLightField, mappingField);
|
entityInfo.getHighlightFieldMap().putIfAbsent(realHighLightField, mappingField);
|
||||||
|
|
||||||
// 封装高亮参数
|
// 封装高亮参数
|
||||||
HighLightParam highLightParam =
|
HighLightParam highLightParam = new HighLightParam();
|
||||||
new HighLightParam(highLight.fragmentSize(), highLight.preTag(), highLight.postTag(), realHighLightField, highLight.highLightType());
|
highLightParam.setFragmentSize(highLight.fragmentSize())
|
||||||
|
.setPreTag(highLight.preTag())
|
||||||
|
.setPostTag(highLight.postTag())
|
||||||
|
.setHighLightField(realHighLightField)
|
||||||
|
.setHighLightType(highLight.highLightType());
|
||||||
|
if (MINUS_ONE != highLight.numberOfFragments() && highLight.numberOfFragments() > ZERO) {
|
||||||
|
highLightParam.setNumberOfFragments(highLight.numberOfFragments());
|
||||||
|
}
|
||||||
entityInfo.getHighLightParams().add(highLightParam);
|
entityInfo.getHighLightParams().add(highLightParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,6 +470,11 @@ public class EntityInfoHelper {
|
|||||||
entityFieldInfo.setDateFormat(indexField.dateFormat());
|
entityFieldInfo.setDateFormat(indexField.dateFormat());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 缩放因子
|
||||||
|
if (MINUS_ONE != indexField.scalingFactor()) {
|
||||||
|
entityFieldInfo.setScalingFactor(indexField.scalingFactor());
|
||||||
|
}
|
||||||
|
|
||||||
// 处理内部字段
|
// 处理内部字段
|
||||||
InnerIndexField[] innerIndexFields = Optional.ofNullable(multiIndexField).map(MultiIndexField::otherIndexFields).orElse(null);
|
InnerIndexField[] innerIndexFields = Optional.ofNullable(multiIndexField).map(MultiIndexField::otherIndexFields).orElse(null);
|
||||||
processInnerField(innerIndexFields, entityFieldInfo);
|
processInnerField(innerIndexFields, entityFieldInfo);
|
||||||
@ -497,7 +514,7 @@ public class EntityInfoHelper {
|
|||||||
innerFieldInfo.setFieldType(innerField.fieldType());
|
innerFieldInfo.setFieldType(innerField.fieldType());
|
||||||
innerFieldInfo.setAnalyzer(innerField.analyzer());
|
innerFieldInfo.setAnalyzer(innerField.analyzer());
|
||||||
innerFieldInfo.setSearchAnalyzer(innerField.searchAnalyzer());
|
innerFieldInfo.setSearchAnalyzer(innerField.searchAnalyzer());
|
||||||
if (innerField.ignoreAbove() > 0){
|
if (innerField.ignoreAbove() > ZERO) {
|
||||||
innerFieldInfo.setIgnoreAbove(innerField.ignoreAbove());
|
innerFieldInfo.setIgnoreAbove(innerField.ignoreAbove());
|
||||||
}
|
}
|
||||||
innerFieldInfoList.add(innerFieldInfo);
|
innerFieldInfoList.add(innerFieldInfo);
|
||||||
@ -703,4 +720,5 @@ public class EntityInfoHelper {
|
|||||||
}
|
}
|
||||||
return mappingColumn;
|
return mappingColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -403,7 +403,8 @@ public class IndexUtils {
|
|||||||
* @param indexParamList 索引参数列表
|
* @param indexParamList 索引参数列表
|
||||||
* @return info信息
|
* @return info信息
|
||||||
*/
|
*/
|
||||||
private static Map<String, Object> initInfo(EntityInfo entityInfo, GlobalConfig.DbConfig dbConfig, Map<String, Object> properties, List<EsIndexParam> indexParamList) {
|
private static Map<String, Object> initInfo(EntityInfo entityInfo, GlobalConfig.DbConfig dbConfig,
|
||||||
|
Map<String, Object> properties, List<EsIndexParam> indexParamList) {
|
||||||
indexParamList.forEach(indexParam -> {
|
indexParamList.forEach(indexParam -> {
|
||||||
Map<String, Object> info = new HashMap<>();
|
Map<String, Object> info = new HashMap<>();
|
||||||
Optional.ofNullable(indexParam.getDateFormat()).ifPresent(format -> info.put(BaseEsConstants.FORMAT, indexParam.getDateFormat()));
|
Optional.ofNullable(indexParam.getDateFormat()).ifPresent(format -> info.put(BaseEsConstants.FORMAT, indexParam.getDateFormat()));
|
||||||
@ -444,6 +445,12 @@ public class IndexUtils {
|
|||||||
MyOptional.ofNullable(indexParam.getFieldData()).ifTrue(fieldData -> info.put(FIELD_DATA, fieldData));
|
MyOptional.ofNullable(indexParam.getFieldData()).ifTrue(fieldData -> info.put(FIELD_DATA, fieldData));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// scaled_float数据类型,须设置scaling_factor
|
||||||
|
if (FieldType.SCALED_FLOAT.getType().equals(indexParam.getFieldType())) {
|
||||||
|
int scalingFactor = Optional.ofNullable(indexParam.getScalingFactor()).orElse(DEFAULT_SCALING_FACTOR);
|
||||||
|
info.put(SCALING_FACTOR_FIELD, scalingFactor);
|
||||||
|
}
|
||||||
|
|
||||||
// 设置权重
|
// 设置权重
|
||||||
Optional.ofNullable(indexParam.getBoost()).ifPresent(boost -> info.put(BOOST_KEY, indexParam.getBoost()));
|
Optional.ofNullable(indexParam.getBoost()).ifPresent(boost -> info.put(BOOST_KEY, indexParam.getBoost()));
|
||||||
|
|
||||||
@ -607,6 +614,7 @@ public class IndexUtils {
|
|||||||
}
|
}
|
||||||
esIndexParam.setFieldName(field.getMappingColumn());
|
esIndexParam.setFieldName(field.getMappingColumn());
|
||||||
esIndexParam.setDateFormat(field.getDateFormat());
|
esIndexParam.setDateFormat(field.getDateFormat());
|
||||||
|
esIndexParam.setScalingFactor(field.getScalingFactor());
|
||||||
if (FieldType.NESTED.equals(field.getFieldType())) {
|
if (FieldType.NESTED.equals(field.getFieldType())) {
|
||||||
esIndexParam.setNestedClass(entityInfo.getPathClassMap().get(field.getColumn()));
|
esIndexParam.setNestedClass(entityInfo.getPathClassMap().get(field.getColumn()));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import lombok.experimental.Accessors;
|
|||||||
import org.dromara.easyes.annotation.*;
|
import org.dromara.easyes.annotation.*;
|
||||||
import org.dromara.easyes.annotation.rely.*;
|
import org.dromara.easyes.annotation.rely.*;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,7 +37,7 @@ public class Document {
|
|||||||
/**
|
/**
|
||||||
* 文档内容,指定了类型及存储/查询分词器
|
* 文档内容,指定了类型及存储/查询分词器
|
||||||
*/
|
*/
|
||||||
@HighLight(mappingField = "highlightContent", fragmentSize = 2)
|
@HighLight(mappingField = "highlightContent", fragmentSize = 10, numberOfFragments = 2)
|
||||||
@IndexField(fieldType = FieldType.TEXT, analyzer = Analyzer.IK_SMART, searchAnalyzer = Analyzer.IK_SMART)
|
@IndexField(fieldType = FieldType.TEXT, analyzer = Analyzer.IK_SMART, searchAnalyzer = Analyzer.IK_SMART)
|
||||||
private String content;
|
private String content;
|
||||||
/**
|
/**
|
||||||
@ -126,6 +127,12 @@ public class Document {
|
|||||||
@Distance(decimalPlaces = 2)
|
@Distance(decimalPlaces = 2)
|
||||||
private Double distance2;
|
private Double distance2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 浮点数,可指定缩放因子,不指定默认值为100
|
||||||
|
*/
|
||||||
|
@IndexField(fieldType = FieldType.SCALED_FLOAT, scalingFactor = 101)
|
||||||
|
private BigDecimal bigNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 复合字段,此注解和SpringData中的MultiField用法类似 适用于对同一个字段通过多种分词器检索的场景
|
* 复合字段,此注解和SpringData中的MultiField用法类似 适用于对同一个字段通过多种分词器检索的场景
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -38,6 +38,7 @@ import org.junit.jupiter.api.*;
|
|||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -75,7 +76,7 @@ public class AllTest {
|
|||||||
document.setEsId("1");
|
document.setEsId("1");
|
||||||
document.setCaseTest("Test");
|
document.setCaseTest("Test");
|
||||||
document.setTitle("测试文档1");
|
document.setTitle("测试文档1");
|
||||||
document.setContent("测试内容1");
|
document.setContent("测试内容1我是大家发达酸辣粉家里都是测试阿拉拉肥发的是就测试时风刀霜剑阿凯刘非打死了交付率及时点法律就反倒是测测试初拉力肌肥大来极氪吉利发送代理费逻辑逻辑发骚鸡,测试发力了哦哦我");
|
||||||
document.setCreator("老汉1");
|
document.setCreator("老汉1");
|
||||||
document.setIpAddress("192.168.1.1");
|
document.setIpAddress("192.168.1.1");
|
||||||
document.setLocation("40.171975,116.587105");
|
document.setLocation("40.171975,116.587105");
|
||||||
@ -87,9 +88,9 @@ public class AllTest {
|
|||||||
document.setStarNum(1);
|
document.setStarNum(1);
|
||||||
document.setMultiField("葡萄糖酸钙口服溶液");
|
document.setMultiField("葡萄糖酸钙口服溶液");
|
||||||
document.setEnglish("Calcium Gluconate");
|
document.setEnglish("Calcium Gluconate");
|
||||||
|
document.setBigNum(new BigDecimal("66.66"));
|
||||||
int successCount = documentMapper.insert(document);
|
int successCount = documentMapper.insert(document);
|
||||||
Assertions.assertEquals(successCount, 1);
|
Assertions.assertEquals(successCount, 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -956,5 +957,4 @@ public class AllTest {
|
|||||||
documentMapper.selectList(wrapper);
|
documentMapper.selectList(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
1
pom.xml
1
pom.xml
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<junit.version>5.4.0</junit.version>
|
<junit.version>5.4.0</junit.version>
|
||||||
<!-- <spring-boot.version>2.6.10</spring-boot.version>-->
|
|
||||||
<spring-boot.version>2.7.0</spring-boot.version>
|
<spring-boot.version>2.7.0</spring-boot.version>
|
||||||
<commons-lang3>3.9</commons-lang3>
|
<commons-lang3>3.9</commons-lang3>
|
||||||
</properties>
|
</properties>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user