Writting aggregation queries in Elastic search


(Praveenkumar Arepalli) #1

I want to achieve following query in elasticsearch.
select max(creationDate - updatedDate) from sudentTable;

how to write above query?

elasticsearch verison is v1.1.1

select max(creationDate) from sudentTable; is writtren like below

public static void max() {
final searchRequestBuilder builder = getClient().prepareSearch("indexname").
setTypes("type1");
MaxBuilder mx = AggregationBuilders.max("maxDate");
mx.field("creationDate");
builder.addAggregation(mx);
System.out.print("builders:::"+builder);
Aggregations ag = builder.execute().actionGet().getAggregations();
InternalMax inMx = ag.get("maxDate");
System.out.print("aggg::"+inMx.getValue()+"\n");
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e0041d6c-5ce3-4aeb-88fb-cc3638a8cf6c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Praveenkumar Arepalli) #2

https://programmers.stackexchange.com/questions/249688/how-can-i-get-buckets-from-aggregation-querythis-is-belongs-to-elasticsearch

Please check above question
On Saturday, July 12, 2014 7:27:35 PM UTC+5:30, Praveenkumar Arepalli wrote:

I want to achieve following query in elasticsearch.
select max(creationDate - updatedDate) from sudentTable;

how to write above query?

elasticsearch verison is v1.1.1

select max(creationDate) from sudentTable; is writtren like below

public static void max() {
final searchRequestBuilder builder = getClient().prepareSearch("indexname"
).setTypes("type1");
MaxBuilder mx = AggregationBuilders.max("maxDate");
mx.field("creationDate");
builder.addAggregation(mx);
System.out.print("builders:::"+builder);
Aggregations ag = builder.execute().actionGet().getAggregations();
InternalMax inMx = ag.get("maxDate");
System.out.print("aggg::"+inMx.getValue()+"\n");
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e2c2418e-2fdb-49fc-b06c-b665f239c0a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #3