/** Add fields so that they can later be fetched using {@link #getByKey(Object)}. */
public void addWithKey(Object key, IndexableField field) {
if (keyedFields == null) {
keyedFields = new ObjectObjectOpenHashMap<>();
} else if (keyedFields.containsKey(key)) {
throw new ElasticsearchIllegalStateException("Only one field can be stored per key");
}
keyedFields.put(key, field);
add(field);
}