def add_search(self, query, page=1, page_size=20, index='', doc_type='', query_params={}):
        if isinstance(query, ElasticsearchForm):
            form = query
            index = index or form.get_index()
            doc_type = doc_type or form.get_type()

            qp = form.query_params.copy()
            qp.update(query_params)
            query_params = qp

            query = form.prepare_query()
        elif isinstance(query, Search):
            dsl_search = query
            index = index or dsl_search._index
            doc_type = doc_type or dsl_search._doc_type

            qp = dsl_search._params.copy()
            qp.update(query_params)
            query_params = qp

            query = dsl_search.to_dict()
        elif isinstance(query, dict):
            pass
        else:
            # we don't support any other type of object
            return

        try:
            page = int(page)
        except ValueError:
            page = 1

        try:
            page_size = int(page_size)
        except ValueError:
            page_size = 20

        query['from'] = (page - 1) * page_size
        query['size'] = page_size

        # save these here so we can attach the info the the responses below
        self.page_ranges.append((page, page_size))

        data = query_params.copy()
        if index:
            data['index'] = index
        if doc_type:
            data['type'] = doc_type

        self.bulk_search_data.append(data)
        self.bulk_search_data.append(query)
dataset/ETHPy150Open jaddison/django-simple-elasticsearch/simple_elasticsearch/forms.py/ElasticsearchProcessor.add_search/original