All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.vertexium.elasticsearch.utils.GetResponseUtil Maven / Gradle / Ivy

There is a newer version: 3.0.4
Show newest version
package org.vertexium.elasticsearch.utils;

import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.index.get.GetField;

public class GetResponseUtil {
    public static String getFieldValueString(GetResponse getResponse, String fieldName) {
        GetField field = getResponse.getField(fieldName);
        if (field == null) {
            return null;
        }
        return (String) field.getValue();
    }

    public static Long getFieldValueLong(GetResponse getResponse, String fieldName) {
        GetField field = getResponse.getField(fieldName);
        if (field == null) {
            return null;
        }
        Object value = field.getValue();
        if (value instanceof Integer) {
            return ((Integer) value).longValue();
        }
        return (Long) value;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy