<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def search_payload(self, fields=None, query=None):
 """Create a search query. Do the following: 1. Generate a search query. By default, all values returned by :meth:`nailgun.entity_mixins.Entity.get_values` are used. If ``fields`` is specified, only the named values are used. 2. Merge ``query`` in to the generated search query. 3. Return the result. The rules for generating a search query can be illustrated by example. Let's say that we have an entity with an :class:`nailgun.entity_fields.IntegerField`, a :class:`nailgun.entity_fields.OneToOneField` and a :class:`nailgun.entity_fields.OneToManyField`:: True True True This method appends "_id" and "_ids" on to the names of each ``OneToOneField`` and ``OneToManyField``, respectively:: {'id': 1, 'one_id': 2, 'many_ids': [3, 4]} By default, all fields are used. But you can specify a set of field names to use:: {'id': 1} {'one_id': 2} {'id': 1, 'one_id': 2} If a ``query`` is specified, it is merged in to the generated query:: {'id': 5, 'one_id': 2, 'many_ids': [3, 4]} {'id': 1, 'one_id': 2, 'many_ids': [3, 4], 'per_page': 1000} .. WARNING:: This method currently generates an extremely naive search query that will be wrong in many cases. In addition, Satellite currently accepts invalid search queries without complaint. Make sure to check the API documentation for your version of Satellite against what this method produces. :param fields: See :meth:`search`. :param query: See :meth:`search`. :returns: A dict that can be encoded as JSON and used in a search. """

        if fields is None:
            fields = set(self.get_values().keys())
        if query is None:
            query = {}

        payload = {}
        fields_dict = self.get_fields()
        for field in fields:
            value = getattr(self, field)
            if isinstance(fields_dict[field], OneToOneField):
                payload[field + '_id'] = value.id
            elif isinstance(fields_dict[field], OneToManyField):
                payload[field + '_ids'] = [entity.id for entity in value]
            else:
                payload[field] = value
        payload.update(query)
        return payload