src/main/java/org/novus/service/IngestorServiceImpl.java
/**
   * This uses the json passed to populate random predefined values and generate ES schema specific json to
   * feed into ES.
   * 
   * @param client
   * @param uploadingFiles
   * @param startIndex
   * @param sampleSize
   * @throws IllegalStateException
   * @throws IOException
   */
This uses the json passed to populate random predefined values and generate ES schema specific json to
feed into ES.


This uses the json passed to populate random predefined values and generate ES schema specific json to feed into ES .
public void jsonGenerator(TransportClient client, String sampleJson, int startIndex, int sampleSize, String index,
      String type) throws IllegalStateException, IOException {
    int endIndex = startIndex + sampleSize;
    BulkRequestBuilder bulkRequest = client.prepareBulk();
    JsonDataGenerator jsonDataGenerator = new JsonDataGeneratorImpl();
    IntStream.range(startIndex, endIndex).parallel().boxed().forEach(count -> {
      try {
        try (InputStream inputStream = new ByteArrayInputStream(sampleJson.getBytes())) {
          ByteArrayOutputStream bis = new ByteArrayOutputStream();
          jsonDataGenerator.generateTestDataJson(inputStream, bis);
          if (System.getProperty("debug", "false").equals("true")) {
            log.debug(bis.toString());
            log.debug("==========");
          }
          String json = bis.toString();
          bulkRequest.add(client.prepareIndex(index, type, count.toString()).setSource(json));
          bis.close();
        } catch (Exception ex) {
          log.error("Error while generating json and feeding to ES", ex);
        }
      } catch (Exception ex) {
        log.error("Error while generating json and feeding to ES", ex);
      }
    });
    bulkRequest.setRefreshPolicy("true");
    final BulkResponse bulkResponse = bulkRequest.execute().actionGet();
    if (bulkResponse.hasFailures()) {
      log.error("============================== failures " + bulkResponse.buildFailureMessage());
    }
  }
public void jsonGenerator ( TransportClient client , String sampleJson , int startIndex , int sampleSize , String index , String type ) throws IllegalStateException , IOException { int endIndex = startIndex + sampleSize ; BulkRequestBuilder bulkRequest = client . prepareBulk ( ) ; JsonDataGenerator jsonDataGenerator = new JsonDataGeneratorImpl ( ) ; IntStream . range ( startIndex , endIndex ) . parallel ( ) . boxed ( ) . forEach ( count -> { try { try ( InputStream inputStream = new ByteArrayInputStream ( sampleJson . getBytes ( ) ) ) { ByteArrayOutputStream bis = new ByteArrayOutputStream ( ) ; jsonDataGenerator . generateTestDataJson ( inputStream , bis ) ; if ( System . getProperty ( "debug" , "false" ) . equals ( "true" ) ) { log . debug ( bis . toString ( ) ) ; log . debug ( "==========" ) ; } String json = bis . toString ( ) ; bulkRequest . add ( client . prepareIndex ( index , type , count . toString ( ) ) . setSource ( json ) ) ; bis . close ( ) ; } catch ( Exception ex ) { log . error ( "Error while generating json and feeding to ES" , ex ) ; } } catch ( Exception ex ) { log . error ( "Error while generating json and feeding to ES" , ex ) ; } } ) ; bulkRequest . setRefreshPolicy ( "true" ) ; final BulkResponse bulkResponse = bulkRequest . execute ( ) . actionGet ( ) ; if ( bulkResponse . hasFailures ( ) ) { log . error ( "============================== failures " + bulkResponse . buildFailureMessage ( ) ) ; } }
This uses the json passed to populate random predefined values and generate ES schema specific json to
 feed into ES.
This uses the json passed to populate random predefined values and generate ES schema specific json to feed into ES .