Support custom return types for executeCommand & getIndexes

JAVA-1561 & JAVA-1562