Skip to content

[BUG] MapperService has to be passed in as null for EnginePlugins CodecService constructor #1805

@jmazanec15

Description

@jmazanec15

Describe the bug
Because only index settings are passed into the getCustomCodecService of an EnginePlugin, a non-null MapperService cannot be passed in for the call to super in the custom CodecService constructor.

An issue arises for custom CodecService's that implement their Codec using the delegate pattern. In my case this is the k-NN plugin. The k-NN Codec is really only interested in implementing docValuesFormat and compoundFormat. For the others, it delegates. Because the mapper service is always null, the PerFieldMappingPostingFormatCodec can never be used as the delegate. Because a CodecService is used for the whole index, an index with index.knn set to true cannot get some features provided by PerFieldMappingPostingFormatCodec, even if they are not related to the knn field. We got an issue for this some time back: opendistro-for-elasticsearch/k-NN#227. Our solution was to set the PostingFormat from the custom EngineFactory. However, as I am trying to remove the custom engine factory and just rely on custom Codec Service, this solution will no longer work.

To Reproduce
See opendistro-for-elasticsearch/k-NN#227 as an example.

Expected behavior
An EnginePlugin's custom CodecService can be constructed with a non-null mapperService.

I think this could be fixed by changing where the CodecService's are constructed or perhaps using some kind of CodecService Supplier in the EngineConfigFactory. However, I cannot think of a clean way of fixing it without changing the EnginePlugin interface.

Plugins
N/A

Screenshots
N/A

Host/Environment (please complete the following information):
N/A

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions