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

org.elasticsearch.plugin.nlpcn.ElasticResultHandler Maven / Gradle / Ivy

The newest version!
package org.elasticsearch.plugin.nlpcn;

import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.aggregations.Aggregation;
import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * Created by Eliran on 3/10/2015.
 */
public class ElasticResultHandler {
    public static Object getFieldValue(SearchHit hit,String field){
        return deepSearchInMap(hit.getSourceAsMap(),field);
    }

    private static Object deepSearchInMap(Map fieldsMap, String name) {
        if(name.contains(".")){
            String[] path = name.split("\\.");
            Map currentObject = fieldsMap;
            for(int i=0;i) valueFromCurrentMap;
            }
            return currentObject.get(path[path.length-1]);
        }

        return fieldsMap.get(name);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy