use of io.hops.hopsworks.common.elastic.ElasticFeaturestoreHit in project hopsworks by logicalclocks.
the class ElasticFeaturestoreBuilder method setFeatureNameHighlights.
private void setFeatureNameHighlights(SearchHit hitAux, ElasticFeaturestoreDTO result, DatasetAccessController.DatasetAccessCtrl accessCtrl) throws ElasticException, GenericException {
ElasticFeaturestoreHit hit = ElasticFeaturestoreHit.instance(hitAux);
Map<String, HighlightField> highlightFields = hitAux.getHighlightFields();
String featureNameField = FeaturestoreXAttrsConstants.getFeaturestoreElasticKey(FeaturestoreXAttrsConstants.FG_FEATURES, FeaturestoreXAttrsConstants.NAME);
// <highlighted text, name, description>
Function<Triplet<String, String, String>, Boolean> matcher = (state) -> {
// check if highlighted name equals feature name
return removeHighlightTags(state.getValue0()).equals(state.getValue1());
};
BiConsumer<ElasticFeaturestoreItemDTO.Highlights, String> highlighter = ElasticFeaturestoreItemDTO.Highlights::setName;
setFeatureHighlights(highlightFields.get(featureNameField), hit, matcher, highlighter, result, accessCtrl);
}
use of io.hops.hopsworks.common.elastic.ElasticFeaturestoreHit in project hopsworks by logicalclocks.
the class ElasticFeaturestoreBuilder method setFeatureDescriptionHighlights.
private void setFeatureDescriptionHighlights(SearchHit hitAux, ElasticFeaturestoreDTO result, DatasetAccessController.DatasetAccessCtrl accessCtrl) throws ElasticException, GenericException {
ElasticFeaturestoreHit hit = ElasticFeaturestoreHit.instance(hitAux);
Map<String, HighlightField> highlightFields = hitAux.getHighlightFields();
String featureDescriptionField = FeaturestoreXAttrsConstants.getFeaturestoreElasticKey(FeaturestoreXAttrsConstants.FG_FEATURES, FeaturestoreXAttrsConstants.DESCRIPTION);
// <highlighted text, name, description>
Function<Triplet<String, String, String>, Boolean> matcher = (state) -> {
// check if highlighted description equals feature description
return removeHighlightTags(state.getValue0()).equals(state.getValue2());
};
BiConsumer<ElasticFeaturestoreItemDTO.Highlights, String> highlighter = ElasticFeaturestoreItemDTO.Highlights::setDescription;
setFeatureHighlights(highlightFields.get(featureDescriptionField), hit, matcher, highlighter, result, accessCtrl);
}
Aggregations