本文整理汇总了Python中elasticsearch_dsl.Index.to_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Index.to_dict方法的具体用法?Python Index.to_dict怎么用?Python Index.to_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elasticsearch_dsl.Index
的用法示例。
在下文中一共展示了Index.to_dict方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_conflicting_mapping_raises_error_in_index_to_dict
# 需要导入模块: from elasticsearch_dsl import Index [as 别名]
# 或者: from elasticsearch_dsl.Index import to_dict [as 别名]
def test_conflicting_mapping_raises_error_in_index_to_dict():
class A(document.Document):
name = field.Text()
class B(document.Document):
name = field.Keyword()
i = Index('i')
i.document(A)
i.document(B)
with raises(ValueError):
i.to_dict()
示例2: test_analyzers_returned_from_to_dict
# 需要导入模块: from elasticsearch_dsl import Index [as 别名]
# 或者: from elasticsearch_dsl.Index import to_dict [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"}
示例3: test_aliases_returned_from_to_dict
# 需要导入模块: from elasticsearch_dsl import Index [as 别名]
# 或者: from elasticsearch_dsl.Index import to_dict [as 别名]
def test_aliases_returned_from_to_dict():
random_alias = ''.join((choice(string.ascii_letters) for _ in range(100)))
alias_dict = {random_alias: {}}
index = Index('i', using='alias')
index.aliases(**alias_dict)
assert index._aliases == index.to_dict()['aliases'] == alias_dict
示例4: test_settings_are_saved
# 需要导入模块: from elasticsearch_dsl import Index [as 别名]
# 或者: from elasticsearch_dsl.Index import to_dict [as 别名]
def test_settings_are_saved():
i = Index('i')
i.settings(number_of_replicas=0)
i.settings(number_of_shards=1)
assert {
'settings': {
'number_of_shards': 1,
'number_of_replicas': 0,
}
} == i.to_dict()
示例5: test_registered_doc_type_included_in_to_dict
# 需要导入模块: from elasticsearch_dsl import Index [as 别名]
# 或者: from elasticsearch_dsl.Index import to_dict [as 别名]
def test_registered_doc_type_included_in_to_dict():
i = Index('i', using='alias')
i.document(Post)
assert {
'mappings': {
'properties': {
'title': {'type': 'text'},
'published_from': {'type': 'date'},
}
}
} == i.to_dict()
示例6: test_registered_doc_type_included_in_to_dict
# 需要导入模块: from elasticsearch_dsl import Index [as 别名]
# 或者: from elasticsearch_dsl.Index import to_dict [as 别名]
def test_registered_doc_type_included_in_to_dict():
i = Index('i', using='alias')
i.doc_type(Post)
assert Post._doc_type.index == 'i'
assert {
'mappings': {
'post': {
'properties': {
'title': {'type': 'string'},
'published_from': {'type': 'date'},
}
}
}
} == i.to_dict()
示例7: test_doc_type_can_be_set
# 需要导入模块: from elasticsearch_dsl import Index [as 别名]
# 或者: from elasticsearch_dsl.Index import to_dict [as 别名]
def test_doc_type_can_be_set():
i = Index('i', doc_type='t')
m = Mapping('t')
m.field('title', Text())
i.mapping(m)
assert {
'mappings': {
't': {
'properties': {
'title': {'type': 'text'}
}
}
}
} == i.to_dict()
示例8: test_cloned_index_has_analysis_attribute
# 需要导入模块: from elasticsearch_dsl import Index [as 别名]
# 或者: from elasticsearch_dsl.Index import to_dict [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']
示例9: test_multiple_doc_types_will_combine_mappings
# 需要导入模块: from elasticsearch_dsl import Index [as 别名]
# 或者: from elasticsearch_dsl.Index import to_dict [as 别名]
def test_multiple_doc_types_will_combine_mappings():
class User(Document):
username = Text()
i = Index('i')
i.document(Post)
i.document(User)
assert {
'mappings': {
'properties': {
'title': {'type': 'text'},
'username': {'type': 'text'},
'published_from': {'type': 'date'}
}
}
} == i.to_dict()