def write_user_mapping(index='buddyupusers', doc_type='user'): """Write the `user` mapping for buddy up.""" m = Mapping(doc_type) public = Object() public.field('first_name', 'string', index='not_analyzed') public.field('last_name', 'string', index='not_analyzed') public.field('signed_up_at', 'date') m.field('public', public) groups = Nested() groups.field('creator', 'string', index='not_analyzed') groups.field('group_id', 'string', index='not_analyzed') groups.field('school_id', 'string', index='not_analyzed') groups.field('subject', 'string', index='not_analyzed') groups.field('subject_code', 'string', index='not_analyzed') groups.field('subject_icon', 'string', index='not_analyzed') groups.field('start', 'date') groups.field('end', 'date') m.field('groups', groups) private = Object() m.field('private', private) internal = Object() m.field('internal', internal) schools = Nested() m.field('schools', schools) classes = Nested() classes.field('course_id', 'string', index='not_analyzed') classes.field('id', 'string', index='not_analyzed') classes.field('school_id', 'string', index='not_analyzed') classes.field('subject_icon', 'string', index='not_analyzed') m.field('classes', classes) buddies = Nested() buddies.field('user_id', 'string', index='not_analyzed') buddies.field('first_name', 'string', index='not_analyzed') buddies.field('last_name', 'string', index='not_analyzed') m.field('buddies', buddies) buddies_outgoing = Nested() buddies_outgoing.field('user_id', 'string', index='not_analyzed') m.field('buddies_outgoing', buddies_outgoing) m.save(index)
def base_serialized_field(): mapping = Object() mapping.field('url', String(index='not_analyzed')) mapping.field('last_updated', Date()) mapping.field('created', Date()) mapping.field('updaters', String(index='not_analyzed')) # URL references mapping.field('project', String(index='not_analyzed')) mapping.field('related_topics', String(index='not_analyzed', multi=True)) mapping.field('references', String(index='not_analyzed', multi=True)) mapping.field('referenced_by', String(index='not_analyzed', multi=True)) return mapping
def write_event_mapping(index='buddyupevents', doc_type='event'): """Write the `event` mapping for an ES index and doc type. http://elasticsearch-dsl.readthedocs.org/en/latest/persistence.html#mappings """ m = Mapping(doc_type) data = Object() # elasticsearch_dsl field object data.field('password', 'string', index='no', include_in_all=False, store=False) data.field('first_name', 'string', index='not_analyzed') data.field('last_name', 'string', index='not_analyzed') data.field('accepted_by', 'string', index='not_analyzed') data.field('accepted_by_last_name', 'string', index='not_analyzed') data.field('accepted_by_first_name', 'string', index='not_analyzed') data.field('requested_by', 'string', index='not_analyzed') data.field('requested_by_last_name', 'string', index='not_analyzed') data.field('requested_by_first_name', 'string', index='not_analyzed') data.field('recipient', 'string', index='not_analyzed') data.field('recipient_first_name', 'string', index='not_analyzed') data.field('recipient_last_name', 'string', index='not_analyzed') data.field('sender', 'string', index='not_analyzed') data.field('sender_first_name', 'string', index='not_analyzed') data.field('sender_last_name', 'string', index='not_analyzed') data.field('sender_last_name', 'string', index='not_analyzed') data.field('email', 'string', index='not_analyzed') data.field('sent_at', 'date') data.field('start', 'date') data.field('end', 'date') device = Object() device.field('manufacturer', 'string', index='not_analyzed') device.field('model', 'string', index='not_analyzed') device.field('platform', 'string', index='not_analyzed') data.field('device', device) m.field('data', data) m.field('created_at', 'date') m.field('first_name', 'string', index='not_analyzed') m.field('last_name', 'string', index='not_analyzed') m.field('id', 'string', index='not_analyzed') m.field('creator', 'string', index='not_analyzed') m.field('involved', 'string', index='not_analyzed') m.field('profile_pic_url_tiny', 'string', index='not_analyzed') m.field('type', 'string', index='not_analyzed') m.save(index)
def base_serialized_field(): mapping = Object() mapping.field("url", String(index="not_analyzed")) mapping.field("last_updated", Date()) mapping.field("created", Date()) mapping.field("updaters", String(index="not_analyzed")) # URL references mapping.field("project", String(index="not_analyzed")) mapping.field("related_topics", String(index="not_analyzed", multi=True)) mapping.field("references", String(index="not_analyzed", multi=True)) mapping.field("referenced_by", String(index="not_analyzed", multi=True)) return mapping