I am trying to use multi-index search api of ES in java. The list of indexes over which i will be performing search operation will be known at run-time only. Using below snippet of code i am able to perform search when the indexes are known.
Search search = new Search.Builder(query).addIndex("index1")
.addIndex("index2").addType("type").build();
How can i make it work for a dynamic list which i get on run time?