Different results with fields vs script_field using terms facet

Shouldn't these two queries return the same result? That doesn't seem to
be the case. The first query returns the correct result. But the second
one does not. It seems that the second query does not properly handle the
fact that there are multiple instances. The sum of counts from the first
query correctly exceed the number of documents since there are multiple
instances in each document. However, it seems the sum of counts in the
second query equals the total number of documents so it isn't "flattening"
out the instances.

Our documents have a map of entities, each entity has an array of
instances, each instance has an attributes object.

Is this the intended behavior?

Thanks,
Adam

POST /_search
{
"size": 0,
"facets": {
"results": {
"terms": {
"field": "entities.B.instances.attributes.name"
}
}
}
}

{
"size": 0,
"facets": {
"results": {
"terms": {
"script_field":
"doc['entities.B.instances.attributes.name'].value"
}
}
}
}

Build:
1.0.0.Beta2-SNAPSHOT

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

Anybody else see this? This is with 1.0.0.Beta2-SNAPSHOT so could be a
new bug...

On Thursday, November 14, 2013 9:52:34 AM UTC-6, Adam H wrote:

Shouldn't these two queries return the same result? That doesn't seem to
be the case. The first query returns the correct result. But the second
one does not. It seems that the second query does not properly handle the
fact that there are multiple instances. The sum of counts from the first
query correctly exceed the number of documents since there are multiple
instances in each document. However, it seems the sum of counts in the
second query equals the total number of documents so it isn't "flattening"
out the instances.

Our documents have a map of entities, each entity has an array of
instances, each instance has an attributes object.

Is this the intended behavior?

Thanks,
Adam

POST /_search
{
"size": 0,
"facets": {
"results": {
"terms": {
"field": "entities.B.instances.attributes.name"
}
}
}
}

{
"size": 0,
"facets": {
"results": {
"terms": {
"script_field": "doc['entities.B.instances.attributes.name
'].value"
}
}
}
}

Build:
1.0.0.Beta2-SNAPSHOT

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

Hi Adam

The doc.value always returns the first value of a multi-valued field
: Elasticsearch Platform — Find real-time answers at scale | Elastic

If you use the doc.values which returns an array of all values, they
should be identical.

Cheers,
Boaz

On Monday, November 18, 2013 4:54:16 PM UTC+1, Adam H wrote:

Anybody else see this? This is with 1.0.0.Beta2-SNAPSHOT so could be a
new bug...

On Thursday, November 14, 2013 9:52:34 AM UTC-6, Adam H wrote:

Shouldn't these two queries return the same result? That doesn't seem to
be the case. The first query returns the correct result. But the second
one does not. It seems that the second query does not properly handle the
fact that there are multiple instances. The sum of counts from the first
query correctly exceed the number of documents since there are multiple
instances in each document. However, it seems the sum of counts in the
second query equals the total number of documents so it isn't "flattening"
out the instances.

Our documents have a map of entities, each entity has an array of
instances, each instance has an attributes object.

Is this the intended behavior?

Thanks,
Adam

POST /_search
{
"size": 0,
"facets": {
"results": {
"terms": {
"field": "entities.B.instances.attributes.name"
}
}
}
}

{
"size": 0,
"facets": {
"results": {
"terms": {
"script_field": "doc['entities.B.instances.attributes.name
'].value"
}
}
}
}

Build:
1.0.0.Beta2-SNAPSHOT

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