Java Code Examples for org.elasticsearch.index.fielddata.ScriptDocValues#Longs

The following examples show how to use org.elasticsearch.index.fielddata.ScriptDocValues#Longs . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MapScriptFactory.java    From elasticsearch-native-script-example with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 2
Source File: AbstractSearchScript.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
/**
 * Returns field data long (integers) access for the provided field.
 */
protected ScriptDocValues.Longs docFieldLongs(String field) {
    return (ScriptDocValues.Longs) doc().get(field);
}
 
Example 3
Source File: AtomicLongFieldData.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public final ScriptDocValues getScriptValues() {
    return new ScriptDocValues.Longs(getLongValues());
}