public int reindex(String sourceIndex, String sourceType, String targetIndex) throws IOException {
        logger.debug("reindex [{}]/[{}] -> [{}]/[doc]", sourceIndex, sourceType, targetIndex);

        String reindexQuery = "{  \"source\": {\n" +
                "    \"index\": \"" + sourceIndex + "\",\n" +
                "    \"type\": \"" + sourceType + "\"\n" +
                "  },\n" +
                "  \"dest\": {\n" +
                "    \"index\": \"" + targetIndex + "\",\n" +
                "    \"type\": \"doc\"\n" +
                "  }\n" +
                "}\n";

        logger.trace("{}", reindexQuery);

        HttpEntity entity = EntityBuilder.create().setText(reindexQuery).setContentType(ContentType.APPLICATION_JSON).build();
        Response restResponse = lowLevelClient.performRequest("POST", "/_reindex", Collections.emptyMap(), entity);
        Map<String, Object> response = asMap(restResponse);
        logger.debug("reindex response: {}", response);

        return (response == null ? -1 : (int) response.get("total"));
    }
public int reindex ( String sourceIndex , String sourceType , String targetIndex ) throws IOException { logger . debug ( "reindex [{}]/[{}] -> [{}]/[doc]" , sourceIndex , sourceType , targetIndex ) ; String reindexQuery = "{  \"source\": {\n" + "    \"index\": \"" + sourceIndex + "\",\n" + "    \"type\": \"" + sourceType + "\"\n" + "  },\n" + "  \"dest\": {\n" + "    \"index\": \"" + targetIndex + "\",\n" + "    \"type\": \"doc\"\n" + "  }\n" + "}\n" ; logger . trace ( "{}" , reindexQuery ) ; HttpEntity entity = EntityBuilder . create ( ) . setText ( reindexQuery ) . setContentType ( ContentType . APPLICATION_JSON ) . build ( ) ; Response restResponse = lowLevelClient . performRequest ( "POST" , "/_reindex" , Collections . emptyMap ( ) , entity ) ; Map < String , Object > response = asMap ( restResponse ) ; logger . debug ( "reindex response: {}" , response ) ; return ( response == null ? - 1 : ( int ) response . get ( "total" ) ) ; }
Reindex data from one index/type to another index
@param sourceIndex source index name
@param sourceType source type name
@param targetIndex target index name
@return The number of documents that have been reindexed
@throws IOException In case of error