org.elasticsearch.search.DocValueFormat Java Examples

The following examples show how to use org.elasticsearch.search.DocValueFormat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DateHierarchyAggregationBuilder.java    From elasticsearch-aggregation-pathhierarchy with MIT License 6 votes vote down vote up
public List<RoundingInfo> buildRoundings() {
    List<RoundingInfo> roundings = new ArrayList<>();

    ZoneId timeZone = timeZone() == null ? ZoneOffset.UTC: timeZone();

    for (String interval: INTERVAL_CONFIG.keySet()) {
        roundings.add(new RoundingInfo(interval, createRounding(INTERVAL_CONFIG.get(interval).dateTimeUnit),
                new DocValueFormat.DateTime(DateFormatter.forPattern(INTERVAL_CONFIG.get(interval).format), timeZone,
                        DateFieldMapper.Resolution.MILLISECONDS)));
        if (interval.equals(interval())) {
            break;
        }
    }

    return roundings;
}
 
Example #2
Source File: IpColumnReference.java    From crate with Apache License 2.0 6 votes vote down vote up
@Override
public String value() {
    try {
        if (values.advanceExact(docId)) {
            long ord = values.nextOrd();
            if (values.nextOrd() != SortedSetDocValues.NO_MORE_ORDS) {
                throw new GroupByOnArrayUnsupportedException(columnName);
            }
            BytesRef encoded = values.lookupOrd(ord);
            return (String) DocValueFormat.IP.format(encoded);
        } else {
            return null;
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example #3
Source File: MultiValuesSourceAggregationBuilder.java    From elasticsearch-linear-regression with Apache License 2.0 5 votes vote down vote up
private static DocValueFormat resolveFormat(@Nullable String format,
    @Nullable ValueType valueType) {
  if (valueType == null) {
    return DocValueFormat.RAW; // we can't figure it out
  }
  DocValueFormat valueFormat = valueType.defaultFormat();
  if (valueFormat instanceof DocValueFormat.Decimal && format != null) {
    valueFormat = new DocValueFormat.Decimal(format);
  }
  return valueFormat;
}
 
Example #4
Source File: BundlePlugin.java    From elasticsearch-plugin-bundle with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public List<NamedWriteableRegistry.Entry> getNamedWriteables() {
    List<NamedWriteableRegistry.Entry> extra = new ArrayList<>();
    if (settings.getAsBoolean("plugins.xbib.icu.enabled", true)) {
        extra.add(new NamedWriteableRegistry.Entry(
                        DocValueFormat.class,
                        IcuCollationKeyFieldMapper.CollationFieldType.COLLATE_FORMAT.getWriteableName(),
                        in -> IcuCollationKeyFieldMapper.CollationFieldType.COLLATE_FORMAT
                )
        );
    }
    return extra;
}
 
Example #5
Source File: IpFieldMapper.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public Object valueForDisplay(Object value) {
    if (value == null) {
        return null;
    }
    return DocValueFormat.IP.format((BytesRef) value);
}
 
Example #6
Source File: DateHierarchyAggregationBuilder.java    From elasticsearch-aggregation-pathhierarchy with MIT License 4 votes vote down vote up
public RoundingInfo(String interval, Rounding rounding, DocValueFormat docValueFormat) {
    this.interval = interval;
    this.rounding =  rounding;
    this.format = docValueFormat;
}
 
Example #7
Source File: DateHierarchyAggregationBuilder.java    From elasticsearch-aggregation-pathhierarchy with MIT License 4 votes vote down vote up
public RoundingInfo(StreamInput in) throws IOException {
    rounding = Rounding.read(in);
    interval = in.readString();
    format = in.readNamedWriteable(DocValueFormat.class);
}
 
Example #8
Source File: IcuCollationKeyFieldMapper.java    From elasticsearch-plugin-bundle with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public DocValueFormat docValueFormat(final String format, final DateTimeZone timeZone) {
    return COLLATE_FORMAT;
}