本文整理匯總了Python中elasticsearch_dsl.Object方法的典型用法代碼示例。如果您正苦於以下問題:Python elasticsearch_dsl.Object方法的具體用法?Python elasticsearch_dsl.Object怎麽用?Python elasticsearch_dsl.Object使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類elasticsearch_dsl
的用法示例。
在下文中一共展示了elasticsearch_dsl.Object方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_field_sort
# 需要導入模塊: import elasticsearch_dsl [as 別名]
# 或者: from elasticsearch_dsl import Object [as 別名]
def get_field_sort(self, field_name):
"""
Given a field name, returns the field name that should be used for sorting. If a mapping defines
a .raw sub-field, that is used, otherwise the field name itself is used if index=not_analyzed.
"""
if field_name.endswith('.raw'):
return field_name
if field_name in self.sort_fields:
return self.sort_fields[field_name]
if field_name in self.document._doc_type.mapping:
dsl_field = self.document._doc_type.mapping[field_name]
if isinstance(dsl_field, (dsl.Object, dsl.Nested)):
return None
if not isinstance(dsl_field, dsl.String):
return field_name
if 'raw' in dsl_field.fields:
return '%s.raw' % field_name
elif getattr(dsl_field, 'index', None) == 'not_analyzed':
return field_name
return None
示例2: test_bucket_keys_get_deserialized
# 需要導入模塊: import elasticsearch_dsl [as 別名]
# 或者: from elasticsearch_dsl import Object [as 別名]
def test_bucket_keys_get_deserialized(aggs_data, aggs_search):
class Commit(Document):
info = Object(properties={'committed_date': Date()})
class Index:
name = 'test-commit'
aggs_search = aggs_search.doc_type(Commit)
agg_response = response.Response(aggs_search, aggs_data)
per_month = agg_response.aggregations.per_month
for b in per_month:
assert isinstance(b.key, date)
示例3: deep_field_factory
# 需要導入模塊: import elasticsearch_dsl [as 別名]
# 或者: from elasticsearch_dsl import Object [as 別名]
def deep_field_factory(field):
if field.is_relation and (field.many_to_one or field.one_to_one):
props = {}
for f in field.related_model._meta.get_fields():
nested_field = deep_field_factory(f)
if nested_field is not None:
props[f.name] = nested_field
return dsl.Object(properties=props)
else:
return document_field(field)
示例4: get_field_highlight
# 需要導入模塊: import elasticsearch_dsl [as 別名]
# 或者: from elasticsearch_dsl import Object [as 別名]
def get_field_highlight(self, field_name):
if field_name in self.highlight_fields:
return self.highlight_fields[field_name]
if field_name in self.document._doc_type.mapping:
dsl_field = self.document._doc_type.mapping[field_name]
if isinstance(dsl_field, (dsl.Object, dsl.Nested)):
return '%s.*' % field_name
return field_name
return None