def skip_for_es6(): ec = ElasticCore() first, second, third = ec.get_version() if first == 7: return False else: return True
def humanize_lang_code(lang_code: str, base_mapping: dict = ES6_SNOWBALL_MAPPING, es7_mapping=ES7_SNOWBALL_MAPPING) -> Optional[str]: """ https://www.elastic.co/guide/en/elasticsearch/reference/7.10/analysis-snowball-tokenfilter.html :param lang_code: Language string in ISO 639-1 format. :param base_mapping: Dictionary where the keys are ISO 639-1 codes and the values their humanised forms as per Elasticsearch 6 support. :param es7_mapping: Same as base_mapping but only includes new additions from Elasticsearch 7. :return: Humanized form of the language code that is compatible with the built-in Snowball options that Elasticsearch supports or None if it doesn't. """ ec = ElasticCore() first, second, third = ec.get_version() if first == 6: humanized = base_mapping.get(lang_code, None) return humanized elif first == 7: full_mapping = {**base_mapping, **es7_mapping} humanized = full_mapping.get(lang_code, None) return humanized