本文整理匯總了Python中criteria.helper.criteria.Criteria.get_criteria_details方法的典型用法代碼示例。如果您正苦於以下問題:Python Criteria.get_criteria_details方法的具體用法?Python Criteria.get_criteria_details怎麽用?Python Criteria.get_criteria_details使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類criteria.helper.criteria.Criteria
的用法示例。
在下文中一共展示了Criteria.get_criteria_details方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_criteria_details
# 需要導入模塊: from criteria.helper.criteria import Criteria [as 別名]
# 或者: from criteria.helper.criteria.Criteria import get_criteria_details [as 別名]
def get_criteria_details(cls, feature_id, idx=None, idx_type=None, config=None):
'Function to get the criteria details for a given feature_id'
if idx is None:
idx = ElasticSettings.idx(cls.FEATURE_TYPE.upper()+'_CRITERIA')
# get all the criterias from ini
criteria_list = []
if idx_type is None:
available_criterias = cls.get_available_criterias(feature=cls.FEATURE_TYPE, config=config)
criteria_list = available_criterias[cls.FEATURE_TYPE]
idx_type = ','.join(criteria_list)
result_dict = Criteria.get_criteria_details(feature_id, idx, idx_type)
result_dict_expanded = Criteria.add_meta_info(idx, criteria_list, result_dict)
return result_dict_expanded
示例2: filter_queryset
# 需要導入模塊: from criteria.helper.criteria import Criteria [as 別名]
# 或者: from criteria.helper.criteria.Criteria import get_criteria_details [as 別名]
def filter_queryset(self, request, queryset, view):
''' Override this method to request just the documents required from elastic. '''
q_size = view.paginator.get_limit(request)
q_from = view.paginator.get_offset(request)
filterable = getattr(view, 'filter_fields', [])
filters = dict([(k, v) for k, v in request.GET.items() if k in filterable])
criteria_idx = self._get_index(filters.get('feature_type', 'GENE_CRITERIA'))
feature_type = filters.get('feature_type')
feature_id = filters.get('feature_id')
aggregate = filters.get('aggregate')
detail = filters.get('detail')
idx = criteria_idx
if type(criteria_idx) == list:
idx = ','.join(ElasticSettings.idx(name) for name in criteria_idx)
else:
idx = ElasticSettings.idx(criteria_idx)
results = []
if feature_id and aggregate == 'true':
disease_doc_tags = Criteria.get_disease_tags(feature_id, idx=idx)
disease_tags = [getattr(d, 'code') for d in disease_doc_tags]
new_obj = ElasticObject()
new_obj.qid = feature_id
new_obj.disease_tags = disease_tags
new_obj.criteria_type = None
results.append(new_obj)
return results
elif feature_id and detail == 'true':
(idx, idx_types) = Criteria.get_feature_idx_n_idxtypes(feature_type.lower())
criteria_details = Criteria.get_criteria_details(feature_id, idx=idx, idx_type=idx_types)
criteria_list = idx_types.split(',')
criteria_details_expanded = Criteria.add_meta_info(idx, criteria_list, criteria_details)
feature_details = self._get_feature_details(criteria_details_expanded)
for criteria, details in feature_details.items():
print(criteria)
new_obj = ElasticObject()
new_obj.qid = details['qid']
new_obj.criteria_type = criteria
disease_tags = details['disease_tags']
fdetails = list(details['fdetails'])
print('+++++++++++++++')
print(disease_tags)
print(fdetails)
print('+++++++++++++++')
new_obj.disease_tags = disease_tags
new_obj.feature_details = fdetails
results.append(new_obj)
return results
else:
q = ElasticQuery(Query.match_all())
s = Search(search_query=q, idx=idx, size=q_size, search_from=q_from)
json_results = s.get_json_response()
for result in json_results['hits']['hits']:
new_obj = ElasticObject(initial=result['_source'])
new_obj.uuid = result['_id']
new_obj.criteria_type = result['_type']
results.append(new_obj)
view.es_count = json_results['hits']['total']
return results