How to retrieve payloads as byte arrays in Java scoring script?

I am working with Elasticsearch 2.1.1. I am writing a native (Java) scoring script plugin by subclassing AbstractDoubleSearchScript. My goal is to iterate all of the payloads for a given term in a given field. I obtain an Iterator of TermPosition as follows:

Iterator<TermPosition> itr = indexLookup().get(myField).get(myTerm).iterator();

So far so good. I can now step through the TermPosition instances, which is great.

Now for the problem: Class org.elasticsearch.search.lookup.TermPosition exposes only the following public methods for retrieving payloads from term occurrences:

public String payloadAsString()
public float payloadAsFloat()
public int payloadAsInt()

Under the hood, of course, payloads are byte arrays. I have a highly customized kind of payload that is not suitable for viewing as String, float or int.

I think it would be easy, and I believe useful for covering many more payload use cases, to add the following method to class TermPosition:

public byte[] payloadAsBytes()

Is there a different way I should be using to step through the payloads of a term of a document as byte arrays that I am perhaps overlooking? If not, does the idea of adding the payloadAsBytes() method seem useful? I am new to the community so a pointer on how to vet such an idea and get it in the queue for development appreciated.

Answering my own question here: Just use the public payload member on TermPosition. This lets you get at a payload as a byte array. Silly I did not see that before :slightly_smiling: