Created
January 30, 2012 21:34
-
-
Save bracki/1706856 to your computer and use it in GitHub Desktop.
Simple reindex for elasticsearch using pyes
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
>>> import pyes | |
>>> conn = pyes.es.ES("localhost:9200") | |
>>> all = conn.scan(pyes.query.MatchAllQuery(), 'index', 'type') | |
>>> for a in all: | |
... hits = a['hits']['hits'] | |
... for hit in hits: | |
... conn.index(hit['_source'], 'new_index', 'type', hit['_id'], bulk=True) |
Why I have this error:
AttributeError: 'ES' object has no attribute 'scan'
new version:
import pyes
conn = pyes.es.ES("localhost:9200")
all = conn.search(pyes.query.MatchAllQuery(), 'index', 'type', scan=True)
for a in all:
conn.index(a, 'new_index', 'type', a.get_id(), bulk=True)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome, thanks, just what I was looking for.