Add boolean similarity to built in similarity types (#26613)

This commit is contained in:
Ivan Brusic 2017-09-13 04:58:30 -07:00 committed by Adrien Grand
parent d2cfad6187
commit 9e05b3260b
1 changed files with 9 additions and 12 deletions

View File

@ -46,30 +46,27 @@ public final class SimilarityService extends AbstractIndexComponent {
public static final Map<String, SimilarityProvider.Factory> BUILT_IN;
static {
Map<String, SimilarityProvider.Factory> defaults = new HashMap<>();
Map<String, SimilarityProvider.Factory> buildIn = new HashMap<>();
defaults.put("classic",
(name, settings, indexSettings, scriptService) -> new ClassicSimilarityProvider(name, settings, indexSettings));
defaults.put("BM25",
(name, settings, indexSettings, scriptService) -> new BM25SimilarityProvider(name, settings, indexSettings));
defaults.put("boolean",
(name, settings, indexSettings, scriptService) -> new BooleanSimilarityProvider(name, settings, indexSettings));
buildIn.put("classic",
(name, settings, indexSettings, scriptService) -> new ClassicSimilarityProvider(name, settings, indexSettings));
buildIn.put("BM25",
(name, settings, indexSettings, scriptService) -> new BM25SimilarityProvider(name, settings, indexSettings));
buildIn.put("DFR",
Map<String, SimilarityProvider.Factory> builtIn = new HashMap<>(defaults);
builtIn.put("DFR",
(name, settings, indexSettings, scriptService) -> new DFRSimilarityProvider(name, settings, indexSettings));
buildIn.put("IB",
builtIn.put("IB",
(name, settings, indexSettings, scriptService) -> new IBSimilarityProvider(name, settings, indexSettings));
buildIn.put("LMDirichlet",
builtIn.put("LMDirichlet",
(name, settings, indexSettings, scriptService) -> new LMDirichletSimilarityProvider(name, settings, indexSettings));
buildIn.put("LMJelinekMercer",
builtIn.put("LMJelinekMercer",
(name, settings, indexSettings, scriptService) -> new LMJelinekMercerSimilarityProvider(name, settings, indexSettings));
buildIn.put("DFI",
builtIn.put("DFI",
(name, settings, indexSettings, scriptService) -> new DFISimilarityProvider(name, settings, indexSettings));
buildIn.put("scripted", ScriptedSimilarityProvider::new);
builtIn.put("scripted", ScriptedSimilarityProvider::new);
DEFAULTS = Collections.unmodifiableMap(defaults);
BUILT_IN = Collections.unmodifiableMap(buildIn);
BUILT_IN = Collections.unmodifiableMap(builtIn);
}
public SimilarityService(IndexSettings indexSettings, ScriptService scriptService,