Term stat facets on multiple fields

Hi All,

Using Terms Stats Facet we can create sums, counts and averages etc. of a
value given in one field, aggregated by all values of another field. It's a
way of creating statistical cross-tabs.

Does this feature work on more than one aggregation field? In other words,
if I had a data set of: Building type, year built, area. I want to apply
term stat facets on Year and area.

If my data looks like (this is just sample data):

*BuildingType Year area *
Residential 2004 3500
Residential 2005 3600
Residential 2006 3700
Residential 2007 3800
Residential 2008 3700
Residential 2009 3650
Commerical 2004 14,000
Commercial 2005 15,000

Then i want output as:

Residential min(Year)=2004, max(year)= 2009, min(area)=3500,
max(area)=3800
Commerical min(Year)=2004, max(year)= 2004, min(area)=14000,
max(area)=15000

To apply term stat facet on single column (lets say "area") my query is:

TermsFacetBuilder termsFacetBuilder = FacetBuilders.termsFacet("facet1");
termsFacetBuilder.keyField("BuildingType").valueField("area");

SearchRequestBuilder srb
=client.prepareSearch("TweetIndex").setQuery(qb).setSearchType(SearchType.QUERY_THEN_FETCH).addFacet(termsFacetBuilder);

searchResponse = srb.execute().actionGet();

In search response i am able to get my result if apply facet on single
column.

Could I somehow apply term stat facets on two fields?

--
Thanks & Regards
Hanish Bansal

--
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/CAB0WE8Zntuh3k-1eOX9tckHO4eaCyDnbc0H9%3DjqCRFSLbW94ew%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

You can do this with1.0beta2 that was just released using the new
aggregations functionality. You would create a terms aggregator on
building type and then nest a min and max aggregator for year and area.

Thanks,
Matt Weber
On Dec 2, 2013 9:30 PM, "Hanish Bansal" hanish.bansal.agarwal@gmail.com
wrote:

Hi All,

Using Terms Stats Facet we can create sums, counts and averages etc. of a
value given in one field, aggregated by all values of another field. It's a
way of creating statistical cross-tabs.

Does this feature work on more than one aggregation field? In other words,
if I had a data set of: Building type, year built, area. I want to apply
term stat facets on Year and area.

If my data looks like (this is just sample data):

*BuildingType Year area *
Residential 2004 3500
Residential 2005 3600
Residential 2006 3700
Residential 2007 3800
Residential 2008 3700
Residential 2009 3650
Commerical 2004 14,000
Commercial 2005 15,000

Then i want output as:

Residential min(Year)=2004, max(year)= 2009, min(area)=3500,
max(area)=3800
Commerical min(Year)=2004, max(year)= 2004, min(area)=14000,
max(area)=15000

To apply term stat facet on single column (lets say "area") my query is:

TermsFacetBuilder termsFacetBuilder = FacetBuilders.termsFacet("facet1");
termsFacetBuilder.keyField("BuildingType").valueField("area");

SearchRequestBuilder srb
=client.prepareSearch("TweetIndex").setQuery(qb).setSearchType(SearchType.QUERY_THEN_FETCH).addFacet(termsFacetBuilder);

searchResponse = srb.execute().actionGet();

In search response i am able to get my result if apply facet on single
column.

Could I somehow apply term stat facets on two fields?

--
Thanks & Regards
Hanish Bansal

--
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/CAB0WE8Zntuh3k-1eOX9tckHO4eaCyDnbc0H9%3DjqCRFSLbW94ew%40mail.gmail.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
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/CAJ3KEoDGJKpMkrYZ8oBWGrUnz_Hv18E5_LQZoaJqXNZWjG2RtQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Matt,

Thanks for response !!

I am using elasticsearch-0.90.5.

One way is that apply 2 facets separately and merge the result in-memory
and then i can return the result. But its costly operation.

Is there any other way possible to do this or i'll have to upgrade
Elasticsearch to get this functionality?

On Tue, Dec 3, 2013 at 6:18 AM, Matt Weber matt@mattweber.org wrote:

You can do this with1.0beta2 that was just released using the new
aggregations functionality. You would create a terms aggregator on
building type and then nest a min and max aggregator for year and area.

Elasticsearch Platform — Find real-time answers at scale | Elastic

Elasticsearch Platform — Find real-time answers at scale | Elastic

Thanks,
Matt Weber
On Dec 2, 2013 9:30 PM, "Hanish Bansal" hanish.bansal.agarwal@gmail.com
wrote:

Hi All,

Using Terms Stats Facet we can create sums, counts and averages etc. of a
value given in one field, aggregated by all values of another field. It's a
way of creating statistical cross-tabs.

Does this feature work on more than one aggregation field? In other
words, if I had a data set of: Building type, year built, area. I want to
apply term stat facets on Year and area.

If my data looks like (this is just sample data):

*BuildingType Year area *
Residential 2004 3500
Residential 2005 3600
Residential 2006 3700
Residential 2007 3800
Residential 2008 3700
Residential 2009 3650
Commerical 2004 14,000
Commercial 2005 15,000

Then i want output as:

Residential min(Year)=2004, max(year)= 2009, min(area)=3500,
max(area)=3800
Commerical min(Year)=2004, max(year)= 2004, min(area)=14000,
max(area)=15000

To apply term stat facet on single column (lets say "area") my query is:

TermsFacetBuilder termsFacetBuilder = FacetBuilders.termsFacet("facet1");
termsFacetBuilder.keyField("BuildingType").valueField("area");

SearchRequestBuilder srb
=client.prepareSearch("TweetIndex").setQuery(qb).setSearchType(SearchType.QUERY_THEN_FETCH).addFacet(termsFacetBuilder);

searchResponse = srb.execute().actionGet();

In search response i am able to get my result if apply facet on single
column.

Could I somehow apply term stat facets on two fields?

--
Thanks & Regards
Hanish Bansal

--
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/CAB0WE8Zntuh3k-1eOX9tckHO4eaCyDnbc0H9%3DjqCRFSLbW94ew%40mail.gmail.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
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/CAJ3KEoDGJKpMkrYZ8oBWGrUnz_Hv18E5_LQZoaJqXNZWjG2RtQ%40mail.gmail.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
Thanks & Regards
Hanish Bansal

--
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/CAB0WE8a_E61o8nOySssGeD%2BhiofTfavJjxhyYzKGi3x-ToTZVQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.