Is there anyway to stop arrays with one element from being returned as a single value

I'm using elasticsearch as my main database. I'm using some fields as
arrays, and always upload arrays for those fields even if there's only one
element in the array. The _source always contains the unchanged array, but
a search request with specific fields converts arrays with a single element
into a single value. Is there a way to prevent this behaviour?

--
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 Raja,

There is no way just yet but we are working on a solution (
Add finer control over `_source` retrieval, in `get`, `mget`, `get_source`, `explain` & `search` API · Issue #3301 · elastic/elasticsearch · GitHub ). This
behaviour has to do with the original intention of the fields parameter -
exposing lucene stored fields. If you are using the search API you can use
partial_fields instead, which will leave the array intact

Cheers,
Boaz

On Monday, July 8, 2013 5:07:25 PM UTC+2, Raja Mukherji wrote:

I'm using elasticsearch as my main database. I'm using some fields as
arrays, and always upload arrays for those fields even if there's only one
element in the array. The _source always contains the unchanged array, but
a search request with specific fields converts arrays with a single element
into a single value. Is there a way to prevent this behaviour?

--
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 Boaz,

Thanks, that works fine except for one case it seems. If I request a field
"objectfield" of type object with "fields", the object value is returned.
However for "partial_fields", I have to request "objectfield.*", requesting
"objectfield" on its own does not return anything. I can work around this
for now though.

Also, since partial_fields is meant to match on wildcards, is there a
performance penalty compared to just fields?

Thanks,
Raja

On Tuesday, 9 July 2013 13:13:18 UTC+1, Boaz Leskes wrote:

Hi Raja,

There is no way just yet but we are working on a solution (
Add finer control over `_source` retrieval, in `get`, `mget`, `get_source`, `explain` & `search` API · Issue #3301 · elastic/elasticsearch · GitHub ). This
behaviour has to do with the original intention of the fields parameter -
exposing lucene stored fields. If you are using the search API you can use
partial_fields instead, which will leave the array intact -
Elasticsearch Platform — Find real-time answers at scale | Elastic

Cheers,
Boaz

On Monday, July 8, 2013 5:07:25 PM UTC+2, Raja Mukherji wrote:

I'm using elasticsearch as my main database. I'm using some fields as
arrays, and always upload arrays for those fields even if there's only one
element in the array. The _source always contains the unchanged array, but
a search request with specific fields converts arrays with a single element
into a single value. Is there a way to prevent this behaviour?

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

Yeah - directly selecting objects (i.e. "obj" for { obj: { field: 1 } } ,
instead of "obj.*") is something I recently added and will be out with the
next release.

As to overhead - if you are using fields to access lucene stored fields it
may be faster because it doesn't need to load the _source. How ever, if you
retrieving many fields, it might be faster to just load the source once.
For _source extraction wild cards have a small overhead but it is very
minor.

On Tue, Jul 9, 2013 at 5:10 PM, Raja Mukherji rajamukherji@gmail.comwrote:

Hi Boaz,

Thanks, that works fine except for one case it seems. If I request a field
"objectfield" of type object with "fields", the object value is returned.
However for "partial_fields", I have to request "objectfield.*", requesting
"objectfield" on its own does not return anything. I can work around this
for now though.

Also, since partial_fields is meant to match on wildcards, is there a
performance penalty compared to just fields?

Thanks,
Raja

On Tuesday, 9 July 2013 13:13:18 UTC+1, Boaz Leskes wrote:

Hi Raja,

There is no way just yet but we are working on a solution (
https://github.com/**elasticsearch/elasticsearch/**issues/3301https://github.com/elasticsearch/elasticsearch/issues/3301). This behaviour has to do with the original intention of the fields
parameter - exposing lucene stored fields. If you are using the search API
you can use partial_fields instead, which will leave the array intact -
http://www.elasticsearch.**org/guide/reference/api/**search/fields/http://www.elasticsearch.org/guide/reference/api/search/fields/

Cheers,
Boaz

On Monday, July 8, 2013 5:07:25 PM UTC+2, Raja Mukherji wrote:

I'm using elasticsearch as my main database. I'm using some fields as
arrays, and always upload arrays for those fields even if there's only one
element in the array. The _source always contains the unchanged array, but
a search request with specific fields converts arrays with a single element
into a single value. Is there a way to prevent this behaviour?

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/1NEk7MXnMM8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

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

Sounds good, I'll look forward to the next release so.

Thanks again.

On Tuesday, 9 July 2013 16:54:06 UTC+1, Boaz Leskes wrote:

Yeah - directly selecting objects (i.e. "obj" for { obj: { field: 1 } } ,
instead of "obj.*") is something I recently added and will be out with the
next release.

As to overhead - if you are using fields to access lucene stored fields it
may be faster because it doesn't need to load the _source. How ever, if you
retrieving many fields, it might be faster to just load the source once.
For _source extraction wild cards have a small overhead but it is very
minor.

On Tue, Jul 9, 2013 at 5:10 PM, Raja Mukherji <rajamu...@gmail.com<javascript:>

wrote:

Hi Boaz,

Thanks, that works fine except for one case it seems. If I request a
field "objectfield" of type object with "fields", the object value is
returned. However for "partial_fields", I have to request "objectfield.*",
requesting "objectfield" on its own does not return anything. I can work
around this for now though.

Also, since partial_fields is meant to match on wildcards, is there a
performance penalty compared to just fields?

Thanks,
Raja

On Tuesday, 9 July 2013 13:13:18 UTC+1, Boaz Leskes wrote:

Hi Raja,

There is no way just yet but we are working on a solution (
https://github.com/**elasticsearch/elasticsearch/**issues/3301https://github.com/elasticsearch/elasticsearch/issues/3301). This behaviour has to do with the original intention of the fields
parameter - exposing lucene stored fields. If you are using the search API
you can use partial_fields instead, which will leave the array intact -
http://www.elasticsearch.**org/guide/reference/api/**search/fields/http://www.elasticsearch.org/guide/reference/api/search/fields/

Cheers,
Boaz

On Monday, July 8, 2013 5:07:25 PM UTC+2, Raja Mukherji wrote:

I'm using elasticsearch as my main database. I'm using some fields as
arrays, and always upload arrays for those fields even if there's only one
element in the array. The _source always contains the unchanged array, but
a search request with specific fields converts arrays with a single element
into a single value. Is there a way to prevent this behaviour?

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/1NEk7MXnMM8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

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