@Override
 public TokenStream tokenStream(Analyzer analyzer) {
   if (fieldType().indexed()) {
     return mapper.popCachedStream().setIntValue(number);
   }
   return null;
 }
 @Override
 public TokenStream tokenStream(Analyzer analyzer, TokenStream previous) throws IOException {
   if (fieldType().indexed()) {
     return mapper.popCachedStream().setIntValue(number);
   }
   return null;
 }
 @Override
 public TokenStream tokenStream(Analyzer analyzer, TokenStream previous) throws IOException {
   if (fieldType().indexOptions() != IndexOptions.NONE) {
     return mapper.popCachedStream().setDoubleValue(number);
   }
   return null;
 }
 @Override
 public TokenStream tokenStreamValue() {
   if (isIndexed) {
     return mapper.popCachedStream().setIntValue(number);
   }
   return null;
 }
 @Override
 protected void doXContentBody(XContentBuilder builder) throws IOException {
   super.doXContentBody(builder);
   if (index != Defaults.INDEX) {
     builder.field("index", index.name().toLowerCase());
   }
   if (store != Defaults.STORE) {
     builder.field("store", store.name().toLowerCase());
   }
   if (termVector != Defaults.TERM_VECTOR) {
     builder.field("term_vector", termVector.name().toLowerCase());
   }
   if (omitNorms != Defaults.OMIT_NORMS) {
     builder.field("omit_norms", omitNorms);
   }
   if (indexOptions != Defaults.INDEX_OPTIONS) {
     builder.field("index_options", indexOptionToString(indexOptions));
   }
   if (precisionStep != Defaults.PRECISION_STEP) {
     builder.field("precision_step", precisionStep);
   }
   if (fuzzyFactor != Defaults.FUZZY_FACTOR) {
     builder.field("fuzzy_factor", fuzzyFactor);
   }
   if (nullValue != null) {
     builder.field("null_value", nullValue);
   }
   if (includeInAll != null) {
     builder.field("include_in_all", includeInAll);
   }
 }
示例#6
0
  @Override
  protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params)
      throws IOException {
    super.doXContentBody(builder, includeDefaults, params);

    if (includeDefaults || precisionStep != Defaults.PRECISION_STEP_64_BIT) {
      builder.field("precision_step", precisionStep);
    }
    builder.field("format", dateTimeFormatter.format());
    if (includeDefaults || nullValue != null) {
      builder.field("null_value", nullValue);
    }
    if (includeInAll != null) {
      builder.field("include_in_all", includeInAll);
    } else if (includeDefaults) {
      builder.field("include_in_all", false);
    }

    if (includeDefaults || timeUnit != Defaults.TIME_UNIT) {
      builder.field("numeric_resolution", timeUnit.name().toLowerCase(Locale.ROOT));
    }
    // only serialize locale if needed, ROOT is the default, so no need to serialize that case as
    // well...
    if (dateTimeFormatter.locale() != null && dateTimeFormatter.locale() != Locale.ROOT) {
      builder.field("locale", dateTimeFormatter.locale());
    } else if (includeDefaults) {
      if (dateTimeFormatter.locale() == null) {
        builder.field("locale", Locale.ROOT);
      } else {
        builder.field("locale", dateTimeFormatter.locale());
      }
    }
  }
 @Override
 public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException {
   super.merge(mergeWith, mergeContext);
   if (!this.getClass().equals(mergeWith.getClass())) {
     return;
   }
   if (!mergeContext.mergeFlags().simulate()) {
     this.nullValue = ((IntegerFieldMapper) mergeWith).nullValue;
     this.nullValueAsString = ((IntegerFieldMapper) mergeWith).nullValueAsString;
   }
 }
示例#8
0
 @Override
 public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException {
   super.merge(mergeWith, mergeContext);
   if (!this.getClass().equals(mergeWith.getClass())) {
     return;
   }
   if (!mergeContext.mergeFlags().simulate()) {
     this.nullValue = ((DateFieldMapper) mergeWith).nullValue;
     this.dateTimeFormatter = ((DateFieldMapper) mergeWith).dateTimeFormatter;
   }
 }
 @Override
 protected void doXContentBody(XContentBuilder builder) throws IOException {
   super.doXContentBody(builder);
   if (precisionStep != Defaults.PRECISION_STEP) {
     builder.field("precision_step", precisionStep);
   }
   if (fuzzyFactor != Defaults.FUZZY_FACTOR) {
     builder.field("fuzzy_factor", fuzzyFactor);
   }
   if (nullValue != null) {
     builder.field("null_value", nullValue);
   }
   if (includeInAll != null) {
     builder.field("include_in_all", includeInAll);
   }
 }
  @Override
  protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params)
      throws IOException {
    super.doXContentBody(builder, includeDefaults, params);

    if (includeDefaults || precisionStep != Defaults.PRECISION_STEP_32_BIT) {
      builder.field("precision_step", precisionStep);
    }
    if (includeDefaults || nullValue != null) {
      builder.field("null_value", nullValue);
    }
    if (includeInAll != null) {
      builder.field("include_in_all", includeInAll);
    } else if (includeDefaults) {
      builder.field("include_in_all", false);
    }
  }
 public CustomShortNumericField(NumberFieldMapper mapper, short number) {
   super(mapper, mapper.stored() ? Numbers.shortToBytes(number) : null);
   this.mapper = mapper;
   this.number = number;
 }