def set_properties(schema_class, dynamic=False, custom_types=default_special_types, nested_types=default_nested_types, init_dict=None):
    """
    Helper function to walk a schema_class's properties recursively and create a typed out mapping
    that can index well (specifically dict types and date time properties)
    """
    props_dict = init_dict or {}
    for prop_name, prop_type in schema_class.properties().items():
        if custom_types.has_key(prop_name):
            props_dict[prop_name] = custom_types[prop_name]
        elif simple_type_mapper.has_key(prop_type.__class__):
            props_dict[prop_name] = simple_type_mapper[prop_type.__class__]
        elif complex_type_mapper.has_key(prop_type.__class__):
            func = complex_type_mapper[prop_type.__class__]
            sub_types = custom_types.get("__sub_types", {}).get(prop_name)
            props_dict[prop_name] = func(prop_type._schema, nested=nested_types in prop_name, dynamic=dynamic, sub_types=sub_types)

    if not props_dict.get('doc_type'):
        props_dict["doc_type"] = {"type": "string", "index": "not_analyzed"}
    return props_dict



#A conservative mapping - don't detect datestring we don't know about
#but try to always add to mapping additional properties of dicts we didn't expect (from DictProperties)
dataset/ETHPy150Open dimagi/commcare-hq/corehq/pillows/dynamic.py/set_properties/swapped operands of `in`