コード例 #1
2
  @Override
  protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params)
      throws IOException {
    builder.field("type", contentType());

    if (includeDefaults || fieldType().tree().equals(Defaults.TREE) == false) {
      builder.field(Names.TREE, fieldType().tree());
    }
    if (includeDefaults || fieldType().treeLevels() != 0) {
      builder.field(Names.TREE_LEVELS, fieldType().treeLevels());
    }
    if (includeDefaults || fieldType().precisionInMeters() != -1) {
      builder.field(
          Names.TREE_PRESISION, DistanceUnit.METERS.toString(fieldType().precisionInMeters()));
    }
    if (includeDefaults || fieldType().strategyName() != Defaults.STRATEGY) {
      builder.field(Names.STRATEGY, fieldType().strategyName());
    }
    if (includeDefaults || fieldType().distanceErrorPct() != fieldType().defaultDistanceErrorPct) {
      builder.field(Names.DISTANCE_ERROR_PCT, fieldType().distanceErrorPct());
    }
    if (includeDefaults || fieldType().orientation() != Defaults.ORIENTATION) {
      builder.field(Names.ORIENTATION, fieldType().orientation());
    }
    if (includeDefaults || fieldType().pointsOnly() != GeoShapeFieldMapper.Defaults.POINTS_ONLY) {
      builder.field(Names.STRATEGY_POINTS_ONLY, fieldType().pointsOnly());
    }
    if (includeDefaults || coerce.explicit()) {
      builder.field("coerce", coerce.value());
    }
  }
コード例 #2
0
    public void ensureValidity() {

      if (shardSize.value() == 0) {
        setShardSize(Integer.MAX_VALUE);
      }

      if (requiredSize.value() == 0) {
        setRequiredSize(Integer.MAX_VALUE);
      }
      // shard_size cannot be smaller than size as we need to at least fetch <size> entries from
      // every shards in order to return <size>
      if (shardSize.value() < requiredSize.value()) {
        setShardSize(requiredSize.value());
      }

      // shard_min_doc_count should not be larger than min_doc_count because this can cause buckets
      // to be removed that would match the min_doc_count criteria
      if (shardMinDocCount.value() > minDocCount.value()) {
        setShardMinDocCount(minDocCount.value());
      }

      if (requiredSize.value() < 0 || minDocCount.value() < 0) {
        throw new ElasticsearchException(
            "parameters [requiredSize] and [minDocCount] must be >=0 in terms aggregation.");
      }
    }
コード例 #3
0
  @Override
  protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params)
      throws IOException {
    super.doXContentBody(builder, includeDefaults, params);

    if (includeDefaults || fieldType().nullValue() != null) {
      Object nullValue = fieldType().nullValue();
      if (nullValue != null) {
        nullValue = InetAddresses.toAddrString((InetAddress) nullValue);
      }
      builder.field("null_value", nullValue);
    }

    if (includeDefaults || ignoreMalformed.explicit()) {
      builder.field("ignore_malformed", ignoreMalformed.value());
    }
    if (includeInAll != null) {
      builder.field("include_in_all", includeInAll);
    } else if (includeDefaults) {
      builder.field("include_in_all", false);
    }
  }
コード例 #4
0
  @Override
  protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
    Object addressAsObject;
    if (context.externalValueSet()) {
      addressAsObject = context.externalValue();
    } else {
      addressAsObject = context.parser().textOrNull();
    }

    if (addressAsObject == null) {
      addressAsObject = fieldType().nullValue();
    }

    if (addressAsObject == null) {
      return;
    }

    String addressAsString = addressAsObject.toString();
    InetAddress address;
    if (addressAsObject instanceof InetAddress) {
      address = (InetAddress) addressAsObject;
    } else {
      try {
        address = InetAddresses.forString(addressAsString);
      } catch (IllegalArgumentException e) {
        if (ignoreMalformed.value()) {
          return;
        } else {
          throw e;
        }
      }
    }

    if (context.includeInAll(includeInAll, this)) {
      context.allEntries().addText(fieldType().name(), addressAsString, fieldType().boost());
    }

    if (fieldType().indexOptions() != IndexOptions.NONE) {
      fields.add(new InetAddressPoint(fieldType().name(), address));
    }
    if (fieldType().hasDocValues()) {
      fields.add(
          new SortedSetDocValuesField(
              fieldType().name(), new BytesRef(InetAddressPoint.encode(address))));
    }
    if (fieldType().stored()) {
      fields.add(
          new StoredField(fieldType().name(), new BytesRef(InetAddressPoint.encode(address))));
    }
  }
コード例 #5
0
 public void toXContent(XContentBuilder builder) throws IOException {
   if (requiredSize.explicit()) {
     builder.field(
         AbstractTermsParametersParser.REQUIRED_SIZE_FIELD_NAME.getPreferredName(),
         requiredSize.value());
   }
   if (shardSize.explicit()) {
     builder.field(
         AbstractTermsParametersParser.SHARD_SIZE_FIELD_NAME.getPreferredName(),
         shardSize.value());
   }
   if (minDocCount.explicit()) {
     builder.field(
         AbstractTermsParametersParser.MIN_DOC_COUNT_FIELD_NAME.getPreferredName(),
         minDocCount.value());
   }
   if (shardMinDocCount.explicit()) {
     builder.field(
         AbstractTermsParametersParser.SHARD_MIN_DOC_COUNT_FIELD_NAME.getPreferredName(),
         shardMinDocCount.value());
   }
 }
コード例 #6
0
 public long getShardMinDocCount() {
   return shardMinDocCount.value();
 }
コード例 #7
0
 public int getShardSize() {
   return shardSize.value();
 }
コード例 #8
0
 public int getRequiredSize() {
   return requiredSize.value();
 }
コード例 #9
0
 public long getMinDocCount() {
   return minDocCount.value();
 }