-
-
Save alecklandgraf/a8a64b3a25fa1399eab5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def reindex_orgs(org_ids): | |
from seed.services import es_search_query | |
from elasticsearch import Elasticsearch | |
s = es_search_query() | |
s = s.filter('terms', building_snapshot__super_organization=org_ids) | |
from seed.services import elasticsearch_client | |
es = elasticsearch_client() | |
es.delete_by_query(index=settings.ES_INDEX, doc_type='canonical_building', body=s.to_dict()) | |
from seed.utils.seed_elasticsearch import canon_serializer | |
import itertools | |
from seed.utils.generic import queryset_iterator_v2 | |
from elasticsearch.helpers import bulk | |
es = Elasticsearch([{'host': settings.ES_HOST}], timeout=120, index='buildingenergy') | |
bulk(es, itertools.imap(canon_serializer,queryset_iterator_v2(CanonicalBuilding.objects.filter(canonical_snapshot__super_organization__in=org_ids)))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment