Skip to content

Instantly share code, notes, and snippets.

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