(results, fields_property='fields')
return field_dict
In ElasticSearch 1.3, the return format was changed such that field
    values are always returned as lists, where as previously they would
    be returned as scalars if the field had a single value, and returned
    as lists if the field had multiple values.
    This method restores the behavior of 0.90 .

    https://www.elastic.co/guide/en/elasticsearch/reference/1.3/_return_values.html
In ElasticSearch 1.3, the return format was changed such that field
    values are always returned as lists, where as previously they would
    be returned as scalars if the field had a single value, and returned
    as lists if the field had multiple values.
    This method restores the behavior of 0.90 .
In ElasticSearch 1 . 3 the return format was changed such that field values are always returned as lists where as previously they would be returned as scalars if the field had a single value and returned as lists if the field had multiple values . This method restores the behavior of 0 . 90 .
def flatten_field_dict(results, fields_property='fields'):
    """
    In ElasticSearch 1.3, the return format was changed such that field
    values are always returned as lists, where as previously they would
    be returned as scalars if the field had a single value, and returned
    as lists if the field had multiple values.
    This method restores the behavior of 0.90 .

    https://www.elastic.co/guide/en/elasticsearch/reference/1.3/_return_values.html
    """
    field_dict = results.get(fields_property, {})
    for key, val in field_dict.items():
        new_val = val
        if type(val) == list and len(val) == 1:
            new_val = val[0]
        field_dict[key] = new_val
    return field_dict
def flatten_field_dict ( results , fields_property = 'fields' ) : field_dict = results . get ( fields_property , { } ) for key , val in field_dict . items ( ) : new_val = val if type ( val ) == list and len ( val ) == 1 : new_val = val [ 0 ] field_dict [ key ] = new_val return field_dict