Custom Similiarity Plugin


#1

Hi, I want to update my custom similarity plugin from version 6.2 to version 6.4. However the AbstractSimilarityProvider class has been removed from version 6.4. That class I was using so far for making my lucene Similarity class available in elasticsearch. What is the proper way of integrating a similarity plugin into version 6.4?


(Ryan Ernst) #2

You need to implement the onIndexModule of Plugin, and call addSimilarity. This takes a function which will construct your Similarity from Settings, Version and the ScriptService.


#3

Thanks a lot. That worked out for me. In case it helps anyone, here is the code I ended up with:

public void onIndexModule(IndexModule indexModule) {
	super.onIndexModule(indexModule); //not sure if this is necessary
	indexModule.addSimilarity("myfancysimilarity",
			(settings, indexCreatedVersion, scriptService) -> new MyFancySimilarity());
	
}

(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.