@Override @SuppressWarnings("unchecked") public Object run() { ArrayList<Long> transactions = (ArrayList<Long>) agg.get(InitScriptFactory.TRANSACTIONS_FIELD); ScriptDocValues.Longs amount = (ScriptDocValues.Longs) doc().get("amount"); ScriptDocValues.Strings type = (ScriptDocValues.Strings) doc().get("type"); if ("sale".equals(type.getValue())) { transactions.add(amount.getValue()); } else { transactions.add(-amount.getValue()); } return null; } }
result = Long.toString(((ScriptDocValues.Longs) field).getValue());
@Override @SuppressWarnings("unchecked") public Object run() { // First we get field using doc lookup ScriptDocValues<Long> docValue = (ScriptDocValues<Long>) doc().get(fieldName); // Check if field exists if (docValue != null && !docValue.isEmpty()) { try { // Try to parse it as an integer BigInteger bigInteger = BigInteger.valueOf(((Longs) docValue).getValue()); // Check if it's prime return bigInteger.isProbablePrime(certainty); } catch (NumberFormatException ex) { return false; } } return false; }
public MutableDateTime getDate() { date.setMillis(getValue()); return date; }