//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package org.dromara.easyes.core.kernel;
import co.elastic.clients.elasticsearch._types.DistanceUnit;
import co.elastic.clients.elasticsearch._types.GeoDistanceType;
import co.elastic.clients.elasticsearch._types.GeoLocation;
import co.elastic.clients.elasticsearch._types.GeoShapeRelation;
import co.elastic.clients.elasticsearch._types.SortOptions;
import co.elastic.clients.elasticsearch._types.SortOrder;
import co.elastic.clients.elasticsearch._types.mapping.TypeMapping;
import co.elastic.clients.elasticsearch._types.query_dsl.ChildScoreMode;
import co.elastic.clients.elasticsearch._types.query_dsl.Operator;
import co.elastic.clients.elasticsearch.core.SearchRequest;
import co.elastic.clients.elasticsearch.indices.IndexSettings;
import co.elastic.clients.util.NamedValue;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Stack;
import java.util.UUID;
import java.util.function.BiPredicate;
import java.util.function.Consumer;
import java.util.function.Predicate;
import org.dromara.easyes.annotation.rely.FieldType;
import org.dromara.easyes.common.enums.AggregationTypeEnum;
import org.dromara.easyes.common.enums.EsQueryTypeEnum;
import org.dromara.easyes.common.enums.OrderTypeEnum;
import org.dromara.easyes.common.utils.ArrayUtils;
import org.dromara.easyes.common.utils.Assert;
import org.dromara.easyes.common.utils.CollectionUtils;
import org.dromara.easyes.common.utils.ExceptionUtils;
import org.dromara.easyes.common.utils.StringUtils;
import org.dromara.easyes.core.biz.AggregationParam;
import org.dromara.easyes.core.biz.BaseSortParam;
import org.dromara.easyes.core.biz.EntityFieldInfo;
import org.dromara.easyes.core.biz.EsIndexParam;
import org.dromara.easyes.core.biz.EsUpdateParam;
import org.dromara.easyes.core.biz.OrderByParam;
import org.dromara.easyes.core.biz.Param;
import org.dromara.easyes.core.conditions.function.Compare;
import org.dromara.easyes.core.conditions.function.Func;
import org.dromara.easyes.core.conditions.function.Geo;
import org.dromara.easyes.core.conditions.function.Index;
import org.dromara.easyes.core.conditions.function.Join;
import org.dromara.easyes.core.conditions.function.Nested;
import org.dromara.easyes.core.conditions.function.Query;
import org.dromara.easyes.core.conditions.function.Update;
import org.dromara.easyes.core.toolkit.EntityInfoHelper;
import org.dromara.easyes.core.toolkit.GeoUtils;
import org.elasticsearch.geometry.Geometry;
public abstract class AbstractWrapper<T, R, Children extends AbstractWrapper<T, R, Children>> extends Wrapper<T> implements Compare<Children, R>, Nested<Children, Children>, Func<Children, R>, Join<Children>, Geo<Children, R>, Query<Children, T, R>, Update<Children, R>, Index<Children, R> {
protected final Children typedThis = this;
protected int level;
protected String parentId;
protected EsQueryTypeEnum prevQueryType;
protected Stack<String> parentIdStack;
protected LinkedList<EsQueryTypeEnum> prevQueryTypeQueue;
public AbstractWrapper() {
}
public Children setEntity(T entity) {
this.entity = entity;
this.initEntityClass();
return this.typedThis;
}
public Children setEntityClass(Class<T> entityClass) {
this.entityClass = entityClass;
this.initEntityClass();
return this.typedThis;
}
protected void initEntityClass() {
if (this.entityClass == null && this.entity != null) {
this.entityClass = this.entity.getClass();
}
}
protected Class<T> getCheckEntityClass() {
Assert.notNull(this.entityClass, "entityClass must not null,please set entity before use this method!");
return this.entityClass;
}
protected final void initNeed() {
this.baseSortParams = new ArrayList();
this.aggregationParamList = new ArrayList();
this.paramQueue = new LinkedList();
this.prevQueryType = EsQueryTypeEnum.NESTED_AND;
this.parentIdStack = new Stack();
this.prevQueryTypeQueue = new LinkedList();
}
public <V> Children allEq(boolean condition, Map<String, V> params) {
if (condition && CollectionUtils.isNotEmpty(params)) {
params.forEach(this::eq);
}
return this.typedThis;
}
public <V> Children allEq(boolean condition, BiPredicate<String, V> filter, Map<String, V> params) {
if (condition && CollectionUtils.isNotEmpty(params)) {
params.forEach((k, v) -> {
if (filter.test(k, v) && StringUtils.checkValNotNull(v)) {
this.eq(k, v);
}
});
}
return this.typedThis;
}
public Children eq(boolean condition, String column, Object val, Float boost) {
return this.addParam(condition, EsQueryTypeEnum.TERM, column, val, boost);
}
public Children and(boolean condition, Consumer<Children> consumer) {
return this.addNested(condition, EsQueryTypeEnum.NESTED_AND, consumer);
}
public Children or(boolean condition, Consumer<Children> consumer) {
return this.addNested(condition, EsQueryTypeEnum.NESTED_OR, consumer);
}
public Children or(boolean condition) {
for(int i = this.paramQueue.size() - 1; i >= 0; --i) {
Param param = (Param)this.paramQueue.get(i);
if (Objects.equals(this.level, param.getLevel())) {
param.setPrevQueryType(EsQueryTypeEnum.NESTED_OR);
break;
}
}
return this.addParam(condition, EsQueryTypeEnum.OR, (String)null, (Object)null, (Float)null);
}
public Children must(boolean condition, Consumer<Children> consumer) {
return this.addNested(condition, EsQueryTypeEnum.NESTED_AND, consumer);
}
public Children should(boolean condition, Consumer<Children> consumer) {
return this.addNested(condition, EsQueryTypeEnum.NESTED_OR, consumer);
}
public Children filter(boolean condition, Consumer<Children> consumer) {
return this.addNested(condition, EsQueryTypeEnum.NESTED_FILTER, consumer);
}
public Children filter(boolean condition) {
return this.addParam(condition, EsQueryTypeEnum.FILTER, (String)null, (Object)null, (Float)null);
}
public Children not(boolean condition) {
return this.addParam(condition, EsQueryTypeEnum.NOT, (String)null, (Object)null, (Float)null);
}
public Children not(boolean condition, Consumer<Children> consumer) {
return this.addNested(condition, EsQueryTypeEnum.NESTED_NOT, consumer);
}
public Children nested(boolean condition, String path, Consumer<Children> consumer, ChildScoreMode scoreMode) {
return this.addNested(condition, path, scoreMode, consumer);
}
public Children match(boolean condition, String column, Object val, Float boost) {
return this.addParam(condition, EsQueryTypeEnum.MATCH, column, val, boost);
}
public Children hasChild(boolean condition, String type, Consumer<Children> consumer, ChildScoreMode scoreMode) {
return this.addJoin(condition, EsQueryTypeEnum.HAS_CHILD, type, scoreMode, consumer);
}
public Children hasParent(boolean condition, String parentType, Consumer<Children> consumer, boolean score) {
return this.addJoin(condition, EsQueryTypeEnum.HAS_PARENT, parentType, score, consumer);
}
public Children parentId(boolean condition, Object parentId, String type, Float boost) {
if (condition) {
Assert.notNull(parentId, "parentId could not be null");
}
return this.addParam(condition, EsQueryTypeEnum.PARENT_ID, type, parentId, boost);
}
public Children matchPhrase(boolean condition, String column, Object val, Float boost) {
return this.addParam(condition, EsQueryTypeEnum.MATCH_PHRASE, column, val, boost);
}
public Children matchAllQuery(boolean condition, Float boost) {
return this.addParam(condition, EsQueryTypeEnum.MATCH_ALL, (String)null, (Object)null, boost);
}
public Children matchPhrasePrefixQuery(boolean condition, String column, Object val, int maxExpansions, Float boost) {
return this.addParam(condition, (EsQueryTypeEnum)EsQueryTypeEnum.MATCH_PHRASE_PREFIX, (String)column, val, maxExpansions, (Object)null, boost);
}
@SafeVarargs
public final Children multiMatchQuery(boolean condition, Object val, Operator operator, int minimumShouldMatch, Float boost, String... columns) {
return this.addParam(condition, val, operator, minimumShouldMatch, boost, columns);
}
public Children queryStringQuery(boolean condition, String queryString, Float boost) {
return this.addParam(condition, EsQueryTypeEnum.QUERY_STRING, queryString, (Object)null, boost);
}
public Children prefixQuery(boolean condition, String column, String prefix, Float boost) {
if (condition) {
Assert.notBlank(prefix, "prefix can't be blank");
}
return this.addParam(condition, EsQueryTypeEnum.PREFIX, column, prefix, boost);
}
public Children gt(boolean condition, String column, Object val, ZoneId timeZone, String format, Float boost) {
return this.addParam(condition, (EsQueryTypeEnum)EsQueryTypeEnum.GT, (String)column, val, timeZone, format, boost);
}
public Children ge(boolean condition, String column, Object val, ZoneId timeZone, String format, Float boost) {
return this.addParam(condition, (EsQueryTypeEnum)EsQueryTypeEnum.GE, (String)column, val, timeZone, format, boost);
}
public Children lt(boolean condition, String column, Object val, ZoneId timeZone, String format, Float boost) {
return this.addParam(condition, (EsQueryTypeEnum)EsQueryTypeEnum.LT, (String)column, val, timeZone, format, boost);
}
public Children le(boolean condition, String column, Object val, ZoneId timeZone, String format, Float boost) {
return this.addParam(condition, (EsQueryTypeEnum)EsQueryTypeEnum.LE, (String)column, val, timeZone, format, boost);
}
public Children between(boolean condition, String column, Object from, Object to, ZoneId timeZone, String format, Float boost) {
return this.addParam(condition, (String)column, (Object)from, to, timeZone, format, boost);
}
public Children like(boolean condition, String column, Object val, Float boost) {
val = Optional.ofNullable(val).map((v) -> {
return "*" + v + "*";
}).orElse("*");
return this.addParam(condition, EsQueryTypeEnum.WILDCARD, column, val, boost);
}
public Children likeLeft(boolean condition, String column, Object val, Float boost) {
val = Optional.ofNullable(val).map((v) -> {
return "*" + v;
}).orElse("*");
return this.addParam(condition, EsQueryTypeEnum.WILDCARD, column, val, boost);
}
public Children likeRight(boolean condition, String column, Object val, Float boost) {
val = Optional.ofNullable(val).map((v) -> {
return v + "*";
}).orElse("*");
return this.addParam(condition, EsQueryTypeEnum.WILDCARD, column, val, boost);
}
public Children in(boolean condition, String column, Collection<?> coll, Float boost) {
return CollectionUtils.isEmpty(coll) ? this.typedThis : this.addParam(condition, EsQueryTypeEnum.TERMS, column, coll, boost);
}
public Children exists(boolean condition, String column, Float boost) {
return this.addParam(condition, EsQueryTypeEnum.EXISTS, column, (Object)null, boost);
}
public Children geoBoundingBox(boolean condition, String column, String topLeft, String bottomRight, Float boost) {
if (condition) {
Assert.notBlank(topLeft, "TopLeft must not be null in geoBoundingBox query");
Assert.notBlank(bottomRight, "BottomRight must not be null in geoBoundingBox query");
return this.geoBoundingBox(true, column, GeoUtils.create(topLeft), GeoUtils.create(bottomRight), boost);
} else {
return this.typedThis;
}
}
public Children geoBoundingBox(boolean condition, String column, GeoLocation topLeft, GeoLocation bottomRight, Float boost) {
if (condition) {
Assert.notNull(topLeft, "TopLeft point must not be null in geoBoundingBox query");
Assert.notNull(bottomRight, "BottomRight point must not be null in geoBoundingBox query");
}
return this.addParam(condition, (EsQueryTypeEnum)EsQueryTypeEnum.GEO_BOUNDING_BOX, (String)column, (Object)null, topLeft, bottomRight, boost);
}
public Children geoDistance(boolean condition, String column, Double distance, DistanceUnit distanceUnit, GeoLocation centralGeoLocation, Float boost) {
if (condition) {
Assert.notNull(distance, "Distance must not be null in geoDistance query");
Assert.notNull(distanceUnit, "Distance unit must not be null in geoDistance query");
Assert.notNull(centralGeoLocation, "CentralGeoLocation must not be null in geoDistance query");
}
return this.addParam(condition, (EsQueryTypeEnum)EsQueryTypeEnum.GEO_DISTANCE, (String)column, distance, distanceUnit, centralGeoLocation, boost);
}
public Children geoDistance(boolean condition, String column, Double distance, DistanceUnit distanceUnit, String centralGeoLocation, Float boost) {
if (condition) {
Assert.notBlank(centralGeoLocation, "centralGeoLocation must not be null in geoDistance query");
return this.geoDistance(true, column, distance, distanceUnit, GeoUtils.create(centralGeoLocation), boost);
} else {
return this.typedThis;
}
}
public Children geoDistance(boolean condition, String column, String distance, GeoLocation centralGeoLocation, Float boost) {
if (condition) {
Assert.notBlank(distance, "Distance must not be null in geoDistance query");
Assert.notNull(centralGeoLocation, "CentralGeoLocation must not be null in geoDistance query");
}
return this.addParam(condition, (EsQueryTypeEnum)EsQueryTypeEnum.GEO_DISTANCE, (String)column, distance, (Object)null, centralGeoLocation, boost);
}
public Children geoDistance(boolean condition, String column, String distance, String centralGeoLocation, Float boost) {
if (condition) {
Assert.notBlank(centralGeoLocation, "centralGeoLocation must not be null in geoDistance query");
return this.geoDistance(true, column, distance, GeoUtils.create(centralGeoLocation), boost);
} else {
return this.typedThis;
}
}
public Children geoPolygon(boolean condition, String column, List<GeoLocation> geoPoints, Float boost) {
if (condition) {
Assert.notEmpty(geoPoints, "GeoLocations must not be null in geoPolygon query");
}
return this.addParam(condition, EsQueryTypeEnum.GEO_POLYGON, column, geoPoints, boost);
}
public Children geoShape(boolean condition, String column, String indexedShapeId, Float boost) {
if (condition) {
Assert.notNull(indexedShapeId, "IndexedShapeId must not be null in geoShape query");
}
return this.addParam(condition, EsQueryTypeEnum.GEO_SHAPE_ID, column, indexedShapeId, boost);
}
public Children geoShape(boolean condition, String column, Geometry geometry, GeoShapeRelation shapeRelation, Float boost) {
if (condition) {
Assert.notNull(geometry, "Geometry must not be null in geoShape query");
Assert.notNull(geometry, "GeoShapeRelation must not be null in geoShape query");
}
return this.addParam(condition, (EsQueryTypeEnum)EsQueryTypeEnum.GEO_SHAPE, (String)column, geometry, shapeRelation, (Object)null, boost);
}
public final Children orderBy(boolean condition, boolean isAsc, String... columns) {
if (ArrayUtils.isEmpty(columns)) {
return this.typedThis;
} else {
if (condition) {
Arrays.stream(columns).forEach((column) -> {
BaseSortParam baseSortParam = BaseSortParam.builder().sortField(column).sortOrder(isAsc ? SortOrder.Asc : SortOrder.Desc).orderTypeEnum(OrderTypeEnum.FIELD).build();
this.baseSortParams.add(baseSortParam);
});
}
return this.typedThis;
}
}
public Children orderBy(boolean condition, List<OrderByParam> orderByParams) {
if (CollectionUtils.isNotEmpty(orderByParams)) {
this.orderByParams = orderByParams;
}
return this.typedThis;
}
public Children orderByDistanceAsc(boolean condition, String column, DistanceUnit unit, GeoDistanceType geoDistance, GeoLocation... geoPoints) {
if (ArrayUtils.isNotEmpty(geoPoints) && condition) {
BaseSortParam baseSortParam = BaseSortParam.builder().sortField(column).sortOrder(SortOrder.Asc).orderTypeEnum(OrderTypeEnum.GEO).geoPoints(Arrays.asList(geoPoints)).unit(unit).geoDistanceType(geoDistance).build();
this.baseSortParams.add(baseSortParam);
}
return this.typedThis;
}
public Children orderByDistanceDesc(boolean condition, String column, DistanceUnit unit, GeoDistanceType geoDistance, GeoLocation... geoPoints) {
if (ArrayUtils.isNotEmpty(geoPoints) && condition) {
BaseSortParam baseSortParam = BaseSortParam.builder().sortField(column).sortOrder(SortOrder.Desc).orderTypeEnum(OrderTypeEnum.GEO).geoPoints(Arrays.asList(geoPoints)).unit(unit).geoDistanceType(geoDistance).build();
this.baseSortParams.add(baseSortParam);
}
return this.typedThis;
}
public Children sort(boolean condition, List<SortOptions> sortBuilders) {
if (CollectionUtils.isEmpty(sortBuilders)) {
return this.typedThis;
} else {
if (condition) {
sortBuilders.forEach((sortBuilder) -> {
BaseSortParam baseSortParam = BaseSortParam.builder().orderTypeEnum(OrderTypeEnum.CUSTOMIZE).sortBuilder(sortBuilder).build();
this.baseSortParams.add(baseSortParam);
});
}
return this.typedThis;
}
}
public Children sortByScore(boolean condition, SortOrder sortOrder) {
if (condition) {
BaseSortParam baseSortParam = BaseSortParam.builder().sortOrder(sortOrder).orderTypeEnum(OrderTypeEnum.SCORE).build();
this.baseSortParams.add(baseSortParam);
}
return this.typedThis;
}
public final Children groupBy(boolean condition, boolean enablePipeline, String... columns) {
if (ArrayUtils.isEmpty(columns)) {
return this.typedThis;
} else {
Arrays.stream(columns).forEach((column) -> {
this.doIt(condition, enablePipeline, AggregationTypeEnum.TERMS, column);
});
return this.typedThis;
}
}
public Children termsAggregation(boolean condition, boolean enablePipeline, String... columns) {
if (ArrayUtils.isEmpty(columns)) {
return this.typedThis;
} else {
Arrays.stream(columns).forEach((column) -> {
this.doIt(condition, enablePipeline, AggregationTypeEnum.TERMS, column);
});
return this.typedThis;
}
}
public Children avg(boolean condition, boolean enablePipeline, String... columns) {
if (ArrayUtils.isEmpty(columns)) {
return this.typedThis;
} else {
Arrays.stream(columns).forEach((column) -> {
this.doIt(condition, enablePipeline, AggregationTypeEnum.AVG, column);
});
return this.typedThis;
}
}
public Children min(boolean condition, boolean enablePipeline, String... columns) {
if (ArrayUtils.isEmpty(columns)) {
return this.typedThis;
} else {
Arrays.stream(columns).forEach((column) -> {
this.doIt(condition, enablePipeline, AggregationTypeEnum.MIN, column);
});
return this.typedThis;
}
}
public Children max(boolean condition, boolean enablePipeline, String... columns) {
if (ArrayUtils.isEmpty(columns)) {
return this.typedThis;
} else {
Arrays.stream(columns).forEach((column) -> {
this.doIt(condition, enablePipeline, AggregationTypeEnum.MAX, column);
});
return this.typedThis;
}
}
public Children sum(boolean condition, boolean enablePipeline, String... columns) {
if (ArrayUtils.isEmpty(columns)) {
return this.typedThis;
} else {
Arrays.stream(columns).forEach((column) -> {
this.doIt(condition, enablePipeline, AggregationTypeEnum.SUM, column);
});
return this.typedThis;
}
}
public Children distinct(boolean condition, String column) {
if (condition) {
this.distinctField = column;
}
return this.typedThis;
}
public Children from(Integer from) {
this.from = from;
return this.typedThis;
}
public Children size(Integer size) {
this.size = size;
return this.typedThis;
}
public Children limit(Integer m) {
this.size = m;
return this.typedThis;
}
public Children limit(Integer m, Integer n) {
this.from = m;
this.size = n;
return this.typedThis;
}
public Children index(boolean condition, String... indexNames) {
if (condition) {
if (ArrayUtils.isEmpty(indexNames)) {
throw ExceptionUtils.eee("indexNames can not be empty");
}
this.indexNames.addAll(Arrays.asList(indexNames));
}
return this.typedThis;
}
public Children routing(boolean condition, String routing) {
if (condition) {
this.routing = routing;
}
return this.typedThis;
}
public Children preference(boolean condition, String preference) {
if (condition) {
if (StringUtils.isBlank(preference)) {
return this.typedThis;
}
this.preference = preference;
}
return this.typedThis;
}
public Children setSearchBuilder(boolean condition, SearchRequest.Builder searchBuilder) {
if (condition) {
this.searchBuilder = searchBuilder;
}
return this.typedThis;
}
public Children mix(boolean condition, co.elastic.clients.elasticsearch._types.query_dsl.Query query) {
return this.addParam(condition, query);
}
public Children bucketOrder(boolean condition, List<NamedValue<SortOrder>> bucketOrders) {
if (condition) {
this.bucketOrders = bucketOrders;
}
return this.typedThis;
}
public Children select(String... columns) {
this.include = columns;
return this.typedThis;
}
public Children select(Predicate<EntityFieldInfo> predicate) {
return this.select(this.entityClass, predicate);
}
public Children select(Class<T> entityClass, Predicate<EntityFieldInfo> predicate) {
this.entityClass = entityClass;
List<String> list = EntityInfoHelper.getEntityInfo(this.getCheckEntityClass()).chooseSelect(predicate);
this.include = (String[])list.toArray(this.include);
return this.typedThis;
}
public Children minScore(Double score) {
this.minScore = score;
return this.typedThis;
}
public Children trackScores() {
this.trackScores = Boolean.TRUE;
return this.typedThis;
}
public Children notSelect(String... columns) {
this.exclude = columns;
return this.typedThis;
}
public Children set(boolean condition, String column, Object val) {
if (condition) {
EsUpdateParam esUpdateParam = new EsUpdateParam();
esUpdateParam.setField(column);
esUpdateParam.setValue(val);
this.updateParamList.add(esUpdateParam);
}
return this.typedThis;
}
public Children indexName(String... indexNames) {
if (ArrayUtils.isEmpty(indexNames)) {
throw new RuntimeException("indexNames can not be empty");
} else {
this.indexNames.addAll(Arrays.asList(indexNames));
return this.typedThis;
}
}
public Children settings(Integer shards, Integer replicas, Integer maxResultWindow) {
this.settings = this.settings == null ? new IndexSettings.Builder() : this.settings;
if (Objects.nonNull(shards)) {
this.settings.numberOfShards(shards + "");
}
if (Objects.nonNull(replicas)) {
this.settings.numberOfReplicas(replicas + "");
}
if (Objects.nonNull(maxResultWindow)) {
this.settings.maxResultWindow(maxResultWindow);
}
return this.typedThis;
}
public Children settings(IndexSettings.Builder settings) {
this.settings = settings;
return this.typedThis;
}
public Children mapping(TypeMapping.Builder mapping) {
this.mapping = mapping;
return this.typedThis;
}
public Children mapping(String column, FieldType fieldType, String analyzer, String searchAnalyzer, String dateFormat, Boolean fieldData, Double boost) {
this.addEsIndexParam(column, fieldType, analyzer, searchAnalyzer, dateFormat, fieldData, boost);
return this.typedThis;
}
public Children createAlias(String aliasName) {
if (CollectionUtils.isEmpty(this.indexNames)) {
throw new RuntimeException("indexNames can not be empty");
} else if (StringUtils.isEmpty(aliasName)) {
throw new RuntimeException("aliasName can not be empty");
} else {
this.aliasName = aliasName;
return this.typedThis;
}
}
public Children join(String column, String parentName, String childName) {
EsIndexParam esIndexParam = new EsIndexParam();
esIndexParam.setFieldName(column);
esIndexParam.setFieldType(FieldType.JOIN.getType());
this.esIndexParamList.add(esIndexParam);
return this.typedThis;
}
protected abstract Children instance();
private void addBaseParam(Param param, EsQueryTypeEnum queryTypeEnum, String column, Object val, Float boost) {
param.setId(UUID.randomUUID().toString());
Optional.ofNullable(this.parentId).ifPresent(param::setParentId);
param.setPrevQueryType(this.prevQueryType);
param.setQueryTypeEnum(queryTypeEnum);
param.setVal(val);
param.setColumn(column);
param.setBoost(boost);
param.setLevel(this.level);
this.processJoin(param);
this.paramQueue.add(param);
}
private void addBaseNested(Param param, EsQueryTypeEnum queryTypeEnum, Consumer<Children> consumer) {
param.setId(UUID.randomUUID().toString());
Optional.ofNullable(this.parentId).ifPresent(param::setParentId);
param.setQueryTypeEnum(queryTypeEnum);
param.setLevel(this.level);
param.setPrevQueryType(queryTypeEnum);
this.processJoin(param);
this.paramQueue.add(param);
this.parentId = param.getId();
this.parentIdStack.push(this.parentId);
++this.level;
consumer.accept(this.instance());
--this.level;
if (!this.parentIdStack.isEmpty()) {
this.parentIdStack.pop();
if (this.parentIdStack.isEmpty()) {
this.parentId = null;
} else {
this.parentId = (String)this.parentIdStack.peek();
}
}
}
private void processJoin(Param param) {
if (!this.paramQueue.isEmpty()) {
Param prev = (Param)this.paramQueue.peekLast();
if (EsQueryTypeEnum.OR.equals(prev.getQueryTypeEnum())) {
param.setPrevQueryType(EsQueryTypeEnum.NESTED_OR);
} else if (EsQueryTypeEnum.NOT.equals(prev.getQueryTypeEnum())) {
param.setPrevQueryType(EsQueryTypeEnum.NESTED_NOT);
} else if (EsQueryTypeEnum.FILTER.equals(prev.getPrevQueryType())) {
param.setPrevQueryType(EsQueryTypeEnum.NESTED_FILTER);
}
}
}
private Children addParam(boolean condition, co.elastic.clients.elasticsearch._types.query_dsl.Query query) {
if (condition) {
Param param = new Param();
param.setQuery(query);
this.addBaseParam(param, EsQueryTypeEnum.MIX, (String)null, (Object)null, (Float)null);
}
return this.typedThis;
}
private Children addParam(boolean condition, EsQueryTypeEnum queryTypeEnum, String column, Object val, Float boost) {
if (condition) {
Param param = new Param();
this.addBaseParam(param, queryTypeEnum, column, val, boost);
}
return this.typedThis;
}
private Children addParam(boolean condition, EsQueryTypeEnum queryTypeEnum, String column, Object val, Object var1, Object var2, Float boost) {
if (condition) {
Param param = new Param();
param.setExt1(var1);
param.setExt2(var2);
this.addBaseParam(param, queryTypeEnum, column, val, boost);
}
return this.typedThis;
}
private Children addParam(boolean condition, String column, Object var1, Object var2, Object var3, Object var4, Float boost) {
if (condition) {
Assert.notNull(var1, "from must not be null in between query");
Assert.notNull(var2, "to must not be null in between query");
Param param = new Param();
param.setExt1(var1);
param.setExt2(var2);
param.setExt3(var3);
param.setExt4(var4);
this.addBaseParam(param, EsQueryTypeEnum.BETWEEN, column, (Object)null, boost);
}
return this.typedThis;
}
private Children addParam(boolean condition, Object val, Operator operator, int minimumShouldMatch, Float boost, String... columns) {
if (condition) {
Param param = new Param();
param.setExt1(operator);
param.setExt2(minimumShouldMatch);
param.setColumns(columns);
this.addBaseParam(param, EsQueryTypeEnum.MULTI_MATCH, (String)null, val, boost);
}
return this.typedThis;
}
private Children addNested(boolean condition, EsQueryTypeEnum queryTypeEnum, Consumer<Children> consumer) {
if (condition) {
Param param = new Param();
this.addBaseNested(param, queryTypeEnum, consumer);
}
return this.typedThis;
}
private Children addJoin(boolean condition, EsQueryTypeEnum queryTypeEnum, String path, Object ext, Consumer<Children> consumer) {
if (condition) {
Param param = new Param();
param.setColumn(path);
param.setVal(ext);
this.addBaseNested(param, queryTypeEnum, consumer);
}
return this.typedThis;
}
private Children addNested(boolean condition, String path, ChildScoreMode scoreMode, Consumer<Children> consumer) {
if (condition) {
Param param = new Param();
param.setColumn(path);
param.setVal(scoreMode);
this.addBaseNested(param, EsQueryTypeEnum.NESTED, consumer);
}
return this.typedThis;
}
private Children doIt(boolean condition, boolean enablePipeline, AggregationTypeEnum aggregationTypeEnum, String column) {
if (condition) {
AggregationParam aggregationParam = new AggregationParam();
aggregationParam.setEnablePipeline(enablePipeline);
aggregationParam.setName(column);
aggregationParam.setField(column);
aggregationParam.setAggregationType(aggregationTypeEnum);
this.aggregationParamList.add(aggregationParam);
}
return this.typedThis;
}
private void addEsIndexParam(String fieldName, FieldType fieldType, String analyzer, String searchAnalyzer, String dateFormat, Boolean fieldData, Double boost) {
EsIndexParam esIndexParam = new EsIndexParam();
esIndexParam.setFieldName(fieldName);
esIndexParam.setFieldType(fieldType.getType());
esIndexParam.setAnalyzer(analyzer);
esIndexParam.setSearchAnalyzer(searchAnalyzer);
esIndexParam.setDateFormat(dateFormat);
esIndexParam.setFieldData(fieldData);
esIndexParam.setBoost(boost);
this.esIndexParamList.add(esIndexParam);
}
}
哪个方法适用我上诉情况