def index_single(entity_id): """ Index a single entity. """ entity = Entity.by_id(entity_id) if entity.same_as is not None: return log.debug("Indexing: %s", entity['name'].value) body = entities.to_index(entity) es.index(index=es_index, doc_type='entity', id=body.pop('id'), body=body)
def index_entities(): """ Re-build an index for all enitites from scratch. """ for i, entity in enumerate(Entity.all().filter_by(same_as=None)): body = entities.to_index(entity) if not 'name' in body: log.warn('No name: %s, skipping!', entity.id) continue es.index(index=es_index, doc_type='entity', id=body.pop('id'), body=body) if i > 0 and i % 1000 == 0: log.info("Indexed: %s entities", i) es.indices.refresh(index=es_index) es.indices.refresh(index=es_index)
def index_entities(): """ Re-build an index for all enitites from scratch. """ for i, entity in enumerate(Entity.all().filter_by(same_as=None)): body = entities.to_index(entity) if 'name' not in body.get('properties', {}): log.warn('No name: %s, skipping!', entity.id) #pprint(body) continue es.index(index=es_index, doc_type='entity', id=body.pop('id'), body=body) if i > 0 and i % 1000 == 0: log.info("Indexed: %s entities", i) es.indices.refresh(index=es_index) es.indices.refresh(index=es_index)