• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Min类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getMinId

import org.elasticsearch.search.aggregations.metrics.min.Min; //导入依赖的package包/类
protected final int getMinId(String indexName, String columnName) {
    ElasticSearchClient client = getClient();
    SearchRequestBuilder searchRequestBuilder = client.prepareSearch(indexName);
    searchRequestBuilder.setTypes("type");
    searchRequestBuilder.setSize(0);
    MinAggregationBuilder aggregation = AggregationBuilders.min("agg").field(columnName);
    searchRequestBuilder.addAggregation(aggregation);

    SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
    Min agg = searchResponse.getAggregations().get("agg");

    int id = (int)agg.getValue();
    if (id == Integer.MAX_VALUE || id == Integer.MIN_VALUE) {
        return 0;
    } else {
        return id;
    }
}
 
开发者ID:apache,项目名称:incubator-skywalking,代码行数:19,代码来源:EsDAO.java


示例2: testSampler

import org.elasticsearch.search.aggregations.metrics.min.Min; //导入依赖的package包/类
/**
 * Uses the sampler aggregation to find the minimum value of a field out of the top 3 scoring documents in a search.
 */
public void testSampler() throws IOException {
    TextFieldType textFieldType = new TextFieldType();
    textFieldType.setIndexAnalyzer(new NamedAnalyzer("foo", AnalyzerScope.GLOBAL, new StandardAnalyzer()));
    MappedFieldType numericFieldType = new NumberFieldMapper.NumberFieldType(NumberFieldMapper.NumberType.LONG);
    numericFieldType.setName("int");

    IndexWriterConfig indexWriterConfig = newIndexWriterConfig();
    indexWriterConfig.setMaxBufferedDocs(100);
    indexWriterConfig.setRAMBufferSizeMB(100); // flush on open to have a single segment with predictable docIds
    try (Directory dir = newDirectory();
            IndexWriter w = new IndexWriter(dir, indexWriterConfig)) {
        for (long value : new long[] {7, 3, -10, -6, 5, 50}) {
            Document doc = new Document();
            StringBuilder text = new StringBuilder();
            for (int i = 0; i < value; i++) {
                text.append("good ");
            }
            doc.add(new Field("text", text.toString(), textFieldType));
            doc.add(new SortedNumericDocValuesField("int", value));
            w.addDocument(doc);
        }

        SamplerAggregationBuilder aggBuilder = new SamplerAggregationBuilder("sampler")
                .shardSize(3)
                .subAggregation(new MinAggregationBuilder("min")
                        .field("int"));
        try (IndexReader reader = DirectoryReader.open(w)) {
            assertEquals("test expects a single segment", 1, reader.leaves().size());
            IndexSearcher searcher = new IndexSearcher(reader);
            Sampler sampler = searchAndReduce(searcher, new TermQuery(new Term("text", "good")), aggBuilder, textFieldType,
                    numericFieldType);
            Min min = sampler.getAggregations().get("min");
            assertEquals(5.0, min.getValue(), 0);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:40,代码来源:SamplerAggregatorTests.java


示例3: minOnNestedField

import org.elasticsearch.search.aggregations.metrics.min.Min; //导入依赖的package包/类
@Test
public void minOnNestedField() throws Exception {
    Aggregations result = query(String.format("SELECT min(nested(message.dayOfWeek)) as minDays FROM %s/nestedType", TEST_INDEX));
    InternalNested nested = result.get("[email protected]");
    Min mins = nested.getAggregations().get("minDays");
    Assert.assertEquals(1.0,mins.getValue(),0.0001);

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


示例4: minOnNestedField

import org.elasticsearch.search.aggregations.metrics.min.Min; //导入依赖的package包/类
@Test
public void minOnNestedField() throws Exception {
    Aggregations result = query(String.format("SELECT min(nested(message.dayOfWeek)) as minDays FROM %s/nestedType", TEST_INDEX_NESTED_TYPE));
    InternalNested nested = result.get("[email protected]");
    Min mins = nested.getAggregations().get("minDays");
    Assert.assertEquals(1.0,mins.getValue(),0.0001);

}
 
开发者ID:NLPchina,项目名称:elasticsearch-sql,代码行数:9,代码来源:AggregationTest.java


示例5: getValueFromAggregation

import org.elasticsearch.search.aggregations.metrics.min.Min; //导入依赖的package包/类
public static String getValueFromAggregation(Aggregation a, Function f){
	
	String value = null;
	switch(f.type){
	case Function.SUM :
		value = String.valueOf(((Sum) a).getValue());
		break;
	case Function.COUNT :
		value = String.valueOf(((ValueCount) a).getValue());
		break;
	case Function.DC :
		value = String.valueOf(((Cardinality) a).getValue());
		break;
	case Function.AVG :
		value = String.valueOf(((Avg) a).getValue());
		break;
	case Function.MAX :
		value = String.valueOf(((Max) a).getValue());
		break;
	case Function.MIN :
		value = String.valueOf(((Min) a).getValue());
		break;
	}
	
	return value;
	
	
}
 
开发者ID:huangchen007,项目名称:elasticsearch-rest-command,代码行数:29,代码来源:Search.java


示例6: minTest

import org.elasticsearch.search.aggregations.metrics.min.Min; //导入依赖的package包/类
@Test
public void minTest() throws IOException, SqlParseException, SQLFeatureNotSupportedException {
	Aggregations result = query(String.format("SELECT MIN(age) FROM %s/account", TEST_INDEX));
	Min min = result.get("MIN(age)");
	assertThat(min.getValue(), equalTo(20.0));
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:7,代码来源:AggregationTest.java


示例7: minTest

import org.elasticsearch.search.aggregations.metrics.min.Min; //导入依赖的package包/类
@Test
public void minTest() throws IOException, SqlParseException, SQLFeatureNotSupportedException {
	Aggregations result = query(String.format("SELECT MIN(age) FROM %s/account", TestsConstants.TEST_INDEX));
	Min min = result.get("MIN(age)");
	assertThat(min.getValue(), equalTo(20.0));
}
 
开发者ID:selvakumarEsra,项目名称:es4sql,代码行数:7,代码来源:AggregationTest.java


示例8: minTest

import org.elasticsearch.search.aggregations.metrics.min.Min; //导入依赖的package包/类
@Test
public void minTest() throws IOException, SqlParseException, SQLFeatureNotSupportedException {
	Aggregations result = query(String.format("SELECT MIN(age) FROM %s/account", TEST_INDEX_ACCOUNT));
	Min min = result.get("MIN(age)");
	assertThat(min.getValue(), equalTo(20.0));
}
 
开发者ID:NLPchina,项目名称:elasticsearch-sql,代码行数:7,代码来源:AggregationTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NewFolderDialog类代码示例发布时间:2022-05-23
下一篇:
Java Deserializer类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap