本文整理汇总了Java中org.elasticsearch.search.aggregations.AggregationBuilders.nested方法的典型用法代码示例。如果您正苦于以下问题:Java AggregationBuilders.nested方法的具体用法?Java AggregationBuilders.nested怎么用?Java AggregationBuilders.nested使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.search.aggregations.AggregationBuilders
的用法示例。
在下文中一共展示了AggregationBuilders.nested方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createNestedAggregation
import org.elasticsearch.search.aggregations.AggregationBuilders; //导入方法依赖的package包/类
private AggregationBuilder createNestedAggregation(Field field) {
AggregationBuilder nestedBuilder;
String nestedPath = field.getNestedPath();
if (field.isReverseNested()) {
if (nestedPath == null || !nestedPath.startsWith("~")) {
ReverseNestedAggregationBuilder reverseNestedAggregationBuilder = AggregationBuilders.reverseNested(getNestedAggName(field));
if(nestedPath!=null){
reverseNestedAggregationBuilder.path(nestedPath);
}
return reverseNestedAggregationBuilder;
}
nestedPath = nestedPath.substring(1);
}
nestedBuilder = AggregationBuilders.nested(getNestedAggName(field),nestedPath);
return nestedBuilder;
}
示例2: addFieldToAgg
import org.elasticsearch.search.aggregations.AggregationBuilders; //导入方法依赖的package包/类
private AggregationBuilder addFieldToAgg(MethodField field, ValuesSourceAggregationBuilder builder) {
KVValue kvValue = field.getParams().get(0);
if (kvValue.key != null && kvValue.key.equals("script")) {
if (kvValue.value instanceof MethodField) {
return builder.script(new Script(((MethodField) kvValue.value).getParams().get(1).toString()));
} else {
return builder.script(new Script(kvValue.value.toString()));
}
} else if (kvValue.key != null && kvValue.value.toString().trim().startsWith("def")) {
return builder.script(new Script(kvValue.value.toString()));
} else if (kvValue.key != null && (kvValue.key.equals("nested") || kvValue.key.equals("reverse_nested"))) {
NestedType nestedType = (NestedType) kvValue.value;
builder.field(nestedType.field);
AggregationBuilder nestedBuilder;
String nestedAggName = nestedType.field + "@NESTED";
if (nestedType.isReverse()) {
if (nestedType.path != null && nestedType.path.startsWith("~")) {
String realPath = nestedType.path.substring(1);
nestedBuilder = AggregationBuilders.nested(nestedAggName,realPath);
nestedBuilder = nestedBuilder.subAggregation(builder);
return AggregationBuilders.reverseNested(nestedAggName + "_REVERSED").subAggregation(nestedBuilder);
} else {
ReverseNestedAggregationBuilder reverseNestedAggregationBuilder = AggregationBuilders.reverseNested(nestedAggName);
if (nestedType.path!=null){
reverseNestedAggregationBuilder.path(nestedType.path);
}
nestedBuilder = reverseNestedAggregationBuilder;
}
} else {
nestedBuilder = AggregationBuilders.nested(nestedAggName,nestedType.path);
}
return nestedBuilder.subAggregation(builder);
} else if (kvValue.key != null && (kvValue.key.equals("children"))) {
ChildrenType childrenType = (ChildrenType) kvValue.value;
builder.field(childrenType.field);
AggregationBuilder childrenBuilder;
String childrenAggName = childrenType.field + "@CHILDREN";
childrenBuilder = JoinAggregationBuilders.children(childrenAggName,childrenType.childType);
return childrenBuilder;
}
return builder.field(kvValue.toString());
}
示例3: addFieldToAgg
import org.elasticsearch.search.aggregations.AggregationBuilders; //导入方法依赖的package包/类
private AggregationBuilder addFieldToAgg(MethodField field, ValuesSourceAggregationBuilder builder) {
KVValue kvValue = field.getParams().get(0);
if (kvValue.key != null && kvValue.key.equals("script")) {
if (kvValue.value instanceof MethodField) {
return builder.script(new Script(((MethodField) kvValue.value).getParams().get(1).toString()));
} else {
return builder.script(new Script(kvValue.value.toString()));
}
} else if (kvValue.key != null && kvValue.value.toString().trim().startsWith("def")) {
return builder.script(new Script(kvValue.value.toString()));
} else if (kvValue.key != null && (kvValue.key.equals("nested") || kvValue.key.equals("reverse_nested"))) {
NestedType nestedType = (NestedType) kvValue.value;
builder.field(nestedType.field);
AggregationBuilder nestedBuilder;
String nestedAggName = nestedType.field + "@NESTED";
if (nestedType.isReverse()) {
if (nestedType.path != null && nestedType.path.startsWith("~")) {
String realPath = nestedType.path.substring(1);
nestedBuilder = AggregationBuilders.nested(nestedAggName,realPath);
nestedBuilder = nestedBuilder.subAggregation(builder);
return AggregationBuilders.reverseNested(nestedAggName + "_REVERSED").subAggregation(nestedBuilder);
} else {
ReverseNestedAggregationBuilder reverseNestedAggregationBuilder = AggregationBuilders.reverseNested(nestedAggName);
if (nestedType.path!=null){
reverseNestedAggregationBuilder.path(nestedType.path);
}
nestedBuilder = reverseNestedAggregationBuilder;
}
} else {
nestedBuilder = AggregationBuilders.nested(nestedAggName,nestedType.path);
}
return nestedBuilder.subAggregation(builder);
} else if (kvValue.key != null && (kvValue.key.equals("children"))) {
ChildrenType childrenType = (ChildrenType) kvValue.value;
builder.field(childrenType.field);
AggregationBuilder childrenBuilder;
String childrenAggName = childrenType.field + "@CHILDREN";
childrenBuilder = AggregationBuilders.children(childrenAggName,childrenType.childType);
return childrenBuilder;
}
return builder.field(kvValue.toString());
}