def _from_meta(cls, meta, collection_id): obj = cls() obj.collection_id = collection_id obj.crawler_id = meta.crawler obj.crawler_run = meta.crawler_run obj.foreign_id = meta.foreign_id obj.content_hash = meta.content_hash obj.meta = expand_json(meta.to_attr_dict(compute=True)) db.session.add(obj) return obj
def index_entity(entity): """Index an entity.""" data = entity.to_dict() data.pop('id', None) data['doc_count'] = get_count(entity) data['terms'] = entity.terms data['terms_latin'] = [latinize_text(t) for t in entity.terms] data['name_latin'] = latinize_text(data.get('name')) data['summary_latin'] = latinize_text(data.get('summary')) data['description_latin'] = latinize_text(data.get('description')) data = expand_json(data) get_es().index(index=get_es_index(), doc_type=TYPE_ENTITY, id=entity.id, body=data)