New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make GetField behavior more consitent for multivalued fields. #3015
Conversation
Looks good!, lets backport to 0.90 as well. |
Before this change, the GetField#getValue() method was returning a list of values of a multivalued fields if the field values were obtained from source or if the field was stored and real-time get was used. If the field was stored but non-realtime get was used, GetField#getValue() was returning only the first element and the GetField#getValues() was returning a list of elements. This change makes behavior consistent. GetField#getValue() now always returns only the first value of the field and GetField#getValues() returns the entire list.
For nested types, what should be the expected behavior here? After upgrading to 0.90.1 our ES client code broke semantically since now Even if the mapping is known, there is no way to distinguish an array object type from an "object" object type. This makes it very difficult to proxy elasticsearch queries dynamically (ex. dynamically created queries for which you wouldn't know until runtime which fields are returned ), and requires access to the mapping and manually maintained metadata to know which method to call for a single vs multivalue field. |
I thought about this a little more. Would it be possible to add a new method to |
@imotov: Just curious to your thoughts on this. We don't really have a good solution for working around this right now. Is there another mechanism I'm overlooking? Thank again. |
@btiernay I don't think I fully understand the problem. In elasticsearch any field can be multivalued. There is no "array" type because any field can accept and array of values. Are you trying to distinguish between an array that contains one element and a single element that wasn't passed to elasticsearch as an array? If not, could you provide some examples? |
@imotov: I'm trying to distinguish
from:
So that when a query requesting What I am getting from you is that since ES makes no distinction between the two, it is up to the application to manage this information. Is that correct? |
There is a difference between |
@btiernay there isn't a way today, but we are going to support it pretty soon. In search we actually support it with teh concept of partial fields, and we plan to add it to get, and actually simplify partial fields even more. |
@btiernay I don't think we have a ticket open yet, there should be one open pretty soon where we can brainstorm if needed. |
@kimchy: Awesome thanks again for such a great product :) |
@kimchy Was the feature you mentioned in your previous message ever added? We are struggling with this issue now that we are upgrading from 0.90.1 to 1.4. Cheers. |
…ey produce a list. This change is essentially the same as elastic#3015 but on script fields.
@btiernay, yeah- look for source filtering http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-source-filtering.html |
Before this change, the GetField#getValue() method was returning a list of values of a multivalued fields if the field values were obtained from source or if the field was stored and real-time get was used. If the field was stored but non-realtime get was used, GetField#getValue() was returning only the first element and the GetField#getValues() was returning a list of elements. This change makes behavior consistent. GetField#getValue() now always returns only the first value of the field and GetField#getValues() returns the entire list.