use of com.enonic.xp.query.highlight.HighlightQueryProperty in project xp by enonic.
the class QueryHighlightParams method getHighlightQuery.
HighlightQuery getHighlightQuery(final Map<String, Object> highlightMap) {
if (highlightMap == null) {
return HighlightQuery.empty();
}
final HighlightQuerySettings settings = fillQuerySettings(HighlightQuerySettings.create(), highlightMap).build();
final HighlightQuery.Builder highlightQuery = HighlightQuery.create().settings(settings);
final Map<String, Object> propertiesMap = (Map<String, Object>) highlightMap.get("properties");
if (propertiesMap == null) {
return HighlightQuery.empty();
}
propertiesMap.forEach((name, propertyMap) -> {
final HighlightQueryProperty highlightQueryProperty = highlightPropertyFromParams(name, (Map<String, Object>) propertyMap);
highlightQuery.property(highlightQueryProperty);
});
return highlightQuery.build();
}
use of com.enonic.xp.query.highlight.HighlightQueryProperty in project xp by enonic.
the class QueryHighlightParams method getHighlightQuery.
HighlightQuery getHighlightQuery(final Map<String, Object> highlightMap) {
if (highlightMap == null) {
return HighlightQuery.empty();
}
final HighlightQuerySettings settings = fillQuerySettings(HighlightQuerySettings.create(), highlightMap).build();
final HighlightQuery.Builder highlightQuery = HighlightQuery.create().settings(settings);
final Map<String, Object> propertiesMap = (Map<String, Object>) highlightMap.get("properties");
if (propertiesMap == null) {
return HighlightQuery.empty();
}
propertiesMap.forEach((name, propertyMap) -> {
final HighlightQueryProperty highlightQueryProperty = highlightPropertyFromParams(name, (Map<String, Object>) propertyMap);
highlightQuery.property(highlightQueryProperty);
});
return highlightQuery.build();
}
use of com.enonic.xp.query.highlight.HighlightQueryProperty in project xp by enonic.
the class ElasticHighlightQueryBuilderFactory method create.
public ElasticHighlightQuery create(final HighlightQuery highlightQuery) {
if (highlightQuery == null) {
return ElasticHighlightQuery.empty();
}
ElasticHighlightQuery.Builder result = ElasticHighlightQuery.create().settings(highlightQuery.getSettings());
for (HighlightQueryProperty highlightQueryProperty : highlightQuery.getProperties()) {
final String normalizedFieldName = IndexFieldNameNormalizer.normalize(highlightQueryProperty.getName());
final String normalizedFieldNameWithPostFix = normalizedFieldName + IndexValueType.INDEX_VALUE_TYPE_SEPARATOR + "_*";
final HighlightBuilder.Field rawHighlightField = createField(normalizedFieldName, highlightQueryProperty);
final HighlightBuilder.Field analyzedHighlightField = createField(normalizedFieldNameWithPostFix, highlightQueryProperty);
result.addField(rawHighlightField);
result.addField(analyzedHighlightField);
}
return result.build();
}
Aggregations