Created
March 17, 2015 23:47
-
-
Save anonymous/689a6b0cfa302e419bb5 to your computer and use it in GitHub Desktop.
Pasted from IPython
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 | |
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 | |
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