Document createDocument ( Entity entity ) { int maxIndexingDepth = entity . getEntityType ( ) . getIndexingDepth ( ) ; XContentBuilder contentBuilder ; try { contentBuilder = XContentFactory . contentBuilder ( JSON ) ; XContentGenerator generator = contentBuilder . generator ( ) ; generator . writeStartObject ( ) ; createRec ( entity , generator , 0 , maxIndexingDepth ) ; generator . writeEndObject ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } String documentId = toElasticsearchId ( entity . getIdValue ( ) ) ; return Document . create ( documentId , contentBuilder ) ; }
Create Elasticsearch document source content from entity