private byte[] extractSource(Document doc, DocumentMapper documentMapper) {
   byte[] source = null;
   Fieldable sourceField = doc.getFieldable(documentMapper.sourceMapper().names().indexName());
   if (sourceField != null) {
     source = documentMapper.sourceMapper().nativeValue(sourceField);
     doc.removeField(documentMapper.sourceMapper().names().indexName());
   }
   return source;
 }
  private FieldSelector buildFieldSelectors(DocumentMapper docMapper, String... fields) {
    if (fields == null) {
      return docMapper.sourceMapper().fieldSelector();
    }

    // don't load anything
    if (fields.length == 0) {
      return null;
    }

    FieldMappersFieldSelector fieldSelector = null;
    for (String fieldName : fields) {
      FieldMappers x = docMapper.mappers().smartName(fieldName);
      if (x != null && x.mapper().stored()) {
        if (fieldSelector == null) {
          fieldSelector = new FieldMappersFieldSelector();
        }
        fieldSelector.add(x);
      }
    }

    return fieldSelector;
  }