public void addUnboundedFrom(Object from) { addRange(null, from, null); }
protected List<AggregationBuilder> getElasticsearchRangeAggregations(RangeAggregation agg) { List<AggregationBuilder> aggs = new ArrayList<>(); PropertyDefinition propertyDefinition = getPropertyDefinition(agg.getFieldName()); if (propertyDefinition == null) { throw new VertexiumException("Could not find mapping for property: " + agg.getFieldName()); for (String propertyName : getPropertyNames(agg.getFieldName())) { String visibilityHash = getSearchIndex().getPropertyVisibilityHashFromPropertyName(propertyName); String aggName = createAggregationName(agg.getAggregationName(), visibilityHash); if (propertyDataType == Date.class) { DateRangeAggregationBuilder dateRangeBuilder = AggregationBuilders.dateRange(aggName); dateRangeBuilder.field(propertyName); if (!Strings.isNullOrEmpty(agg.getFormat())) { dateRangeBuilder.format(agg.getFormat()); for (RangeAggregation.Range range : agg.getRanges()) { applyRange(dateRangeBuilder, range); for (AggregationBuilder subAgg : getElasticsearchAggregations(agg.getNestedAggregations())) { dateRangeBuilder.subAggregation(subAgg); if (!Strings.isNullOrEmpty(agg.getFormat())) { throw new VertexiumException("Invalid use of format for property: " + agg.getFieldName() + ". Format is only valid for date properties"); for (RangeAggregation.Range range : agg.getRanges()) { Object from = range.getFrom(); Object to = range.getTo(); if ((from != null && !(from instanceof Number)) || (to != null && !(to instanceof Number))) {
private RangeResult queryGraphQueryWithRangeAggregation( String propertyName, String format, String keyOne, Object boundaryOne, String keyTwo, Object boundaryTwo, String keyThree, Authorizations authorizations ) { Query q = graph.query(authorizations).limit(0); RangeAggregation agg = new RangeAggregation("range-count", propertyName, format); if (!q.isAggregationSupported(agg)) { LOGGER.warn("%s unsupported", RangeAggregation.class.getName()); return null; } agg.addUnboundedTo(keyOne, boundaryOne); agg.addRange(keyTwo, boundaryOne, boundaryTwo); agg.addUnboundedFrom(keyThree, boundaryTwo); q.addAggregation(agg); return q.vertices().getAggregationResult("range-count", RangeResult.class); }
RangeAggregation rangeAggregation = new RangeAggregation("range-count", agePropertyName); TermsAggregation termsAggregation = new TermsAggregation("name-count", "name"); rangeAggregation.addNestedAggregation(termsAggregation); rangeAggregation.addUnboundedTo("lower", 23); rangeAggregation.addUnboundedFrom("upper", 23); q.addAggregation(rangeAggregation);
protected List<AggregationBuilder> getElasticsearchRangeAggregations(RangeAggregation agg) { List<AggregationBuilder> aggs = new ArrayList<>(); PropertyDefinition propertyDefinition = getPropertyDefinition(agg.getFieldName()); if (propertyDefinition == null) { throw new VertexiumException("Could not find mapping for property: " + agg.getFieldName()); for (String propertyName : getPropertyNames(agg.getFieldName())) { String visibilityHash = getSearchIndex().getPropertyVisibilityHashFromPropertyName(propertyName); String aggName = createAggregationName(agg.getAggregationName(), visibilityHash); if (propertyDataType == Date.class) { DateRangeAggregationBuilder dateRangeBuilder = AggregationBuilders.dateRange(aggName); dateRangeBuilder.field(propertyName); if (!Strings.isNullOrEmpty(agg.getFormat())) { dateRangeBuilder.format(agg.getFormat()); for (RangeAggregation.Range range : agg.getRanges()) { applyRange(dateRangeBuilder, range); for (AggregationBuilder subAgg : getElasticsearchAggregations(agg.getNestedAggregations())) { dateRangeBuilder.subAggregation(subAgg); if (!Strings.isNullOrEmpty(agg.getFormat())) { throw new VertexiumException("Invalid use of format for property: " + agg.getFieldName() + ". Format is only valid for date properties"); for (RangeAggregation.Range range : agg.getRanges()) { Object from = range.getFrom(); Object to = range.getTo(); if ((from != null && !(from instanceof Number)) || (to != null && !(to instanceof Number))) {
private RangeResult queryGraphQueryWithRangeAggregation( String propertyName, String format, String keyOne, Object boundaryOne, String keyTwo, Object boundaryTwo, String keyThree, Authorizations authorizations ) { Query q = graph.query(authorizations).limit(0); RangeAggregation agg = new RangeAggregation("range-count", propertyName, format); if (!q.isAggregationSupported(agg)) { LOGGER.warn("%s unsupported", RangeAggregation.class.getName()); return null; } agg.addUnboundedTo(keyOne, boundaryOne); agg.addRange(keyTwo, boundaryOne, boundaryTwo); agg.addUnboundedFrom(keyThree, boundaryTwo); q.addAggregation(agg); return q.vertices().getAggregationResult("range-count", RangeResult.class); }
RangeAggregation rangeAggregation = new RangeAggregation("range-count", agePropertyName); TermsAggregation termsAggregation = new TermsAggregation("name-count", "name"); rangeAggregation.addNestedAggregation(termsAggregation); rangeAggregation.addUnboundedTo("lower", 23); rangeAggregation.addUnboundedFrom("upper", 23); q.addAggregation(rangeAggregation);
protected List<AggregationBuilder> getElasticsearchRangeAggregations(RangeAggregation agg) { List<AggregationBuilder> aggs = new ArrayList<>(); PropertyDefinition propertyDefinition = getPropertyDefinition(agg.getFieldName()); if (propertyDefinition == null) { throw new VertexiumException("Could not find mapping for property: " + agg.getFieldName()); for (String propertyName : getPropertyNames(agg.getFieldName())) { String visibilityHash = getSearchIndex().getPropertyVisibilityHashFromDeflatedPropertyName(propertyName); String aggName = createAggregationName(agg.getAggregationName(), visibilityHash); if (propertyDataType == Date.class) { DateRangeBuilder dateRangeBuilder = AggregationBuilders.dateRange(aggName); dateRangeBuilder.field(propertyName); if (!Strings.isNullOrEmpty(agg.getFormat())) { dateRangeBuilder.format(agg.getFormat()); for (RangeAggregation.Range range : agg.getRanges()) { dateRangeBuilder.addRange(range.getKey(), range.getFrom(), range.getTo()); for (AbstractAggregationBuilder subAgg : getElasticsearchAggregations(agg.getNestedAggregations())) { dateRangeBuilder.subAggregation(subAgg); if (!Strings.isNullOrEmpty(agg.getFormat())) { throw new VertexiumException("Invalid use of format for property: " + agg.getFieldName() + ". Format is only valid for date properties"); for (RangeAggregation.Range range : agg.getRanges()) { Object from = range.getFrom(); Object to = range.getTo(); if ((from != null && !(from instanceof Number)) || (to != null && !(to instanceof Number))) {
public void addUnboundedFrom(String key, Object from) { addRange(key, from, null); }
protected List<AggregationBuilder> getElasticsearchRangeAggregations(RangeAggregation agg) { List<AggregationBuilder> aggs = new ArrayList<>(); PropertyDefinition propertyDefinition = getPropertyDefinition(agg.getFieldName()); if (propertyDefinition == null) { throw new VertexiumException("Could not find mapping for property: " + agg.getFieldName()); for (String propertyName : getPropertyNames(agg.getFieldName())) { String visibilityHash = getSearchIndex().getPropertyVisibilityHashFromDeflatedPropertyName(propertyName); String aggName = createAggregationName(agg.getAggregationName(), visibilityHash); if (propertyDataType == Date.class) { DateRangeBuilder dateRangeBuilder = AggregationBuilders.dateRange(aggName); dateRangeBuilder.field(propertyName); if (!Strings.isNullOrEmpty(agg.getFormat())) { dateRangeBuilder.format(agg.getFormat()); for (RangeAggregation.Range range : agg.getRanges()) { dateRangeBuilder.addRange(range.getKey(), range.getFrom(), range.getTo()); for (AbstractAggregationBuilder subAgg : getElasticsearchAggregations(agg.getNestedAggregations())) { dateRangeBuilder.subAggregation(subAgg); if (!Strings.isNullOrEmpty(agg.getFormat())) { throw new VertexiumException("Invalid use of format for property: " + agg.getFieldName() + ". Format is only valid for date properties"); for (RangeAggregation.Range range : agg.getRanges()) { Object from = range.getFrom(); Object to = range.getTo(); if ((from != null && !(from instanceof Number)) || (to != null && !(to instanceof Number))) {
public void addUnboundedTo(Object to) { addRange(null, null, to); }
public void addUnboundedFrom(String key, Object from) { addRange(key, from, null); }
public void addRange(Object from, Object to) { addRange(null, from, to); }
public void addUnboundedTo(Object to) { addRange(null, null, to); }
public void addUnboundedTo(String key, Object to) { addRange(key, null, to); }
public void addUnboundedFrom(Object from) { addRange(null, from, null); }
public void addRange(Object from, Object to) { addRange(null, from, to); }
public void addUnboundedTo(String key, Object to) { addRange(key, null, to); }