elasticsearch-plugin-bundle
elasticsearch-plugin-bundle copied to clipboard
Can't set "languages" for fields of type langdetect when profile is shorttext
There is a check (https://github.com/jprante/elasticsearch-plugin-bundle/blob/e75891afbc280de6e5b924c57fd029642b268777/src/main/java/org/xbib/elasticsearch/plugin/bundle/common/langdetect/LangdetectService.java#L172) and when the profile is shorttext then languages_short_text
is used but it is never set in builder/parser: https://github.com/jprante/elasticsearch-plugin-bundle/blob/e75891afbc280de6e5b924c57fd029642b268777/src/main/java/org/xbib/elasticsearch/plugin/bundle/index/mapper/langdetect/LangdetectMapper.java#L391 (only languages
are set)
In this fix we first try to get the value of languages
list (if available) before using the default value for languages_short_text
. We don't need initialization of languages
in DEFAULT_SETTINGS
because we provide a default value when getting the languages (https://github.com/jprante/elasticsearch-plugin-bundle/blob/e75891afbc280de6e5b924c57fd029642b268777/src/main/java/org/xbib/elasticsearch/plugin/bundle/common/langdetect/LangdetectService.java#L174). By doing that we ensure that DEFAULT_LANGUAGES_SHORT_TEXT
will be used if no configuration is provided (default constructor). The only drawback of this approach is if someone provide settings that contains languages
but not contains languages_short_text
and actually want to use DEFAULT_LANGUAGES_SHORT_TEXT
. This case could be avoided if the default constructor is used in the situation.
However test case needs to be created...
Nice catch, thanks