Two Dimensional Facet


(Yehuda Zargarov) #1

Is there a way to create a facet on two fields all together?

For example, lets say I have this type:

revenue: {

properties: {
product_id: {
type: string
}
package_type_code: {
type: string
}
sum: {
type: integer
}}

}

I want to get the *sum *per *product_id *per package_type_code.
*
*
Is there a way to do that?

Thanks

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


(Alexander Reelsen) #2

Hey,

you could use a statistical facet using a script and concatenate product id
and package type code in the script,
http://www.elasticsearch.org/guide/reference/api/search/facets/statistical-facet/

--Alex

On Thu, Aug 22, 2013 at 9:33 AM, Yehuda Zargarov yz1583@gmail.com wrote:

Is there a way to create a facet on two fields all together?

For example, lets say I have this type:

revenue: {

properties: {
product_id: {
type: string
}
package_type_code: {
type: string
}
sum: {
type: integer
}}

}

I want to get the *sum *per *product_id *per package_type_code.
*
*
Is there a way to do that?

Thanks

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


(Yehuda Zargarov) #3

Statistical works only on numeric fields (package type code is a string)..

On Thursday, August 22, 2013 1:10:13 PM UTC+3, Alexander Reelsen wrote:

Hey,

you could use a statistical facet using a script and concatenate product
id and package type code in the script,

http://www.elasticsearch.org/guide/reference/api/search/facets/statistical-facet/

--Alex

On Thu, Aug 22, 2013 at 9:33 AM, Yehuda Zargarov <yz1...@gmail.com<javascript:>

wrote:

Is there a way to create a facet on two fields all together?

For example, lets say I have this type:

revenue: {

properties: {
product_id: {
type: string
}
package_type_code: {
type: string
}
sum: {
type: integer
}}

}

I want to get the *sum *per *product_id *per package_type_code.
*
*
Is there a way to do that?

Thanks

--
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 elasticsearc...@googlegroups.com <javascript:>.
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.
For more options, visit https://groups.google.com/groups/opt_out.


(Matt Weber) #4

Aggregations is what you need, but they are not available yet. Keep an
eye on master on GitHub, it shouldn't be too long until they pop up.

Thanks,
Matt Weber

On Thursday, August 22, 2013, Yehuda Zargarov wrote:

Statistical works only on numeric fields (package type code is a string)..

On Thursday, August 22, 2013 1:10:13 PM UTC+3, Alexander Reelsen wrote:

Hey,

you could use a statistical facet using a script and concatenate product
id and package type code in the script,
http://www.elasticsearch.org/guide/reference/api/search/
facets/statistical-facet/http://www.elasticsearch.org/guide/reference/api/search/facets/statistical-facet/

--Alex

On Thu, Aug 22, 2013 at 9:33 AM, Yehuda Zargarov yz1...@gmail.comwrote:

Is there a way to create a facet on two fields all together?

For example, lets say I have this type:

revenue: {

properties: {
product_id: {
type: string
}
package_type_code: {
type: string
}
sum: {
type: integer
}}

}

I want to get the *sum *per *product_id *per package_type_code.
*
*
Is there a way to do that?

Thanks

--
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 elasticsearc...@**googlegroups.com.
For more options, visit https://groups.google.com/**groups/opt_outhttps://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 <javascript:_e({},
'cvml', 'elasticsearch%2Bunsubscribe@googlegroups.com');>.
For more options, visit https://groups.google.com/groups/opt_out.

--
Thanks,
Matt Weber

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


(lebowitz) #5

I think Alex's suggestion will work. You'd concatenate the two grouped fields and the sum is the numeric.

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


(Alexander Reelsen) #6

Hey,

you are right regarding statistical only working on numeric fields. But
that is the value, and your value is the sum field. The key (used for the
grouping) can be a string. And in your case the key needs to be a
concatenation of product_id and package_type_code

Something along these lines should help (on the top of may head, havent
looked into the docs, still lacking some coffee...

"facets" : {
"stats" : {
"statistical" : {
"script" : "doc['product_id'].value :
doc['package_type_code'].value"
}
}
}

--Alex

On Thu, Aug 22, 2013 at 1:14 PM, Yehuda Zargarov yz1583@gmail.com wrote:

Statistical works only on numeric fields (package type code is a string)..

On Thursday, August 22, 2013 1:10:13 PM UTC+3, Alexander Reelsen wrote:

Hey,

you could use a statistical facet using a script and concatenate product
id and package type code in the script,
http://www.elasticsearch.org/guide/reference/api/search/
facets/statistical-facet/http://www.elasticsearch.org/guide/reference/api/search/facets/statistical-facet/

--Alex

On Thu, Aug 22, 2013 at 9:33 AM, Yehuda Zargarov yz1...@gmail.comwrote:

Is there a way to create a facet on two fields all together?

For example, lets say I have this type:

revenue: {

properties: {
product_id: {
type: string
}
package_type_code: {
type: string
}
sum: {
type: integer
}}

}

I want to get the *sum *per *product_id *per package_type_code.
*
*
Is there a way to do that?

Thanks

--
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 elasticsearc...@**googlegroups.com.

For more options, visit https://groups.google.com/**groups/opt_outhttps://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.
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.
For more options, visit https://groups.google.com/groups/opt_out.


(jminard) #7

This is likely to use a lot of memory (each value will be loaded into
memory), and perform badly. Great for prototyping but likely you should
create a concatenated field of the combined values; then just use that. It
will then perform the same as any other field.

-- Jayson

On Friday, August 23, 2013 9:03:21 AM UTC+2, Alexander Reelsen wrote:

Hey,

you are right regarding statistical only working on numeric fields. But
that is the value, and your value is the sum field. The key (used for the
grouping) can be a string. And in your case the key needs to be a
concatenation of product_id and package_type_code

Something along these lines should help (on the top of may head, havent
looked into the docs, still lacking some coffee...

"facets" : {
"stats" : {
"statistical" : {
"script" : "doc['product_id'].value :
doc['package_type_code'].value"
}
}
}

--Alex

On Thu, Aug 22, 2013 at 1:14 PM, Yehuda Zargarov <yz1...@gmail.com<javascript:>

wrote:

Statistical works only on numeric fields (package type code is a string)..

On Thursday, August 22, 2013 1:10:13 PM UTC+3, Alexander Reelsen wrote:

Hey,

you could use a statistical facet using a script and concatenate product
id and package type code in the script,
http://www.elasticsearch.org/guide/reference/api/search/
facets/statistical-facet/http://www.elasticsearch.org/guide/reference/api/search/facets/statistical-facet/

--Alex

On Thu, Aug 22, 2013 at 9:33 AM, Yehuda Zargarov yz1...@gmail.comwrote:

Is there a way to create a facet on two fields all together?

For example, lets say I have this type:

revenue: {

properties: {
product_id: {
type: string
}
package_type_code: {
type: string
}
sum: {
type: integer
}}

}

I want to get the *sum *per *product_id *per package_type_code.
*
*
Is there a way to do that?

Thanks

--
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 elasticsearc...@**googlegroups.com.

For more options, visit https://groups.google.com/**groups/opt_outhttps://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 elasticsearc...@googlegroups.com <javascript:>.
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.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #8