(hit, include_score=False, is_related_case=False)
return result
Flattens a result from CaseSearchES into the format that Case serializers
    expect

    i.e. instead of {'name': 'blah', 'case_properties':{'key':'foo', 'value':'bar'}} we return
    {'name': 'blah', 'foo':'bar'}
Flattens a result from CaseSearchES into the format that Case serializers
    expect
Flattens a result from CaseSearchES into the format that Case serializers expect
def flatten_result(hit, include_score=False, is_related_case=False):
    """Flattens a result from CaseSearchES into the format that Case serializers
    expect

    i.e. instead of {'name': 'blah', 'case_properties':{'key':'foo', 'value':'bar'}} we return
    {'name': 'blah', 'foo':'bar'}
    """
    try:
        result = hit['_source']
    except KeyError:
        result = hit

    if include_score:
        result[RELEVANCE_SCORE] = hit['_score']
    if is_related_case:
        result[IS_RELATED_CASE] = "true"
    case_properties = result.pop(CASE_PROPERTIES_PATH, [])
    for case_property in case_properties:
        key = case_property.get('key')
        value = case_property.get('value')
        if key is not None and key not in SPECIAL_CASE_PROPERTIES and value:
            result[key] = value

    for key in SYSTEM_PROPERTIES:
        result.pop(key, None)
    return result
def flatten_result ( hit , include_score = False , is_related_case = False ) : try : result = hit [ '_source' ] except KeyError : result = hit if include_score : result [ RELEVANCE_SCORE ] = hit [ '_score' ] if is_related_case : result [ IS_RELATED_CASE ] = "true" case_properties = result . pop ( CASE_PROPERTIES_PATH , [ ] ) for case_property in case_properties : key = case_property . get ( 'key' ) value = case_property . get ( 'value' ) if key is not None and key not in SPECIAL_CASE_PROPERTIES and value : result [ key ] = value for key in SYSTEM_PROPERTIES : result . pop ( key , None ) return result