Esempio n. 1
0
def generate_entities(document):
    entities = []
    for entity_id, collection_id in Reference.index_references(document.id):
        entities.append({
            'id': entity_id,
            'collection_id': collection_id
        })
    return entities
Esempio n. 2
0
def generate_entities(document):
    colls = defaultdict(set)
    for entity_id, collection_id in Reference.index_references(document.id):
        colls[entity_id].add(collection_id)

    entities = []
    for entity_id, collections in colls.items():
        entities.append({
            'id': entity_id,
            'collection_id': list(collections)
        })
    return entities
Esempio n. 3
0
def index_document(document):
    if document.status == Document.STATUS_PENDING:
        return

    log.info("Index document: %r", document)
    data = document.to_index_dict()

    data['entities'] = []
    for entity_id, collection_id in Reference.index_references(document.id):
        data['entities'].append({
            'id': entity_id,
            'collection_id': collection_id
        })

    es.index(index=es_index, doc_type=TYPE_DOCUMENT, body=data, id=document.id)