Object property vs array index


(random35743373) #1

When a field contains an object, in a terms aggregation I can specify a
specific object property that contains the terms I want to use eg

{
"terms": {
"field": "fieldName.propertyContainingTerms"
}
}

So with a array type field that contains a list of strings ["first",
"second", "third"] I should be able to do the same via array indices

{
"terms": {
"field": "fieldName[0]"
}
}

But this doesn't work. Am I using the wrong syntax or is this just not
possible?

My current solution is to use objects with integers converted to strings as
the property keys eg "fieldName.0", it works but feels wrong.

--
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/002d9cd8-04b6-4dec-91a0-d49f5f187a2d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Alexander Reelsen) #2

Hey,

that doesnt work like you want it to work. I am not sure, if I understood
the intention of your query. Do you want to count on all first elements of
all documents or do you just want to filter for that term? If its the
first, maybe a script aggregations can help you, that just returns the
first field of that array.

--Alex

On Thu, Jun 5, 2014 at 12:07 PM, random35743373@googlemail.com wrote:

When a field contains an object, in a terms aggregation I can specify a
specific object property that contains the terms I want to use eg

{
"terms": {
"field": "fieldName.propertyContainingTerms"
}
}

So with a array type field that contains a list of strings ["first",
"second", "third"] I should be able to do the same via array indices

{
"terms": {
"field": "fieldName[0]"
}
}

But this doesn't work. Am I using the wrong syntax or is this just not
possible?

My current solution is to use objects with integers converted to strings
as the property keys eg "fieldName.0", it works but feels wrong.

--
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/002d9cd8-04b6-4dec-91a0-d49f5f187a2d%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/002d9cd8-04b6-4dec-91a0-d49f5f187a2d%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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/CAGCwEM88H%2B9fnXiLKpx5HESfN-N2L5oU4804J8_DF75ygAfp5A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(system) #3