当前位置: 首页>>代码示例>>Java>>正文


Java InternalFilter类代码示例

本文整理汇总了Java中org.elasticsearch.search.aggregations.bucket.filter.InternalFilter的典型用法代码示例。如果您正苦于以下问题:Java InternalFilter类的具体用法?Java InternalFilter怎么用?Java InternalFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


InternalFilter类属于org.elasticsearch.search.aggregations.bucket.filter包,在下文中一共展示了InternalFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: groupByTestWithFilter

import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter; //导入依赖的package包/类
@Test
public void groupByTestWithFilter() throws Exception {
    Aggregations result = query(String.format("SELECT COUNT(*) FROM %s/account GROUP BY filter(gender='m'),gender", TEST_INDEX));
    InternalFilter filter = result.get("filter(gender = 'm')@FILTER");
    Terms gender = filter.getAggregations().get("gender");

    for(Terms.Bucket bucket : gender.getBuckets()) {
        String key = bucket.getKey().toString();
        long count = ((ValueCount) bucket.getAggregations().get("COUNT(*)")).getValue();
        if(key.equalsIgnoreCase("m")) {
            Assert.assertEquals(507, count);
        }
        else {
            throw new Exception(String.format("Unexpected key. expected: only m. found: %s", key));
        }
    }
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:18,代码来源:AggregationTest.java

示例2: groupByOnNestedFieldWithFilterTest

import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter; //导入依赖的package包/类
@Test
public void groupByOnNestedFieldWithFilterTest() throws Exception {
    Aggregations result = query(String.format("SELECT COUNT(*) FROM %s/nestedType GROUP BY  nested(message.info),filter('myFilter',message.info = 'a')", TEST_INDEX));
    InternalNested nested = result.get("[email protected]");
    InternalFilter filter = nested.getAggregations().get("[email protected]");
    Terms infos = filter.getAggregations().get("message.info");
    Assert.assertEquals(1,infos.getBuckets().size());
    for(Terms.Bucket bucket : infos.getBuckets()) {
        String key = bucket.getKey().toString();
        long count = ((ValueCount) bucket.getAggregations().get("COUNT(*)")).getValue();
        if(key.equalsIgnoreCase("a")) {
            Assert.assertEquals(2, count);
        }

        else {
            throw new Exception(String.format("Unexpected key. expected: only a . found: %s", key));
        }
    }
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:20,代码来源:AggregationTest.java

示例3: reverseToRootGroupByOnNestedFieldWithFilterTestWithReverseNestedAndEmptyPath

import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter; //导入依赖的package包/类
@Test
public void reverseToRootGroupByOnNestedFieldWithFilterTestWithReverseNestedAndEmptyPath() throws Exception {
    Aggregations result = query(String.format("SELECT COUNT(*) FROM %s/nestedType GROUP BY  nested(message.info),filter('myFilter',message.info = 'a'),reverse_nested(someField,'')", TEST_INDEX));
    InternalNested nested = result.get("[email protected]");
    InternalFilter filter = nested.getAggregations().get("[email protected]");
    Terms infos = filter.getAggregations().get("message.info");
    Assert.assertEquals(1,infos.getBuckets().size());
    for(Terms.Bucket bucket : infos.getBuckets()) {
        InternalReverseNested reverseNested = bucket.getAggregations().get("[email protected]");
        Terms terms = reverseNested.getAggregations().get("someField");
        Terms.Bucket internalBucket = terms.getBuckets().get(0);

        long count = ((ValueCount) internalBucket.getAggregations().get("COUNT(*)")).getValue();
        String key = internalBucket.getKey().toString();
        if(key.equalsIgnoreCase("b")) {
            Assert.assertEquals(2, count);
        }
        else {
            throw new Exception(String.format("Unexpected key. expected: only a . found: %s", key));
        }
    }
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:23,代码来源:AggregationTest.java

示例4: reverseToRootGroupByOnNestedFieldWithFilterTestWithReverseNestedNoPath

import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter; //导入依赖的package包/类
@Test
public void reverseToRootGroupByOnNestedFieldWithFilterTestWithReverseNestedNoPath() throws Exception {
    Aggregations result = query(String.format("SELECT COUNT(*) FROM %s/nestedType GROUP BY  nested(message.info),filter('myFilter',message.info = 'a'),reverse_nested(someField)", TEST_INDEX));
    InternalNested nested = result.get("[email protected]");
    InternalFilter filter = nested.getAggregations().get("[email protected]");
    Terms infos = filter.getAggregations().get("message.info");
    Assert.assertEquals(1,infos.getBuckets().size());
    for(Terms.Bucket bucket : infos.getBuckets()) {
        InternalReverseNested reverseNested = bucket.getAggregations().get("[email protected]");
        Terms terms = reverseNested.getAggregations().get("someField");
        Terms.Bucket internalBucket = terms.getBuckets().get(0);

        long count = ((ValueCount) internalBucket.getAggregations().get("COUNT(*)")).getValue();
        String key = internalBucket.getKey().toString();
        if(key.equalsIgnoreCase("b")) {
            Assert.assertEquals(2, count);
        }
        else {
            throw new Exception(String.format("Unexpected key. expected: only a . found: %s", key));
        }
    }
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:23,代码来源:AggregationTest.java

示例5: reverseAnotherNestedGroupByOnNestedFieldWithFilterTestWithReverseNestedNoPath

import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter; //导入依赖的package包/类
@Test
public void reverseAnotherNestedGroupByOnNestedFieldWithFilterTestWithReverseNestedNoPath() throws Exception {
    Aggregations result = query(String.format("SELECT COUNT(*) FROM %s/nestedType GROUP BY  nested(message.info),filter('myFilter',message.info = 'a'),reverse_nested(comment.data,'~comment')", TEST_INDEX));
    InternalNested nested = result.get("[email protected]");
    InternalFilter filter = nested.getAggregations().get("[email protected]");
    Terms infos = filter.getAggregations().get("message.info");
    Assert.assertEquals(1,infos.getBuckets().size());
    for(Terms.Bucket bucket : infos.getBuckets()) {
        InternalReverseNested reverseNested = bucket.getAggregations().get("[email protected]_REVERSED");
        InternalNested innerNested = reverseNested.getAggregations().get("[email protected]");
        Terms terms = innerNested.getAggregations().get("comment.data");
        Terms.Bucket internalBucket = terms.getBuckets().get(0);

        long count = ((ValueCount) internalBucket.getAggregations().get("COUNT(*)")).getValue();
        String key = internalBucket.getKey().toString();
        if(key.equalsIgnoreCase("ab")) {
            Assert.assertEquals(2, count);
        }
        else {
            throw new Exception(String.format("Unexpected key. expected: only a . found: %s", key));
        }
    }
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:24,代码来源:AggregationTest.java

示例6: processFilterAgg

import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter; //导入依赖的package包/类
/**
 * Parse an aggregation performed without grouping.
 * @param filter
 * @param rs
 * @throws SQLException
 */
private void processFilterAgg(InternalFilter filter, ESResultSet rs) throws SQLException{
	//String name = global.getName(); // we do not care about the global name for now
	List<Object> row = rs.getNewRow();
	Column count = null;
	for(Column c : rs.getHeading().columns())
		if(c.getOp() == Operation.COUNT) count = c;
	
	if(count != null){
		row.set(count.getIndex(), filter.getDocCount());
	}
	for(Aggregation agg : filter.getAggregations()){
		if(agg instanceof InternalNumericMetricsAggregation.SingleValue){
			InternalNumericMetricsAggregation.SingleValue numericAgg = 
					(InternalNumericMetricsAggregation.SingleValue)agg;
			String name =numericAgg.getName();
			Column column = rs.getHeading().getColumnByLabel(name);
			if(column == null){
				throw new SQLException("Unable to identify column for "+name);
			}
			row.set(column.getIndex(), numericAgg.value());
		}else throw new SQLException("Unable to parse aggregation of type "+agg.getClass());
	}
	rs.add(row);
}
 
开发者ID:Anchormen,项目名称:sql4es,代码行数:31,代码来源:SearchAggregationParser.java

示例7: collectNumericData

import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter; //导入依赖的package包/类
private <T extends FieldMetadata> List<FieldMetadata> collectNumericData(Collection<FieldInfo> fields, ExtendedStatsAnalyzer<T> parser) {
	if(fields.isEmpty()) {
		return Collections.emptyList();
	}
	List<FieldMetadata> metadata = new ArrayList<>(fields.size());
	SearchRequestBuilder builder = createNumericSearchBuilder(fields);
	SearchResponse response = client.search(builder.request()).actionGet();
	for(FieldInfo info : fields) {
		InternalFilter filter = getAggregation(response, info, FILTER_AGG);
		ExtendedStats stats = (ExtendedStats) filter.getAggregations().get(EXTENDED_STATS_AGG + info.getFullPath());
		LOGGER.debug("Field {} total: {} MAX: {} MIN: {}", info.getFullPath(), stats.getCount(), stats.getMaxAsString(), stats.getMinAsString());
		if(stats.getCount() <= ZERO_ITEMS) {
			continue;
		}
		int valuesPerDocument = valuesPerDoc(response, filter, stats);
		FieldMetadata meta = parser.parse(info, stats, valuesPerDocument);
		LOGGER.debug("Registering metadata: {}", meta);
		metadata.add(meta);
	}
	return metadata;
}
 
开发者ID:kucera-jan-cz,项目名称:esBench,代码行数:22,代码来源:FieldAnalyzer.java

示例8: groupByTestWithFilter

import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter; //导入依赖的package包/类
@Test
public void groupByTestWithFilter() throws Exception {
    Aggregations result = query(String.format("SELECT COUNT(*) FROM %s/account GROUP BY filter(gender='m'),gender", TEST_INDEX_ACCOUNT));
    InternalFilter filter = result.get("filter(gender = 'm')@FILTER");
    Terms gender = filter.getAggregations().get("gender");

    for(Terms.Bucket bucket : gender.getBuckets()) {
        String key = bucket.getKey().toString();
        long count = ((ValueCount) bucket.getAggregations().get("COUNT(*)")).getValue();
        if(key.equalsIgnoreCase("m")) {
            Assert.assertEquals(507, count);
        }
        else {
            throw new Exception(String.format("Unexpected key. expected: only m. found: %s", key));
        }
    }
}
 
开发者ID:NLPchina,项目名称:elasticsearch-sql,代码行数:18,代码来源:AggregationTest.java

示例9: groupByOnNestedFieldWithFilterTest

import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter; //导入依赖的package包/类
@Test
public void groupByOnNestedFieldWithFilterTest() throws Exception {
    Aggregations result = query(String.format("SELECT COUNT(*) FROM %s/nestedType GROUP BY  nested(message.info),filter('myFilter',message.info = 'a')", TEST_INDEX_NESTED_TYPE));
    InternalNested nested = result.get("[email protected]");
    InternalFilter filter = nested.getAggregations().get("[email protected]");
    Terms infos = filter.getAggregations().get("message.info");
    Assert.assertEquals(1,infos.getBuckets().size());
    for(Terms.Bucket bucket : infos.getBuckets()) {
        String key = bucket.getKey().toString();
        long count = ((ValueCount) bucket.getAggregations().get("COUNT(*)")).getValue();
        if(key.equalsIgnoreCase("a")) {
            Assert.assertEquals(2, count);
        }

        else {
            throw new Exception(String.format("Unexpected key. expected: only a . found: %s", key));
        }
    }
}
 
开发者ID:NLPchina,项目名称:elasticsearch-sql,代码行数:20,代码来源:AggregationTest.java

示例10: reverseToRootGroupByOnNestedFieldWithFilterTestWithReverseNestedAndEmptyPath

import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter; //导入依赖的package包/类
@Test
public void reverseToRootGroupByOnNestedFieldWithFilterTestWithReverseNestedAndEmptyPath() throws Exception {
    Aggregations result = query(String.format("SELECT COUNT(*) FROM %s/nestedType GROUP BY  nested(message.info),filter('myFilter',message.info = 'a'),reverse_nested(someField,'')", TEST_INDEX_NESTED_TYPE));
    InternalNested nested = result.get("[email protected]");
    InternalFilter filter = nested.getAggregations().get("[email protected]");
    Terms infos = filter.getAggregations().get("message.info");
    Assert.assertEquals(1,infos.getBuckets().size());
    for(Terms.Bucket bucket : infos.getBuckets()) {
        InternalReverseNested reverseNested = bucket.getAggregations().get("[email protected]");
        Terms terms = reverseNested.getAggregations().get("someField");
        Terms.Bucket internalBucket = terms.getBuckets().get(0);

        long count = ((ValueCount) internalBucket.getAggregations().get("COUNT(*)")).getValue();
        String key = internalBucket.getKey().toString();
        if(key.equalsIgnoreCase("b")) {
            Assert.assertEquals(2, count);
        }
        else {
            throw new Exception(String.format("Unexpected key. expected: only a . found: %s", key));
        }
    }
}
 
开发者ID:NLPchina,项目名称:elasticsearch-sql,代码行数:23,代码来源:AggregationTest.java

示例11: reverseToRootGroupByOnNestedFieldWithFilterTestWithReverseNestedNoPath

import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter; //导入依赖的package包/类
@Test
public void reverseToRootGroupByOnNestedFieldWithFilterTestWithReverseNestedNoPath() throws Exception {
    Aggregations result = query(String.format("SELECT COUNT(*) FROM %s/nestedType GROUP BY  nested(message.info),filter('myFilter',message.info = 'a'),reverse_nested(someField)", TEST_INDEX_NESTED_TYPE));
    InternalNested nested = result.get("[email protected]");
    InternalFilter filter = nested.getAggregations().get("[email protected]");
    Terms infos = filter.getAggregations().get("message.info");
    Assert.assertEquals(1,infos.getBuckets().size());
    for(Terms.Bucket bucket : infos.getBuckets()) {
        InternalReverseNested reverseNested = bucket.getAggregations().get("[email protected]");
        Terms terms = reverseNested.getAggregations().get("someField");
        Terms.Bucket internalBucket = terms.getBuckets().get(0);

        long count = ((ValueCount) internalBucket.getAggregations().get("COUNT(*)")).getValue();
        String key = internalBucket.getKey().toString();
        if(key.equalsIgnoreCase("b")) {
            Assert.assertEquals(2, count);
        }
        else {
            throw new Exception(String.format("Unexpected key. expected: only a . found: %s", key));
        }
    }
}
 
开发者ID:NLPchina,项目名称:elasticsearch-sql,代码行数:23,代码来源:AggregationTest.java

示例12: reverseAnotherNestedGroupByOnNestedFieldWithFilterTestWithReverseNestedNoPath

import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter; //导入依赖的package包/类
@Test
public void reverseAnotherNestedGroupByOnNestedFieldWithFilterTestWithReverseNestedNoPath() throws Exception {
    Aggregations result = query(String.format("SELECT COUNT(*) FROM %s/nestedType GROUP BY  nested(message.info),filter('myFilter',message.info = 'a'),reverse_nested(comment.data,'~comment')", TEST_INDEX_NESTED_TYPE));
    InternalNested nested = result.get("[email protected]");
    InternalFilter filter = nested.getAggregations().get("[email protected]");
    Terms infos = filter.getAggregations().get("message.info");
    Assert.assertEquals(1,infos.getBuckets().size());
    for(Terms.Bucket bucket : infos.getBuckets()) {
        InternalReverseNested reverseNested = bucket.getAggregations().get("[email protected]_REVERSED");
        InternalNested innerNested = reverseNested.getAggregations().get("[email protected]");
        Terms terms = innerNested.getAggregations().get("comment.data");
        Terms.Bucket internalBucket = terms.getBuckets().get(0);

        long count = ((ValueCount) internalBucket.getAggregations().get("COUNT(*)")).getValue();
        String key = internalBucket.getKey().toString();
        if(key.equalsIgnoreCase("ab")) {
            Assert.assertEquals(2, count);
        }
        else {
            throw new Exception(String.format("Unexpected key. expected: only a . found: %s", key));
        }
    }
}
 
开发者ID:NLPchina,项目名称:elasticsearch-sql,代码行数:24,代码来源:AggregationTest.java

示例13: SearchResult

import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter; //导入依赖的package包/类
public SearchResult(SearchResponse resp, Select select) throws SqlParseException {
	Aggregations aggs = resp.getAggregations();
	if (aggs.get("filter") != null) {
		InternalFilter inf = aggs.get("filter");
		aggs = inf.getAggregations();
	}
	if (aggs.get("group by") != null) {
		InternalTerms terms = aggs.get("group by");
		Collection<Bucket> buckets = terms.getBuckets();
		this.total = buckets.size();
		results = new ArrayList<>(buckets.size());
		for (Bucket bucket : buckets) {
			Map<String, Object> aggsMap = toAggsMap(bucket.getAggregations().getAsMap());
			aggsMap.put("docCount", bucket.getDocCount());
			results.add(aggsMap);
		}
	} else {
		results = new ArrayList<>(1);
		this.total = 1;
		Map<String, Object> map = new HashMap<>();
		for (Aggregation aggregation : aggs) {
			map.put(aggregation.getName(), covenValue(aggregation));
		}
		results.add(map);
	}

}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:28,代码来源:SearchResult.java

示例14: reverseToRootGroupByOnNestedFieldWithFilterTestWithReverseNestedOnHistogram

import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter; //导入依赖的package包/类
@Test
public void reverseToRootGroupByOnNestedFieldWithFilterTestWithReverseNestedOnHistogram() throws Exception {
    Aggregations result = query(String.format("SELECT COUNT(*) FROM %s/nestedType GROUP BY  nested(message.info),filter('myFilter',message.info = 'a'),histogram('field'='myNum','reverse_nested'='','interval'='2' , 'alias' = 'someAlias' )", TEST_INDEX));
    InternalNested nested = result.get("[email protected]");
    InternalFilter filter = nested.getAggregations().get("[email protected]");
    Terms infos = filter.getAggregations().get("message.info");
    Assert.assertEquals(1,infos.getBuckets().size());
    for(Terms.Bucket bucket : infos.getBuckets()) {
        InternalReverseNested reverseNested = bucket.getAggregations().get("[email protected]");
        InternalHistogram histogram = reverseNested.getAggregations().get("someAlias");
        Assert.assertEquals(3, histogram.getBuckets().size());

    }
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:15,代码来源:AggregationTest.java

示例15: reverseToRootGroupByOnNestedFieldWithFilterAndSumOnReverseNestedField

import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter; //导入依赖的package包/类
@Test
public void reverseToRootGroupByOnNestedFieldWithFilterAndSumOnReverseNestedField() throws Exception {
    Aggregations result = query(String.format("SELECT sum(reverse_nested(myNum)) bla FROM %s/nestedType GROUP BY  nested(message.info),filter('myFilter',message.info = 'a')", TEST_INDEX));
    InternalNested nested = result.get("[email protected]");
    InternalFilter filter = nested.getAggregations().get("[email protected]");
    Terms infos = filter.getAggregations().get("message.info");
    Assert.assertEquals(1,infos.getBuckets().size());
    for(Terms.Bucket bucket : infos.getBuckets()) {
        InternalReverseNested reverseNested = bucket.getAggregations().get("[email protected]");
        InternalSum sum = reverseNested.getAggregations().get("bla");
        Assert.assertEquals(5.0,sum.getValue(),0.000001);

    }
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:15,代码来源:AggregationTest.java


注:本文中的org.elasticsearch.search.aggregations.bucket.filter.InternalFilter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。