Double Counting in Multi Field Facet Search

Hi,

I'm having a problem with double counting in facet results. I've got
several types in the same index
where the structure of some of the different types is quite similar. When I
use a multi-field facet
and include a field that's in one type, it counts it in all types. If I
include the fields from both types,
that I get double counted results. Is this what's expected? Also, it
seems to work differently if I use a single field facet.

Here's a simplified example. Say I want to get a count of 'towns' from
these 4 docs:

curl -XPUT $ES/example/policeman/policeman1 -d '{
"name": "Policeman 1",
"addresses": [
{
"streetAddress": "1 Example Road",
"town": "OneTown"
}
]
}'

curl -XPUT $ES/example/policeman/policeman2 -d ' {
"name": "Policeman 2",
"addresses": [
{
"streetAddress": "2 Example Road",
"town": "OneTown"
}
]
}'

curl -XPUT $ES/example/fireman/fireman1 -d '{
"name": "Fireman Sam",
"addresses": [
{
"streetAddress": "2 Example Road",
"town": "OneTown"
}
]
}'

curl -XPUT $ES/example/fireman/fireman2 -d '{
"name": "Fireman Dave",
"addresses": [
{
"streetAddress": "2 Other Road",
"town": "TwoTown"
}
]
}'

If i do:

$ curl -XPOST $ES/example/_search?pretty=true -d '{
"query" : { "match_all" : { } },
"facets" : {
"town" : { "terms" : { "fields" : ["policeman.addresses.town"] } }
}
}'

I get onetown: 3, twotown: 1. So it counts the towns in both policeman and
fireman types. If i do:

$ curl -XPOST $ES/example/_search?pretty=true -d '{
"query" : { "match_all" : { } },
"facets" : {
"town" : { "terms" : { "fields" : ["policeman.addresses.town",
"fireman.addresses.town"]] } }
}
}'
I get onetown: 6, twotown: 2. So it's counted everything twice.

Thanks
Alistair

--
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.