The method *getIndexNamed* is only used for *Union* schemas and gives the index of the union's type, so 0 for "null" and 1 for "string" in this case. The *persistent.getSchema()* returns the *Record Schema* in this case and the get *getField* method on that gets the field. *Fields* however are not *Schemas* so you have to call the *schema() *method to get that. If you wanted the index of the "string" union you would call the following:
int unionIndex = persistent.getSchema().getField(fieldName).*schema()*. getIndexNamed("string");
But this is not what you want, I think, so the following is the best way as you have discovered:
int fieldIndex = persistent.getSchema().getField(fieldName).pos();
Regards Rob Turner. On 27 January 2014 19:39, Lewis John Mcgibbney <[EMAIL PROTECTED]>wrote: Cheers Rob.
Yeah thanks for the explanation. It's working like a charm now. Thanks very much. Lewis
NEW: Monitor These Apps!
Apache Lucene, Apache Solr and all other Apache Software Foundation project and their respective logos are trademarks of the Apache Software Foundation.
Elasticsearch, Kibana, Logstash, and Beats are trademarks of Elasticsearch BV, registered in the U.S. and in other countries. This site and Sematext Group is in no way affiliated with Elasticsearch BV.
Service operated by Sematext