コード例 #1
0
 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;
 }
コード例 #2
0
  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;
  }