def script_fields(self, **kwargs):
    '\n        Define script fields to be calculated on hits. See\n        https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html\n        for more details.\n\n        Example::\n\n            s = Search()\n            s = s.script_fields(times_two="doc[\'field\'].value * 2")\n            s = s.script_fields(\n                times_three={\n                    \'script\': {\n                        \'inline\': "doc[\'field\'].value * params.n",\n                        \'params\': {\'n\': 3}\n                    }\n                }\n            )\n\n        '
    s = self._clone()
    for name in kwargs:
        if isinstance(kwargs[name], string_types):
            kwargs[name] = {'script': kwargs[name]}
    s._script_fields.update(kwargs)
    return s
Define script fields to be calculated on hits. See
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html
for more details.

Example::

    s = Search()
    s = s.script_fields(times_two="doc['field'].value * 2")
    s = s.script_fields(
        times_three={
            'script': {
                'inline': "doc['field'].value * params.n",
                'params': {'n': 3}
            }
        }
    )
def script_fields(self, **kwargs):
    '\n        Define script fields to be calculated on hits. See\n        https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html\n        for more details.\n\n        Example::\n\n            s = Search()\n            s = s.script_fields(times_two="doc[\'field\'].value * 2")\n            s = s.script_fields(\n                times_three={\n                    \'script\': {\n                        \'inline\': "doc[\'field\'].value * params.n",\n                        \'params\': {\'n\': 3}\n                    }\n                }\n            )\n\n        '
    s = self._clone()
    for name in kwargs:
        if isinstance(kwargs[name], string_types):
            kwargs[name] = {'script': kwargs[name]}
    s._script_fields.update(kwargs)
    return s