/** * Standard constructor. */ public Dates(SortedNumericDocValues in) { this(in, (key, message) -> deprecationLogger.deprecatedAndMaybeLog(key, message)); }
/** * Standard constructor. */ public Longs(SortedNumericDocValues in) { this(in, (key, message) -> deprecationLogger.deprecatedAndMaybeLog(key, message)); }
public Doubles(SortedNumericDoubleValues in) { this(in, (key, message) -> deprecationLogger.deprecatedAndMaybeLog(key, message)); }
public Strings(SortedBinaryDocValues in) { this(in, (key, message) -> deprecationLogger.deprecatedAndMaybeLog(key, message)); }
public BytesRefs(SortedBinaryDocValues in) { this(in, (key, message) -> deprecationLogger.deprecatedAndMaybeLog(key, message)); }
public Booleans(SortedNumericDocValues in) { this(in, (key, message) -> deprecationLogger.deprecatedAndMaybeLog(key, message)); }
public GeoPoints(MultiGeoPointValues in) { this(in, (key, message) -> deprecationLogger.deprecatedAndMaybeLog(key, message)); }
private static void logDeprecated(String key, String message, Object... params) { // NOTE: we don't check SpecialPermission because this will be called (indirectly) from scripts AccessController.doPrivileged((PrivilegedAction<Void>) () -> { DEPRECATION_LOGGER.deprecatedAndMaybeLog(key, message, params); return null; }); }
private static void maybeLogJodaDeprecation(String input) { if (input.contains("CC")) { deprecationLogger.deprecatedAndMaybeLog("joda-century-of-era-format", "Use of 'C' (century-of-era) is deprecated and will not be supported in the next major version of Elasticsearch."); } if (input.contains("YY")) { deprecationLogger.deprecatedAndMaybeLog("joda-year-of-era-format", "Use of 'Y' (year-of-era) will change to 'y' in the" + " next major version of Elasticsearch. Prefix your date format with '8' to use the new specifier."); } if (input.contains("xx")) { deprecationLogger.deprecatedAndMaybeLog("joda-week-based-year-format","Use of 'x' (week-based-year) will change" + " to 'Y' in the next major version of Elasticsearch. Prefix your date format with '8' to use the new specifier."); } }
/** * Sets the boost for this query. Documents matching this query will (in addition to the normal * weightings) have their score multiplied by the boost provided. */ @SuppressWarnings("unchecked") @Override public final QB boost(float boost) { if (Float.compare(boost, 0f) < 0) { deprecationLogger.deprecatedAndMaybeLog("negative boost", "setting a negative [boost] on a query " + "is deprecated and will throw an error in the next version. You can use a value between 0 and 1 to deboost."); } this.boost = boost; return (QB) this; }
@Override public TokenFilterFactory getSynonymFilter() { DEPRECATION_LOGGER.deprecatedAndMaybeLog("synonym_tokenfilters", "Token filter [" + name() + "] will not be usable to parse synonyms after v7.0"); return this; }
@Override protected void validateReferences(Version indexVersionCreated, Function<String, MappedFieldType> fieldResolver) { if (fieldName != null) { MappedFieldType mappedFieldType = fieldResolver.apply(fieldName); if (mappedFieldType == null) { DEPRECATION_LOGGER.deprecatedAndMaybeLog("geo_context_mapping", "field [{}] referenced in context [{}] is not defined in the mapping", fieldName, name); } else if (GeoPointFieldMapper.CONTENT_TYPE.equals(mappedFieldType.typeName()) == false) { DEPRECATION_LOGGER.deprecatedAndMaybeLog("geo_context_mapping", "field [{}] referenced in context [{}] must be mapped to geo_point, found [{}]", fieldName, name, mappedFieldType.typeName()); } } }
/** * Checks boost value of a nested span clause is equal to {@link AbstractQueryBuilder#DEFAULT_BOOST}, * and if not issues a deprecation warning * @param clause a span query builder */ static void checkNoBoost(SpanQueryBuilder clause) { try { if (clause.boost() != AbstractQueryBuilder.DEFAULT_BOOST) { DEPRECATION_LOGGER.deprecatedAndMaybeLog("span_inner_queries", "setting boost on inner span queries is deprecated!"); } } catch (UnsupportedOperationException ignored) { // if boost is unsupported it can't have been set } } }
private static void checkForTooManyFields(Map<String, Float> fields, QueryShardContext context) { Integer limit = SearchModule.INDICES_MAX_CLAUSE_COUNT_SETTING.get(context.getIndexSettings().getSettings()); if (fields.size() > limit) { DEPRECATION_LOGGER.deprecatedAndMaybeLog("field_expansion_limit", "Field expansion matches too many fields, got: {}. This will be limited starting with version 7.0 of Elasticsearch. " + "The limit will be detemined by the `indices.query.bool.max_clause_count` setting which is currently set to {}. " + "You should look at lowering the maximum number of fields targeted by a query or increase the above limit " + "while being aware that this can negatively affect your clusters performance.", fields.size(), limit); } } }
@Override public double score(int docId, float subQueryScore) throws IOException { leafScript.setDocument(docId); scorer.docid = docId; scorer.score = subQueryScore; double result = leafScript.execute(); if (result < 0f) { deprecationLogger.deprecatedAndMaybeLog("negative score in function score query", "Negative scores for script score function are deprecated," + " and will throw an error in the next major version. Got score: [" + result + "]" ); } return result; }
public static ZoneId dateTimeZoneToZoneId(DateTimeZone timeZone) { if (timeZone == null) { return null; } if (DateTimeZone.UTC.equals(timeZone)) { return ZoneOffset.UTC; } String deprecatedId = DEPRECATED_SHORT_TIMEZONES.get(timeZone.getID()); if (deprecatedId != null) { DEPRECATION_LOGGER.deprecatedAndMaybeLog("timezone", "Use of short timezone id " + timeZone.getID() + " is deprecated. Use " + deprecatedId + " instead"); return ZoneId.of(deprecatedId); } return ZoneId.of(timeZone.getID()); } }
/** Logs a deprecation warning if the setting is deprecated and used. */ void checkDeprecation(Settings settings) { // They're using the setting, so we need to tell them to stop if (this.isDeprecated() && this.exists(settings)) { // It would be convenient to show its replacement key, but replacement is often not so simple final String key = getKey(); Settings.DeprecationLoggerHolder.deprecationLogger.deprecatedAndMaybeLog( key, "[{}] setting was deprecated in Elasticsearch and will be removed in a future release! " + "See the breaking changes documentation for the next major version.", key); } }
@Override public double score(int docId, float subQueryScore) throws IOException { double value; if (values.advanceExact(docId)) { value = values.nextValue(); } else { if (missing != null) { value = missing; } else { throw new ElasticsearchException("Missing value for field [" + field + "]"); } } double val = value * boostFactor; double result = modifier.apply(val); if (result < 0f) { deprecationLogger.deprecatedAndMaybeLog( "negative score in function score query", "Negative scores for field value function are deprecated," + " and will throw an error in the next major version. Got: [" + result + "] for field value: [" + value + "]" ); } return result; }
static Map<String, PreConfiguredTokenFilter> setupPreConfiguredTokenFilters(List<AnalysisPlugin> plugins) { NamedRegistry<PreConfiguredTokenFilter> preConfiguredTokenFilters = new NamedRegistry<>("pre-configured token_filter"); // Add filters available in lucene-core preConfiguredTokenFilters.register("lowercase", PreConfiguredTokenFilter.singleton("lowercase", true, LowerCaseFilter::new)); preConfiguredTokenFilters.register( "standard", PreConfiguredTokenFilter.singletonWithVersion("standard", false, (reader, version) -> { DEPRECATION_LOGGER.deprecatedAndMaybeLog("standard_deprecation", "The [standard] token filter is deprecated and will be removed in a future version."); return reader; })); /* Note that "stop" is available in lucene-core but it's pre-built * version uses a set of English stop words that are in * lucene-analyzers-common so "stop" is defined in the analysis-common * module. */ for (AnalysisPlugin plugin: plugins) { for (PreConfiguredTokenFilter filter : plugin.getPreConfiguredTokenFilters()) { preConfiguredTokenFilters.register(filter.getName(), filter); } } return unmodifiableMap(preConfiguredTokenFilters.getRegistry()); }
private NamedRegistry<AnalysisProvider<TokenFilterFactory>> setupTokenFilters(List<AnalysisPlugin> plugins, HunspellService hunspellService) { NamedRegistry<AnalysisProvider<TokenFilterFactory>> tokenFilters = new NamedRegistry<>("token_filter"); tokenFilters.register("stop", StopTokenFilterFactory::new); tokenFilters.register("standard", (indexSettings, environment, name, settings) -> { DEPRECATION_LOGGER.deprecatedAndMaybeLog("standard_deprecation", "The [standard] token filter name is deprecated and will be removed in a future version."); return new AbstractTokenFilterFactory(indexSettings, name, settings) { @Override public TokenStream create(TokenStream tokenStream) { return tokenStream; } }; }); tokenFilters.register("shingle", ShingleTokenFilterFactory::new); tokenFilters.register("hunspell", requiresAnalysisSettings((indexSettings, env, name, settings) -> new HunspellTokenFilterFactory (indexSettings, name, settings, hunspellService))); tokenFilters.extractAndRegister(plugins, AnalysisPlugin::getTokenFilters); return tokenFilters; }