org.elasticsearch.plugin.nlpcn.ElasticResultHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of elasticsearch-sql Show documentation
Show all versions of elasticsearch-sql Show documentation
Query elasticsearch using SQL
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.sourceAsMap(),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