use of com.thinkbiganalytics.search.rest.model.TableSearchResultData in project kylo by Teradata.
the class ElasticSearchRestSearchResultTransform method getTableSearchResultData.
private TableSearchResultData getTableSearchResultData(ElasticSearchRestSearchHit elasticSearchRestSearchHit) {
final String KYLO_SCHEMA = "kylo_schema";
final String KYLO_TABLE = "kylo_table";
final String POST_DATE = "post_date";
TableSearchResultData tableSearchResultData = new TableSearchResultData();
tableSearchResultData.setSchemaName(elasticSearchRestSearchHit.findValueForKeyInSourceWithDefault(KYLO_SCHEMA, EMPTY_STRING).toString());
tableSearchResultData.setTableName(elasticSearchRestSearchHit.findValueForKeyInSourceWithDefault(KYLO_TABLE, EMPTY_STRING).toString());
List<Pair> columnNamesAndValues = new ArrayList<>();
List<Pair> highlightsList = new ArrayList<>();
for (Pair sourcePairInRestSearchHit : elasticSearchRestSearchHit.getSource()) {
String key = sourcePairInRestSearchHit.getKey();
if (!((key.equals(POST_DATE)) || (key.equals(KYLO_SCHEMA)) || (key.equals(KYLO_TABLE)))) {
columnNamesAndValues.add(sourcePairInRestSearchHit);
}
}
highlightsList.addAll(elasticSearchRestSearchHit.getHighlights());
tableSearchResultData.setHighlights(highlightsList);
tableSearchResultData.setColumnNamesAndValues(columnNamesAndValues);
Map<String, Object> rawData = new HashMap<>();
rawData.put(RAW_DATA_KEY, elasticSearchRestSearchHit.getRawHit());
tableSearchResultData.setRawData(rawData);
tableDataTypeResultCount += 1L;
return tableSearchResultData;
}
use of com.thinkbiganalytics.search.rest.model.TableSearchResultData in project kylo by Teradata.
the class SolrSearchResultTransform method getTableSearchResultData.
private TableSearchResultData getTableSearchResultData(Map<String, Object> solrDocumentFieldValueMap, QueryResponse solrResponse) {
TableSearchResultData tableSearchResultData = new TableSearchResultData();
tableSearchResultData.setSchemaName(solrDocumentFieldValueMap.get("kylo_schema").toString());
tableSearchResultData.setTableName(solrDocumentFieldValueMap.get("kylo_table").toString());
List<Pair> columnNamesAndValues = new ArrayList<>();
List<Pair> highlightsList = new ArrayList<>();
for (Map.Entry<String, Object> entry : solrDocumentFieldValueMap.entrySet()) {
String key = entry.getKey();
if (!(key.equals("kylo_collection") || key.equals("kylo_schema") || key.equals("kylo_table") || key.equals("_version_") || key.equals("id"))) {
columnNamesAndValues.add(new Pair(key, entry.getValue()));
}
}
// Only retrieve the highlights for this search result
for (Map.Entry<String, List<String>> entry : solrResponse.getHighlighting().get(solrDocumentFieldValueMap.get("id")).entrySet()) {
if (entry.getValue().size() >= 1) {
highlightsList.add(new Pair(entry.getKey(), entry.getValue().get(0)));
}
}
tableSearchResultData.setHighlights(highlightsList);
tableSearchResultData.setColumnNamesAndValues(columnNamesAndValues);
tableSearchResultData.setRawData(solrDocumentFieldValueMap);
tableDataTypeResultCount += 1L;
return tableSearchResultData;
}
use of com.thinkbiganalytics.search.rest.model.TableSearchResultData in project kylo by Teradata.
the class ElasticSearchSearchResultTransform method getTableSearchResultData.
private TableSearchResultData getTableSearchResultData(SearchHit searchHit) {
final String KYLO_SCHEMA = "kylo_schema";
final String KYLO_TABLE = "kylo_table";
final String POST_DATE = "post_date";
Map<String, Object> searchHitSourceMap = searchHit.sourceAsMap();
TableSearchResultData tableSearchResultData = new TableSearchResultData();
tableSearchResultData.setSchemaName(searchHitSourceMap.get(KYLO_SCHEMA).toString());
tableSearchResultData.setTableName(searchHitSourceMap.get(KYLO_TABLE).toString());
List<Pair> columnNamesAndValues = new ArrayList<>();
List<Pair> highlightsList = new ArrayList<>();
for (Map.Entry<String, Object> entry : searchHitSourceMap.entrySet()) {
String key = entry.getKey();
if (!((key.equals(POST_DATE)) || (key.equals(KYLO_SCHEMA)) || (key.equals(KYLO_TABLE)))) {
columnNamesAndValues.add(new Pair(key, entry.getValue()));
}
}
Map<String, HighlightField> highlights = searchHit.getHighlightFields();
for (Map.Entry<String, HighlightField> entry : highlights.entrySet()) {
if (entry.getValue().getFragments().length >= 1) {
highlightsList.add(new Pair(entry.getKey(), entry.getValue().getFragments()[0].toString()));
}
}
tableSearchResultData.setHighlights(highlightsList);
tableSearchResultData.setColumnNamesAndValues(columnNamesAndValues);
tableSearchResultData.setRawData(searchHit.getSource());
tableDataTypeResultCount += 1L;
return tableSearchResultData;
}
Aggregations