# Path: api/theatrics/handlers/helpers.py
# @with_params(ListParams)
# async def get_list(request, query, type_=None, relations={},
#                    page=1, page_size=20, fields=(), expand=()):
#     items, count, took = await search(query, type_, page, page_size, fields)
# 
#     expanding_relations = project(relations, expand)
#     items = await expand_multiple_items(items, expanding_relations)
# 
#     previous = get_previous_page_uri(request, page, page_size)
#     next_ = get_next_page_uri(request, page, page_size, count)
# 
#     return {
#         'count': count,
#         'items': items,
#         'took': took,
#         'previous': previous,
#         'next': next_,
#     }
# 
# Path: api/theatrics/handlers/v1/events.py
# EXPANDABLE_RELATIONS = {
#     'place': ('place', (
#         'location', 'name', 'full_name', 'tagline', 'kind', 'is_for_kids',
#         'is_stub', 'url', 'address', 'subway', 'coords', 'working_hours',
#         'phone_numbers', 'age_restriction',
#     )),
#     'parent': ('event', (
#         'location', 'name', 'full_name', 'tagline', 'kind', 'is_for_kids',
#         'is_premiere', 'tagline', 'age_restriction',
#     )),
#     'participants.agent': ('agent', (
#         'name', 'kind', 'is_stub',
#     ))
# }


import re
from datetime import datetime
from marshmallow import Schema, fields
from theatrics.scoring import get_default_score_functions
from theatrics.utils.handlers import with_params, json_response
from theatrics.utils.collections import get_all
from ..helpers import get_list
from .events import EXPANDABLE_RELATIONS
                            'type': 'phrase',
                            'fields': [
                                'name.ngram',
                                'name.text',
                                'full_name.ngram',
                                'full_name.text'
                            ],
                            'slop': 50
                        }},
                    ],
                    'filter': filters,
                    'should': [
                        {'term': {'_type': 'place'}},
                        {'term': {'is_for_kids': False}},
                    ],
                }},
                'functions': get_default_score_functions()
            }
        },
        'highlight': {
            'fields': {
                'name.ngram': {},
                'name.text': {},
                'full_name.text': {},
                'full_name.ngram': {},
            }
        }
    }



# Path: api/theatrics/handlers/helpers.py
# @with_params(ListParams)
# async def get_list(request, query, type_=None, relations={},
#                    page=1, page_size=20, fields=(), expand=()):
#     items, count, took = await search(query, type_, page, page_size, fields)
# 
#     expanding_relations = project(relations, expand)
#     items = await expand_multiple_items(items, expanding_relations)
# 
#     previous = get_previous_page_uri(request, page, page_size)
#     next_ = get_next_page_uri(request, page, page_size, count)
# 
#     return {
#         'count': count,
#         'items': items,
#         'took': took,
#         'previous': previous,
#         'next': next_,
#     }
# 
# Path: api/theatrics/handlers/v1/events.py
# EXPANDABLE_RELATIONS = {
#     'place': ('place', (
#         'location', 'name', 'full_name', 'tagline', 'kind', 'is_for_kids',
#         'is_stub', 'url', 'address', 'subway', 'coords', 'working_hours',
#         'phone_numbers', 'age_restriction',
#     )),
#     'parent': ('event', (
#         'location', 'name', 'full_name', 'tagline', 'kind', 'is_for_kids',
#         'is_premiere', 'tagline', 'age_restriction',
#     )),
#     'participants.agent': ('agent', (
#         'name', 'kind', 'is_stub',
#     ))
# }


# Path: api/theatrics/handlers/v1/search.py
import re
from datetime import datetime
from marshmallow import Schema, fields
from theatrics.scoring import get_default_score_functions
from theatrics.utils.handlers import with_params, json_response
from theatrics.utils.collections import get_all
from ..helpers import get_list
from .events import EXPANDABLE_RELATIONS

                            'type': 'phrase',
                            'fields': [
                                'name.ngram',
                                'name.text',
                                'full_name.ngram',
                                'full_name.text'
                            ],
                            'slop': 50
                        }},
                    ],
                    'filter': filters,
                    'should': [
                        {'term': {'_type': 'place'}},
                        {'term': {'is_for_kids': False}},
                    ],
                }},
                'functions': get_default_score_functions()
            }
        },
        'highlight': {
            'fields': {
                'name.ngram': {},
                'name.text': {},
                'full_name.text': {},
                'full_name.ngram': {},
            }
        }
    }



def cleanup_highlight(highlight):