public PrefixTreeStrategy resolvePrefixTreeStrategy(String strategyName) { if (SpatialStrategy.RECURSIVE.getStrategyName().equals(strategyName)) { return recursiveStrategy; } if (SpatialStrategy.TERM.getStrategyName().equals(strategyName)) { return termStrategy; } throw new IllegalArgumentException("Unknown prefix tree strategy [" + strategyName + "]"); } }
public static boolean parse(String name, String fieldName, Object fieldNode, DeprecatedParameters deprecatedParameters) { if (Names.STRATEGY.match(fieldName, LoggingDeprecationHandler.INSTANCE)) { checkPrefixTreeSupport(fieldName); deprecatedParameters.setSpatialStrategy(SpatialStrategy.fromString(fieldNode.toString())); } else if (Names.TREE.match(fieldName, LoggingDeprecationHandler.INSTANCE)) { checkPrefixTreeSupport(fieldName); deprecatedParameters.setTree(fieldNode.toString()); } else if (Names.TREE_LEVELS.match(fieldName, LoggingDeprecationHandler.INSTANCE)) { checkPrefixTreeSupport(fieldName); deprecatedParameters.setTreeLevels(Integer.parseInt(fieldNode.toString())); } else if (Names.PRECISION.match(fieldName, LoggingDeprecationHandler.INSTANCE)) { checkPrefixTreeSupport(fieldName); deprecatedParameters.setPrecision(fieldNode.toString()); } else if (Names.DISTANCE_ERROR_PCT.match(fieldName, LoggingDeprecationHandler.INSTANCE)) { checkPrefixTreeSupport(fieldName); deprecatedParameters.setDistanceErrorPct(Double.parseDouble(fieldNode.toString())); } else if (Names.POINTS_ONLY.match(fieldName, LoggingDeprecationHandler.INSTANCE)) { checkPrefixTreeSupport(fieldName); deprecatedParameters.setPointsOnly( XContentMapValues.nodeBooleanValue(fieldNode, name + "." + DeprecatedParameters.Names.POINTS_ONLY)); } else { return false; } return true; }
public static SpatialStrategy fromString(String strategyName) { for (SpatialStrategy strategy : values()) { if (strategy.strategyName.equals(strategyName)) { return strategy; } } return null; } }
/** * Sets the relation of query shape and indexed shape. * * @param relation relation of the shapes * @return this */ public GeoShapeQueryBuilder relation(ShapeRelation relation) { if (relation == null) { throw new IllegalArgumentException("No Shape Relation defined"); } if (SpatialStrategy.TERM.equals(strategy) && relation != ShapeRelation.INTERSECTS) { throw new IllegalArgumentException("current strategy [" + strategy.getStrategyName() + "] only supports relation [" + ShapeRelation.INTERSECTS.getRelationName() + "] found relation [" + relation.getRelationName() + "]"); } this.relation = relation; return this; }
public void setStrategy(SpatialStrategy strategy) { checkIfFrozen(); this.strategy = strategy; if (this.strategy.equals(SpatialStrategy.TERM)) { this.pointsOnly = true; } }
public PrefixTreeStrategy resolvePrefixTreeStrategy(SpatialStrategy strategy) { return resolvePrefixTreeStrategy(strategy.getStrategyName()); }
} else if (STRATEGY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { String strategyName = parser.text(); strategy = SpatialStrategy.fromString(strategyName); if (strategy == null) { throw new ParsingException(parser.getTokenLocation(), "Unknown strategy [" + strategyName + " ]");
public static SpatialStrategy fromString(String strategyName) { for (SpatialStrategy strategy : values()) { if (strategy.strategyName.equals(strategyName)) { return strategy; } } return null; } }
/** * Defines which spatial strategy will be used for building the geo shape * Query. When not set, the strategy that will be used will be the one that * is associated with the geo shape field in the mappings. * * @param strategy * The spatial strategy to use for building the geo shape Query * @return this */ public GeoShapeQueryBuilder strategy(SpatialStrategy strategy) { if (strategy != null && strategy == SpatialStrategy.TERM && relation != ShapeRelation.INTERSECTS) { throw new IllegalArgumentException("strategy [" + strategy.getStrategyName() + "] only supports relation [" + ShapeRelation.INTERSECTS.getRelationName() + "] found relation [" + relation.getRelationName() + "]"); } this.strategy = strategy; return this; }
} else if (STRATEGY_FIELD.match(currentFieldName)) { String strategyName = parser.text(); strategy = SpatialStrategy.fromString(strategyName); if (strategy == null) { throw new ParsingException(parser.getTokenLocation(), "Unknown strategy [" + strategyName + " ]");
public static SpatialStrategy fromString(String strategyName) { for (SpatialStrategy strategy : values()) { if (strategy.strategyName.equals(strategyName)) { return strategy; } } return null; } }
builder.field(STRATEGY_FIELD.getPreferredName(), strategy.getStrategyName());
} else if (STRATEGY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { String strategyName = parser.text(); strategy = SpatialStrategy.fromString(strategyName); if (strategy == null) { throw new ParsingException(parser.getTokenLocation(), "Unknown strategy [" + strategyName + " ]");
public static SpatialStrategy fromString(String strategyName) { for (SpatialStrategy strategy : values()) { if (strategy.strategyName.equals(strategyName)) { return strategy; } } return null; } }
public PrefixTreeStrategy resolveStrategy(String strategyName) { if (SpatialStrategy.RECURSIVE.getStrategyName().equals(strategyName)) { return recursiveStrategy; } if (SpatialStrategy.TERM.getStrategyName().equals(strategyName)) { return termStrategy; } throw new IllegalArgumentException("Unknown prefix tree strategy [" + strategyName + "]"); }
} else if (STRATEGY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { String strategyName = parser.text(); strategy = SpatialStrategy.fromString(strategyName); if (strategy == null) { throw new ParsingException(parser.getTokenLocation(), "Unknown strategy [" + strategyName + " ]");
public PrefixTreeStrategy resolveStrategy(String strategyName) { if (SpatialStrategy.RECURSIVE.getStrategyName().equals(strategyName)) { return recursiveStrategy; } if (SpatialStrategy.TERM.getStrategyName().equals(strategyName)) { return termStrategy; } throw new IllegalArgumentException("Unknown prefix tree strategy [" + strategyName + "]"); }
public PrefixTreeStrategy resolveStrategy(String strategyName) { if (SpatialStrategy.RECURSIVE.getStrategyName().equals(strategyName)) { return recursiveStrategy; } if (SpatialStrategy.TERM.getStrategyName().equals(strategyName)) { return termStrategy; } throw new IllegalArgumentException("Unknown prefix tree strategy [" + strategyName + "]"); }
public PrefixTreeStrategy resolveStrategy(String strategyName) { if (SpatialStrategy.RECURSIVE.getStrategyName().equals(strategyName)) { return recursiveStrategy; } if (SpatialStrategy.TERM.getStrategyName().equals(strategyName)) { return termStrategy; } throw new IllegalArgumentException("Unknown prefix tree strategy [" + strategyName + "]"); }
public void setStrategyName(String strategyName) { checkIfFrozen(); this.strategyName = strategyName; if (this.strategyName.equals(SpatialStrategy.TERM.getStrategyName())) { this.pointsOnly = true; } }