Hi,
I have an index with objects that look like this:
{
a : [
{ x:1, y:2 },
{ x:2, y:3 },
]
}
I'd like to get only the "x" members from the array objects. I expected
that specifying "a.x" in the fields list would work and return something
like:
{
a: [
{ x:1 },
{ x:2 }
]
}
but it doesn't. It just doesn't return anything.
Hi,
I have an index with objects that look like this:
{
a : [
{ x:1, y:2 },
{ x:2, y:3 },
]
}
I'd like to get only the "x" members from the array objects. I expected
that specifying "a.x" in the fields list would work and return something
like:
{
a: [
{ x:1 },
{ x:2 }
]
}
but it doesn't. It just doesn't return anything.
Only : curl 'localhost:9200/test/_search?q=&fields=_source.a'
Works and returns the object "a" but: curl
'localhost:9200/test/_search?q=&fields=_source.a.x'
Doesn't return anything again.
Only : curl 'localhost:9200/test/_search?q=&fields=_source.a'
Works and returns the object "a" but: curl
'localhost:9200/test/_search?q=&fields=_source.a.x'
Doesn't return anything again.
Thanks Shay, tested now with 0.18.5 and it does indeed work as you said,
however it feels to me the response should be structured differently.
Since ElasticSearch is document oriented I would expect the search result
to keep the original document's structure, but limit the returned fields to
the requested ones, so my expectation would be to get back:
{
a: [
{ x:1 },
{ x:2 }
]
}
not:
{
a.x: [1, 2]
}
This becomes more apparent if you fetch multiple fields, the original
document structure is completely lost. By the way, if you do the same thing
with MongoDB you get back a structure like I would expect.
I understand, but this is how it works. I find it more usable the way it
works currently (and less "noisy" in terms of data), especially if we are
talking about "deep" navigation. But, its possible to provide other
formats...
Thanks Shay, tested now with 0.18.5 and it does indeed work as you said,
however it feels to me the response should be structured differently.
Since Elasticsearch is document oriented I would expect the search result
to keep the original document's structure, but limit the returned fields to
the requested ones, so my expectation would be to get back:
{
a: [
{ x:1 },
{ x:2 }
]
}
not:
{
a.x: [1, 2]
}
This becomes more apparent if you fetch multiple fields, the original
document structure is completely lost. By the way, if you do the same thing
with MongoDB you get back a structure like I would expect.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.