Exemplo n.º 1
0
 @Override
 public OperationStatus write(WriteOperation builder, List<? extends T> t) {
   // TODO: need to gather operation results and return
   OperationStatus status = new OperationStatus();
   if (t.size() == 1) {
     service.index(
         getIndex(),
         getType(),
         mapping.get(t.get(0)),
         AnnotationHelper.getDocumentId(t.get(0), getIdField()));
   } else if (t.size() > 1) {
     List<String> list = new ArrayList<String>();
     for (T o : t) {
       list.add(mapping.get(o));
       // TODO: what do we do with null ids? bail with exception? Report the error with
       // OperationStatus?
     }
     service.bulkIndex(getIndex(), getType(), list.toArray(new String[list.size()]), getIdField());
   }
   status.setSucceeded(true);
   return status;
 }
Exemplo n.º 2
0
 @Override
 public OperationStatus write(T... t) {
   // TODO: Need to gather results from index operation
   OperationStatus status = new OperationStatus();
   if (t.length == 1) {
     service.index(
         getIndex(),
         getType(),
         mapping.get(t[0]),
         AnnotationHelper.getDocumentId(t[0], getIdField()));
   } else if (t.length > 1) {
     List<String> list = new ArrayList<String>();
     for (T o : t) {
       list.add(mapping.get(o));
       // TODO: what do we do with null ids? bail with exception? Report the error with
       // OperationStatus?
     }
     service.bulkIndex(getIndex(), getType(), list.toArray(new String[list.size()]), getIdField());
   }
   status.setSucceeded(true);
   return status;
 }