@SuppressWarnings("nls")
    private void indexEntity(String type, String id, XContentBuilder sourceEntity, boolean refresh)
            throws StorageException {
        try {
            String json = sourceEntity.string();
            JestResult response = esClient.execute(new Index.Builder(json).refresh(refresh).index(getIndexName())
                    .setParameter(Parameters.OP_TYPE, "create").type(type).id(id).build());
            if (!response.isSucceeded()) {
                throw new StorageException("Failed to index document " + id + " of type " + type + ": " + response.getErrorMessage());
            }
        } catch (StorageException e) {
            throw e;
        } catch (Exception e) {
            throw new StorageException(e);
        }
    }
@ SuppressWarnings ( "nls" ) private void indexEntity ( String type , String id , XContentBuilder sourceEntity , boolean refresh ) throws StorageException { try { String json = sourceEntity . string ( ) ; JestResult response = esClient . execute ( new Index . Builder ( json ) . refresh ( refresh ) . index ( getIndexName ( ) ) . setParameter ( Parameters . OP_TYPE , "create" ) . type ( type ) . id ( id ) . build ( ) ) ; if ( ! response . isSucceeded ( ) ) { throw new StorageException ( "Failed to index document " + id + " of type " + type + ": " + response . getErrorMessage ( ) ) ; } } catch ( StorageException e ) { throw e ; } catch ( Exception e ) { throw new StorageException ( e ) ; } }
Indexes an entity.
@param type
@param id
@param sourceEntity
@param refresh true if the operation should wait for a refresh before it returns
@throws StorageException