Hey Shay,
I understand but as a Java programmer, I still feel uncomfortable:
getting back a List is ok as well as an Object, but those together is
not good; Reason is simply any List is also an object, so to be it
correctly it's just:
String name;
Object value;
and in case you get back many objects the value is an Object of
interface type List, meaning a single List object
Also in runtime its not sure if you will get back a single object or a
list (remember, we have no schema usually), so you need to care anyway
with the danger of getting an Object holding other object's in it;
Following that, the logical consequence for regular SearchHit's is to
strip the class as same behaviour can be achived by giving back a
Map<String, Object>;
Best
On 12 Mrz., 08:13, Shay Banon shay.ba...@elasticsearch.com wrote:
A field, when stored / executed as a script, can be retrieved, and when fetched, it can be of different types (numeric, string, and so on). Thats the reason why the type if Object, if you want the String representation, you can call toString on it.
The reason why it has both value() and values() is because a field can have several values for it indexed (for example, an array of values). So, when stored, you can get the list of values associated with it (in which case, the value method will just return the first one). The reason its a List is because it maintains the order of the values indexed.On Friday, March 11, 2011 at 5:09 PM, K.B. wrote:
Hello,
when I get back a SearchHit hit, I can get back the fields with
hit.getFields();
This leads to a Map<String, SearchHitField> where String is the name
of the field and SearchHitField actually is an Interface just having:
String name();
Object value();
List values();
(plus getters with get..);
Actually is there a special reason there is no Map<String, String>
hit.getSimpleFields(); or sth. like that in it as I don*t see the
reason to get back a map of Objects that contains the key as String
name plus and Object Value that is the content of the field (the idea
with List seems bit strange to me - either I get back an
Object thst is instance of List or not - but a List is actually an
Object when it exists as List itself is just a specialized interface
derived from Collection - so, this is not good in terms of OO imho);
Best