elasticarch中⼏种判断条件
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
if (Operator().equals(MatchType.equal.name())) {
if (Type().equals("int")) {
boolQueryBuilder.must(QueryBuilders.Attribute(), Keyword()));
} el {
boolQueryBuilder.must(QueryBuilders.Attribute() + ".keyword", Keyword())); }
} el if (Operator()._equal.name())) {
boolQueryBuilder.mustNot(QueryBuilders.Attribute() + ".keyword", Keyword())); } el if (Operator().ains.name())) {
if (Type().equals("check")) {
ArrayList arrayList = (ArrayList) Keyword();
if (arrayList.size() > 0) {
if ((0) instanceof Long || (0) instanceof Integer) {
List<Long> listID = (List<Long>) (Keyword());
boolQueryBuilder.Attribute(), listID));
} el if ((0) instanceof String) {
List<String> listKey = (List<String>) Keyword();
王竟力
for (String key : listKey
) {
boolQueryBuilder.should(QueryBuilders.Attribute() + ".keyword", key));
平安树的养殖方法}
boolQueryBuilder.minimumShouldMatch(1);
}
清晨鸟语花香}
} el {
if (StringObjUtil.Keyword().toString())) {
boolQueryBuilder.must(QueryBuilders.Attribute(), "*" + Keyword() + "*"));
} el {
boolQueryBuilder.must(QueryBuilders.Attribute(), Keyword()));
}
}
} el if (Operator()._contains.name())) {
if (Type().equals("check")) {
马若虚ArrayList arrayList = (ArrayList) Keyword();
if (arrayList.size() > 0) {
if ((0) instanceof Long || (0) instanceof Integer) {
boolQueryBuilder.Attribute(), arrayList));
} el if ((0) instanceof String) {
List<String> listKey = (List<String>) Keyword();
for (String key : listKey
) {
boolQueryBuilder.mustNot(QueryBuilders.Attribute() + ".keyword", key));
}
}
}
} el {
if (StringObjUtil.Keyword().toString())) {
boolQueryBuilder.mustNot(QueryBuilders.Attribute(), "*" + Keyword() + "*"));
} el {
boolQueryBuilder.mustNot(QueryBuilders.Attribute(), Keyword()));
}
}
} el if (Operator().equals(MatchType.isnull.name())) {
菜根谭全文及讲解
if (Type().equals("check")){
boolQueryBuilder.Attribute()));34个省级行政区
}el {
boolQueryBuilder.mustNot(QueryBuilders.Attribute(), "*"));
}
} el if (Operator()._isnull.name())) {
} el if (Operator()._isnull.name())) {
if (Type().equals("check")){
boolQueryBuilder.Attribute()));
}el {
boolQueryBuilder.must(QueryBuilders.Attribute(), "*"));
}
} el if (Operator().equals(MatchType.range.name())) {
if (Type().equals("date")) {
if (Keyword().toString().contains("~")) {
String[] dates = Keyword().toString().split("~");
LocalDateTime start = LocalDateTime.par(dates[0], dateTimeFormatter);
LocalDateTime end = LocalDateTime.par(dates[1], dateTimeFormatter);
boolQueryBuilder.must(QueryBuilders.Attribute()).from(start).to(end)); }
} el {
boolQueryBuilder.must(QueryBuilders.Attribute()));
}拉西地平
双鱼座本周运势
} el if (Operator().ame())) {
if (Type().equals("date")) {
LocalDateTime start = LocalDateTime.Keyword().toString(), dateTimeFormatter); boolQueryBuilder.must(QueryBuilders.Attribute()).gt(start));
} el {
boolQueryBuilder.must(QueryBuilders.Attribute()).Keyword())); }
} el if (Operator().equals(MatchType.lt.name())) {
if (Type().equals("date")) {
LocalDateTime start = LocalDateTime.Keyword().toString(), dateTimeFormatter); boolQueryBuilder.must(QueryBuilders.Attribute()).lt(start));
} el {
boolQueryBuilder.must(QueryBuilders.Attribute()).Keyword())); }
}
elasticarch中,对应不同的数据类型,查询不同的条件查询基本写法。
contains("包含"),
/**
* 是
*/
equal("等于"),
/**
* 包含
*/
not_equal("不等于"), /**
* 包含
*/
not_contains("不包含"), startsWith("开头匹配"), endsWith("结尾匹配"), isnull("为空"),
not_isnull("不为空"), range("范围"),
gt("⼤于"),
lt("⼩于");