Refactored code so that it uses the Java API. IndexSelection is not handled at Transport-level, not Rest-level