本文整理汇总了Python中elasticsearch_dsl.Index.analyzer方法的典型用法代码示例。如果您正苦于以下问题:Python Index.analyzer方法的具体用法?Python Index.analyzer怎么用?Python Index.analyzer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elasticsearch_dsl.Index
的用法示例。
在下文中一共展示了Index.analyzer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_analyzers_returned_from_to_dict
# 需要导入模块: from elasticsearch_dsl import Index [as 别名]
# 或者: from elasticsearch_dsl.Index import analyzer [as 别名]
def test_analyzers_returned_from_to_dict():
random_analyzer_name = ''.join((choice(string.ascii_letters) for _ in range(100)))
random_analyzer = analyzer(random_analyzer_name, tokenizer="standard", filter="standard")
index = Index('i', using='alias')
index.analyzer(random_analyzer)
assert index.to_dict()["settings"]["analysis"]["analyzer"][random_analyzer_name] == {"filter": ["standard"], "type": "custom", "tokenizer": "standard"}
示例2: setup_index
# 需要导入模块: from elasticsearch_dsl import Index [as 别名]
# 或者: from elasticsearch_dsl.Index import analyzer [as 别名]
def setup_index(year):
index = Index(f'{INDEX_NAME}-{year}')
index.settings(number_of_shards=2, number_of_replicas=0)
index.aliases(politicians={})
index.document(Politicians)
index.analyzer(brazilian_analyzer)
index.create()
示例3: test_cloned_index_has_analysis_attribute
# 需要导入模块: from elasticsearch_dsl import Index [as 别名]
# 或者: from elasticsearch_dsl.Index import analyzer [as 别名]
def test_cloned_index_has_analysis_attribute():
"""
Regression test for Issue #582 in which `Index.clone()` was not copying
over the `_analysis` attribute.
"""
client = object()
i = Index('my-index', using=client)
random_analyzer_name = ''.join((choice(string.ascii_letters) for _ in range(100)))
random_analyzer = analyzer(random_analyzer_name, tokenizer="standard", filter="standard")
i.analyzer(random_analyzer)
i2 = i.clone('my-clone-index')
assert i.to_dict()['settings']['analysis'] == i2.to_dict()['settings']['analysis']
示例4: Address
# 需要导入模块: from elasticsearch_dsl import Index [as 别名]
# 或者: from elasticsearch_dsl.Index import analyzer [as 别名]
}
class Address(DocType):
"""Address document."""
class Meta:
index = 'garnahata_addresses'
OWNERSHIP_INDEX = "garnahata_ownerships"
ownership_idx = Index(OWNERSHIP_INDEX)
ownership_idx.settings(**BASIC_INDEX_SETTINGS)
ownership_idx.analyzer(namesAutocompleteAnalyzer)
ownership_idx.analyzer(namesAutocompleteSearchAnalyzer)
ownership_idx.analyzer(ukrainianAddressesStopwordsAnalyzer)
@ownership_idx.doc_type
class Ownership(DocType):
"""Ownership document."""
addresses = Text(analyzer="ukrainianAddressesStopwordsAnalyzer", copy_to="all")
persons = Text(analyzer="ukrainian", copy_to="all")
companies = Text(analyzer="ukrainian", copy_to="all")
registered = Date()
mortgage_registered = Date()
names_autocomplete = Text(
analyzer="namesAutocompleteAnalyzer",
search_analyzer="namesAutocompleteSearchAnalyzer",
示例5: test_conflicting_analyzer_raises_error
# 需要导入模块: from elasticsearch_dsl import Index [as 别名]
# 或者: from elasticsearch_dsl.Index import analyzer [as 别名]
def test_conflicting_analyzer_raises_error():
i = Index('i')
i.analyzer('my_analyzer', tokenizer='whitespace', filter=['lowercase', 'stop'])
with raises(ValueError):
i.analyzer('my_analyzer', tokenizer='keyword', filter=['lowercase', 'stop'])