code: public int swapIndex(final String index,
                         final String alias) throws IndexException {
      //IndicesAliasesResponse resp = null;
      try {
        /* index is the index we were just indexing into
         */
  
        final IndicesAdminClient idx = getAdminIdx();
  
        final GetAliasesRequestBuilder igarb = idx.prepareGetAliases(
                alias);
  
        final ActionFuture<GetAliasesResponse> getAliasesAf =
                idx.getAliases(igarb.request());
        final GetAliasesResponse garesp = getAliasesAf.actionGet();
  
        final ImmutableOpenMap<String, List<AliasMetaData>> aliasesmeta =
                garesp.getAliases();
  
        final IndicesAliasesRequestBuilder iarb = idx.prepareAliases();
  
        final Iterator<String> it = aliasesmeta.keysIt();
  
        while (it.hasNext()) {
          final String indexName = it.next();
  
          for (final AliasMetaData amd: aliasesmeta.get(indexName)) {
            if(amd.getAlias().equals(alias)) {
              iarb.removeAlias(indexName, alias);
            }
          }
        }
  
        iarb.addAlias(index, alias);
  
        final ActionFuture<IndicesAliasesResponse> af =
                idx.aliases(iarb.request());
  
        /*resp = */af.actionGet();
  
        return 0;
      } catch (final ElasticsearchException ese) {
        // Failed somehow
        error(ese);
        return -1;
      } catch (final IndexException ie) {
        throw ie;
      } catch (final Throwable t) {
        throw new IndexException(t);
      }
    }
docs: Changes the givenm alias to refer tot eh supplied index name
  
  @param index the index we were building
  @param alias to refer to this index
  @return 0 fir ok <0 for not ok
  @throws IndexException