本文整理汇总了Python中elasticsearch_dsl.Boolean方法的典型用法代码示例。如果您正苦于以下问题:Python elasticsearch_dsl.Boolean方法的具体用法?Python elasticsearch_dsl.Boolean怎么用?Python elasticsearch_dsl.Boolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elasticsearch_dsl
的用法示例。
在下文中一共展示了elasticsearch_dsl.Boolean方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: document_field
# 需要导入模块: import elasticsearch_dsl [as 别名]
# 或者: from elasticsearch_dsl import Boolean [as 别名]
def document_field(field):
"""
The default ``field_factory`` method for converting Django field instances to ``elasticsearch_dsl.Field`` instances.
Auto-created fields (primary keys, for example) and one-to-many fields (reverse FK relationships) are skipped.
"""
if field.auto_created or field.one_to_many:
return None
if field.many_to_many:
return RawMultiString
defaults = {
models.DateField: dsl.Date(),
models.DateTimeField: dsl.Date(),
models.IntegerField: dsl.Long(),
models.PositiveIntegerField: dsl.Long(),
models.BooleanField: dsl.Boolean(),
models.NullBooleanField: dsl.Boolean(),
models.SlugField: dsl.String(index='not_analyzed'),
models.DecimalField: dsl.Double(),
models.FloatField: dsl.Float(),
}
return defaults.get(field.__class__, RawString)
示例2: restore_tokens
# 需要导入模块: import elasticsearch_dsl [as 别名]
# 或者: from elasticsearch_dsl import Boolean [as 别名]
def restore_tokens():
connections.create_connection(hosts=ES_NODES)
Index(INDEX_NAME).delete()
class Token(DocType):
username = String()
token = String()
expires = Date()
read = Boolean()
write = Boolean()
revoked = Boolean()
acl = String()
groups = String()
admin = Boolean()
last_activity_at = Date()
class Meta:
index = INDEX_NAME
Token.init()
reindex_results = connections.get_connection().reindex(body={"source": {"index": BACKUP_INDEX_NAME}, "dest": {"index": INDEX_NAME}}, request_timeout=3600)
if reindex_results.get('created') + reindex_results.get('updated') == reindex_results.get('total'):
return ('Tokens restored to previous schema successfully!')
else:
return ('Tokens did not restore from backup properly')