From 27f43e2e3932fea1832f4bb3723153dad5a111b3 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Fri, 9 Oct 2015 12:08:22 -0400 Subject: [PATCH] Remove files accidentally re-added during merge --- .../index/similarity/Similarities.java | 58 ------------- .../similarity/SimilarityLookupService.java | 87 ------------------- 2 files changed, 145 deletions(-) delete mode 100644 core/src/main/java/org/elasticsearch/index/similarity/Similarities.java delete mode 100644 core/src/main/java/org/elasticsearch/index/similarity/SimilarityLookupService.java diff --git a/core/src/main/java/org/elasticsearch/index/similarity/Similarities.java b/core/src/main/java/org/elasticsearch/index/similarity/Similarities.java deleted file mode 100644 index 3bbbc857dfc..00000000000 --- a/core/src/main/java/org/elasticsearch/index/similarity/Similarities.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.index.similarity; - -import org.apache.lucene.search.similarities.BM25Similarity; -import org.apache.lucene.search.similarities.DefaultSimilarity; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import static java.util.Collections.unmodifiableMap; - -/** - * Cache of pre-defined Similarities - */ -public class Similarities { - - private static final Map PRE_BUILT_SIMILARITIES; - - static { - Map similarities = new HashMap<>(); - similarities.put(SimilarityLookupService.DEFAULT_SIMILARITY, - new PreBuiltSimilarityProvider.Factory(SimilarityLookupService.DEFAULT_SIMILARITY, new DefaultSimilarity())); - similarities.put("BM25", new PreBuiltSimilarityProvider.Factory("BM25", new BM25Similarity())); - - PRE_BUILT_SIMILARITIES = unmodifiableMap(similarities); - } - - private Similarities() { - } - - /** - * Returns the list of pre-defined SimilarityProvider Factories - * - * @return Pre-defined SimilarityProvider Factories - */ - public static Collection listFactories() { - return PRE_BUILT_SIMILARITIES.values(); - } -} diff --git a/core/src/main/java/org/elasticsearch/index/similarity/SimilarityLookupService.java b/core/src/main/java/org/elasticsearch/index/similarity/SimilarityLookupService.java deleted file mode 100644 index 903f0ea4039..00000000000 --- a/core/src/main/java/org/elasticsearch/index/similarity/SimilarityLookupService.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.index.similarity; - -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.AbstractIndexComponent; -import org.elasticsearch.index.Index; -import org.elasticsearch.index.settings.IndexSettings; - -import java.util.HashMap; -import java.util.Map; - -import static java.util.Collections.emptyMap; -import static java.util.Collections.unmodifiableMap; - -/** - * Service for looking up configured {@link SimilarityProvider} implementations by name. - *

- * The service instantiates the Providers through their Factories using configuration - * values found with the {@link SimilarityModule#SIMILARITY_SETTINGS_PREFIX} prefix. - */ -public class SimilarityLookupService extends AbstractIndexComponent { - - public final static String DEFAULT_SIMILARITY = "default"; - - private final Map similarities; - - public SimilarityLookupService(Index index, Settings indexSettings) { - this(index, indexSettings, emptyMap()); - } - - @Inject - public SimilarityLookupService(Index index, @IndexSettings Settings indexSettings, Map similarities) { - super(index, indexSettings); - - Map providers = new HashMap<>(); - - Map similaritySettings = indexSettings.getGroups(SimilarityModule.SIMILARITY_SETTINGS_PREFIX); - for (Map.Entry entry : similarities.entrySet()) { - String name = entry.getKey(); - SimilarityProvider.Factory factory = entry.getValue(); - - Settings settings = similaritySettings.get(name); - if (settings == null) { - settings = Settings.Builder.EMPTY_SETTINGS; - } - providers.put(name, factory.create(name, settings)); - } - - // For testing - for (PreBuiltSimilarityProvider.Factory factory : Similarities.listFactories()) { - if (!providers.containsKey(factory.name())) { - providers.put(factory.name(), factory.get()); - } - } - - this.similarities = unmodifiableMap(providers); - } - - /** - * Returns the {@link SimilarityProvider} with the given name - * - * @param name Name of the SimilarityProvider to find - * @return {@link SimilarityProvider} with the given name, or {@code null} if no Provider exists - */ - public SimilarityProvider similarity(String name) { - return similarities.get(name); - } -}