use of io.vertigo.core.locale.MessageText in project vertigo by KleeGroup.
the class ESFacetedQueryResultBuilder method createTermFacet.
private static Facet createTermFacet(final FacetDefinition facetDefinition, final MultiBucketsAggregation multiBuckets) {
final Map<FacetValue, Long> facetValues = new LinkedHashMap<>();
FacetValue facetValue;
for (final Bucket value : multiBuckets.getBuckets()) {
final String term = value.getKeyAsString();
final MessageText label = MessageText.of(term);
final String query = facetDefinition.getDtField().getName() + ":\"" + term + "\"";
facetValue = new FacetValue(term, ListFilter.of(query), label);
facetValues.put(facetValue, value.getDocCount());
}
return new Facet(facetDefinition, facetValues);
}
use of io.vertigo.core.locale.MessageText in project vertigo by KleeGroup.
the class ESFacetedQueryResultBuilder method createCluster.
private Map<FacetValue, DtList<I>> createCluster(final Map<String, I> dtcIndex, final Map<I, Map<DtField, String>> resultHighlights) {
final Map<FacetValue, DtList<I>> resultCluster = new LinkedHashMap<>();
final FacetDefinition facetDefinition = searchQuery.getClusteringFacetDefinition();
final Aggregation facetAggregation = queryResponse.getAggregations().get(facetDefinition.getName());
if (facetDefinition.isRangeFacet()) {
// Cas des facettes par 'range'
final MultiBucketsAggregation multiBuckets = (MultiBucketsAggregation) facetAggregation;
for (final FacetValue facetRange : facetDefinition.getFacetRanges()) {
final Bucket value = getBucketByKey(multiBuckets, facetRange.getListFilter().getFilterValue());
populateCluster(value, facetRange, resultCluster, dtcIndex, resultHighlights);
}
} else {
// Cas des facettes par 'term'
final MultiBucketsAggregation multiBuckets = (MultiBucketsAggregation) facetAggregation;
FacetValue facetValue;
for (final Bucket bucket : multiBuckets.getBuckets()) {
final String term = bucket.getKeyAsString();
final String query = facetDefinition.getDtField().getName() + ":\"" + term + "\"";
final MessageText label = MessageText.of(term);
facetValue = new FacetValue(term, ListFilter.of(query), label);
populateCluster(bucket, facetValue, resultCluster, dtcIndex, resultHighlights);
}
}
return resultCluster;
}
use of io.vertigo.core.locale.MessageText in project vertigo by KleeGroup.
the class ESFacetedQueryResultBuilder method createTermFacet.
private static Facet createTermFacet(final FacetDefinition facetDefinition, final MultiBucketsAggregation multiBuckets) {
final Map<FacetValue, Long> facetValues = new LinkedHashMap<>();
FacetValue facetValue;
for (final Bucket value : multiBuckets.getBuckets()) {
final String term = value.getKeyAsString();
final MessageText label = MessageText.of(term);
final String query = facetDefinition.getDtField().getName() + ":\"" + term + "\"";
facetValue = new FacetValue(term, ListFilter.of(query), label);
facetValues.put(facetValue, value.getDocCount());
}
return new Facet(facetDefinition, facetValues);
}
use of io.vertigo.core.locale.MessageText in project vertigo by KleeGroup.
the class FacetFactory method createTermCluster.
private static <D extends DtObject> Map<FacetValue, DtList<D>> createTermCluster(final FacetDefinition facetDefinition, final DtList<D> dtList) {
// map résultat avec les docs par FacetFilter
final Map<FacetValue, DtList<D>> clusterValues = new LinkedHashMap<>();
// Cas des facettes par Term
final DtField dtField = facetDefinition.getDtField();
// on garde un index pour incrémenter le facetFilter pour chaque Term
final Map<Object, FacetValue> facetFilterIndex = new HashMap<>();
FacetValue facetValue;
for (final D dto : dtList) {
final Object value = dtField.getDataAccessor().getValue(dto);
facetValue = facetFilterIndex.get(value);
if (facetValue == null) {
final String valueAsString = dtField.getDomain().valueToString(value);
final String label;
if (StringUtil.isEmpty(valueAsString)) {
label = "<==no label==>";
} else {
label = valueAsString;
}
final MessageText labelMsg = MessageText.of(label);
// on garde la syntaxe Solr pour l'instant
final ListFilter listFilter = ListFilter.of(dtField.getName() + ":\"" + valueAsString + "\"");
facetValue = new FacetValue(label, listFilter, labelMsg);
facetFilterIndex.put(value, facetValue);
clusterValues.put(facetValue, new DtList<D>(dtList.getDefinition()));
}
clusterValues.get(facetValue).add(dto);
}
// tri des facettes
final Comparator<FacetValue> facetComparator = new FacetComparator<>(clusterValues);
final Map<FacetValue, DtList<D>> sortedFacetValues = new TreeMap<>(facetComparator);
sortedFacetValues.putAll(clusterValues);
return sortedFacetValues;
}
use of io.vertigo.core.locale.MessageText in project vertigo by KleeGroup.
the class SelectedFacetValuesDeserializer method appendTermFacetValue.
private static void appendTermFacetValue(final JsonElement value, final FacetDefinition facetDefinition, final SelectedFacetValuesBuilder selectedFacetValuesBuilder) {
final String term = value.getAsString();
final MessageText label = MessageText.of(term);
final String query = facetDefinition.getDtField().getName() + ":\"" + term + "\"";
final FacetValue facetValue = new FacetValue(term, ListFilter.of(query), label);
selectedFacetValuesBuilder.add(facetDefinition, facetValue);
}
Aggregations