def service_location(doc):
    """View for getting service by location"""
    for service_id, service in doc.get('services', {}).items():
        service['id'] = service_id
        service['organisation_id'] = doc['_id']

        location = service.get('location', None)
        if location:
            yield location, service
def service_location ( doc ) : for service_id , service in doc . get ( 'services' , { } ) . items ( ) : service [ 'id' ] = service_id service [ 'organisation_id' ] = doc [ '_id' ] location = service . get ( 'location' , None ) if location : yield location , service
View for getting service by location