Пример #1
0
    @Override
    public GeoShapeFieldMapper build(BuilderContext context) {
      GeoShapeFieldType geoShapeFieldType = (GeoShapeFieldType) fieldType;

      if (geoShapeFieldType.tree.equals(Names.TREE_QUADTREE)
          && context.indexCreatedVersion().before(Version.V_2_0_0_beta1)) {
        geoShapeFieldType.setTree("legacyquadtree");
      }

      if (context.indexCreatedVersion().before(Version.V_2_0_0_beta1)
          || (geoShapeFieldType.treeLevels() == 0 && geoShapeFieldType.precisionInMeters() < 0)) {
        geoShapeFieldType.setDefaultDistanceErrorPct(Defaults.LEGACY_DISTANCE_ERROR_PCT);
      }
      setupFieldType(context);

      return new GeoShapeFieldMapper(
          name,
          fieldType,
          coerce(context),
          context.indexSettings(),
          multiFieldsBuilder.build(this, context),
          copyTo);
    }
Пример #2
0
    @Override
    public void checkCompatibility(
        MappedFieldType fieldType, List<String> conflicts, boolean strict) {
      super.checkCompatibility(fieldType, conflicts, strict);
      GeoShapeFieldType other = (GeoShapeFieldType) fieldType;
      // prevent user from changing strategies
      if (strategyName().equals(other.strategyName()) == false) {
        conflicts.add("mapper [" + names().fullName() + "] has different [strategy]");
      }

      // prevent user from changing trees (changes encoding)
      if (tree().equals(other.tree()) == false) {
        conflicts.add("mapper [" + names().fullName() + "] has different [tree]");
      }

      if ((pointsOnly() != other.pointsOnly())) {
        conflicts.add("mapper [" + names().fullName() + "] has different points_only");
      }

      // TODO we should allow this, but at the moment levels is used to build bookkeeping variables
      // in lucene's SpatialPrefixTree implementations, need a patch to correct that first
      if (treeLevels() != other.treeLevels()) {
        conflicts.add("mapper [" + names().fullName() + "] has different [tree_levels]");
      }
      if (precisionInMeters() != other.precisionInMeters()) {
        conflicts.add("mapper [" + names().fullName() + "] has different [precision]");
      }

      if (strict) {
        if (orientation() != other.orientation()) {
          conflicts.add(
              "mapper ["
                  + names().fullName()
                  + "] is used by multiple types. Set update_all_types to true to update [orientation] across all types.");
        }
        if (distanceErrorPct() != other.distanceErrorPct()) {
          conflicts.add(
              "mapper ["
                  + names().fullName()
                  + "] is used by multiple types. Set update_all_types to true to update [distance_error_pct] across all types.");
        }
      }
    }