@classmethod
def process_search_query(cls, search_params, regular_term_fields,
    regular_terms_fields, regular_date_fields, post_params, aggs, sort,
    page, limit, **kwds):
    """Common function to generate query, send to elastic and return the results dict.

    search_params: dict
    regular_term_fields: dict
    regular_terms_fields: dict
    regular_date_fields: dict
    post_params: dict
    aggs: dict
    sort: dict
    page: int
    limit: int
    kwds: dict (other params)
    - index_name: string
    - highlight: bool
    - id_key: string
    - render: ['raw', 'select', 'query', 'pager'] (default is map)
    - raw_aggs: if set it return the raw aggs
    - no_source: if set it will deactivate _source
    - fields: str or list (Source filtering) don't support dict like _source
    - raw_search: {'any_search'}, will be appended in the [bool][must]
    - page_len: int for the paginator render

      return dict
    """
    page = int(page)
    if kwds.get('index_name'):
        index_name = kwds.get('index_name')
    else:
        index_name = cls.get_index_name()
    if not search_params:
        search_params = {}
    if not post_params:
        post_params = {}
    ret = {index_name: {}, 'total': 0, 'aggs': {}}
    filters = cls.process_regular_fields(search_params, regular_term_fields,
        regular_terms_fields, regular_date_fields)
    query = cls.process_filters(query={}, filters=filters)
    post_filter = cls.process_regular_fields(post_params,
        regular_term_fields, regular_terms_fields, regular_date_fields)
    query, keyword_query = cls.process_keyword_query_filter(query,
        search_params)
    if kwds.get('raw_search'):
        if not query:
            query = {'bool': {'must': []}}
        query['bool']['must'].append(kwds.get('raw_search'))
    if not query:
        query = {'match_all': {}}
    my_query = {'query': query}
    if aggs:
        my_query['aggregations'] = aggs
    if kwds.get('no_source'):
        my_query['_source'] = False
        kwds['render'] = 'raw'
    elif kwds.get('fields'):
        my_query['_source'] = kwds.get('fields')
    my_query = cls.process_post_filters(post_filter, my_query)
    if sort is None:
        if keyword_query:
            sort = [{'_score': 'desc'}]
        else:
            sort = [{'created_at': 'asc'}, {cls.ID_KEY: 'asc'}]
    if sort not in cls.SKIP_SORT_LIST:
        my_query['sort'] = sort
    _from = page - 1
    if _from < 0:
        _from = 0
    my_query['from'] = _from * limit
    my_query['size'] = limit
    if kwds.get('highlight'):
        my_query['highlight'] = kwds['highlight']
    if cls.DEBUG_QUERY:
        print('\n' + '=' * len('= ELASTIC SEARCH QUERY +' * 5) + '\n' + 
            '+ ELASTIC SEARCH QUERY +' * 5 + '\n' + '=' * len(
            '+ ELASTIC SEARCH QUERY =' * 5))
        print('Class name :', cls.__name__, ' index_name', index_name)
        import json
        print(json.dumps(my_query))
    id_key = kwds.get('id_key') or cls.ID_KEY
    if kwds.get('render') == 'query':
        return my_query
    result = cls.search(my_query, myindex=index_name)
    if kwds.get('render') == 'select':
        mapped_result = cls.render_select(result)
    elif kwds.get('render') == 'paginator':
        mapped_result = cls.render_paginator(result, page=page, limit=limit,
            page_len=kwds.get('page_len', 0))
    elif kwds.get('render') == 'raw':
        mapped_result = result
    elif kwds.get('render') == 'pager':
        mapped_result = cls.render_pager(result)
    else:
        mapped_result = cls.render_map(result, id_key=id_key)
    if aggs:
        aggs_result_tmp = result.get('aggregations') or {}
        aggs_result = {}
        if kwds.get('raw_aggs'):
            aggs_result = aggs_result_tmp
        elif aggs_result_tmp:
            from collections import OrderedDict
            aggs_result = {}
            for name in aggs.keys():
                if 'buckets' in result['aggregations'][name]:
                    aggs_field_ordered_dict = OrderedDict()
                    for item in result['aggregations'][name]['buckets']:
                        aggs_field_ordered_dict.update({item['key']: item[
                            'doc_count']})
                    aggs_result[name] = aggs_field_ordered_dict
                elif 'value' in result['aggregations'][name]:
                    aggs_result[name] = result['aggregations'][name]['value']
                else:
                    raise NotImplementedError
        ret[index_name] = mapped_result[0]
        ret['total'] = mapped_result[1]
        ret['aggs'] = aggs_result
    elif kwds.get('render') and kwds.get('render') in ('select', 'raw'):
        ret[index_name] = mapped_result
        if kwds.get('render') == 'raw':
            ret['total'] = mapped_result['hits']['total']
        elif kwds.get('render') == 'select':
            ret['total'] = len(mapped_result)
    else:
        ret[index_name] = mapped_result[0]
        ret['total'] = mapped_result[1]
    return ret
