Source filtering of nested object data

Is it possible to filter the _source of nested data conditionally?

For example, I have nested object data like this:

{
"name" : "Thing",
"children" :
{
"id": "1",
"qty": "4"
},
{
"id": "2",
"qty": "5"
},
{
"id": "3",
"qty": "1"
},
{....}
}

In some cases I will have thousands of 'children' so I don't want to return
them all on every query. I want to be able to just return children with
certain "id" numbers.

Is that possible?

--
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/92f1283a-a8d9-4b2f-8e9e-32c0234c781d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

You could use script_fields to generate the values you want:

may be a bit tricky though :slight_smile:

On 12 March 2014 16:59, Ben Hirsch benhirsch@gmail.com wrote:

Is it possible to filter the _source of nested data conditionally?

For example, I have nested object data like this:

{
"name" : "Thing",
"children" :
{
"id": "1",
"qty": "4"
},
{
"id": "2",
"qty": "5"
},
{
"id": "3",
"qty": "1"
},
{....}
}

In some cases I will have thousands of 'children' so I don't want to
return them all on every query. I want to be able to just return children
with certain "id" numbers.

Is that possible?

--
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/92f1283a-a8d9-4b2f-8e9e-32c0234c781d%40googlegroups.comhttps://groups.google.com/d/msgid/elasticsearch/92f1283a-a8d9-4b2f-8e9e-32c0234c781d%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/CAPt3XKQcdMiBoAu3AhJ-UVbJJUadnELoLK0_i-w-zV7PNegK2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

I will know the 5-10 id's needed to be fetched at run-time. With
script_fields how would I access the children with those specific id's?

On Wednesday, March 12, 2014 4:13:30 PM UTC-4, Clinton Gormley wrote:

You could use script_fields to generate the values you want:
Elasticsearch Platform — Find real-time answers at scale | Elastic

may be a bit tricky though :slight_smile:

On 12 March 2014 16:59, Ben Hirsch <benh...@gmail.com <javascript:>>wrote:

Is it possible to filter the _source of nested data conditionally?

For example, I have nested object data like this:

{
"name" : "Thing",
"children" :
{
"id": "1",
"qty": "4"
},
{
"id": "2",
"qty": "5"
},
{
"id": "3",
"qty": "1"
},
{....}
}

In some cases I will have thousands of 'children' so I don't want to
return them all on every query. I want to be able to just return children
with certain "id" numbers.

Is that possible?

--
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:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/92f1283a-a8d9-4b2f-8e9e-32c0234c781d%40googlegroups.comhttps://groups.google.com/d/msgid/elasticsearch/92f1283a-a8d9-4b2f-8e9e-32c0234c781d%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/c514a614-d255-4b9d-a4b4-976ad52bbb44%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

On 12 March 2014 21:55, Ben Hirsch benhirsch@gmail.com wrote:

I will know the 5-10 id's needed to be fetched at run-time. With
script_fields how would I access the children with those specific id's?

With script fields, you have access to the whole _source field, so you
would need to write a script to step through the _source field and to
extract the values you are interested in into a data structure (eg an array
or hash) which you return.

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