Generates the query keys for the default structure of the query index.
    The structure of the key: [field_name, value].
    It supports custom sorting, in which case the value is substituted
    bu the result of transform(value).

    @param transform: callable of 1 argument
    @param field: C{str} field name
    @param evaluator: C{Evaluator}
    @param value: value
    @rtype: dict
    @returns: keys to use to query the view

def generate_keys(transform, field, evaluator, value):
    '''
    Generates the query keys for the default structure of the query index.
    The structure of the key: [field_name, value].
    It supports custom sorting, in which case the value is substituted
    bu the result of transform(value).

    @param transform: callable of 1 argument
    @param field: C{str} field name
    @param evaluator: C{Evaluator}
    @param value: value
    @rtype: dict
    @returns: keys to use to query the view
    '''

    if evaluator == Evaluator.equals:
        return dict(key=(field, transform(value)))
    if evaluator == Evaluator.le:
        return dict(startkey=(field, ), endkey=(field, transform(value)))
    if evaluator == Evaluator.ge:
        return dict(startkey=(field, transform(value)), endkey=(field, {}))
    if evaluator == Evaluator.between:
        return dict(startkey=(field, transform(value[0])),
                    endkey=(field, transform(value[1])))
    if evaluator == Evaluator.inside:
        return dict(keys=[(field, transform(x)) for x in value])
    if evaluator == Evaluator.none:
        return dict(startkey=(field, ), endkey=(field, {}))