-
-
Save itsadok/8110092 to your computer and use it in GitHub Desktop.
Simple reindex for elasticsearch using pyes >= 0.19.1
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") | |
>>> search = pyes.query.MatchAllQuery().search(bulk_read=1000) | |
>>> hits = conn.search(search, 'index', 'type', scan=True, scroll="30m", model=lambda _,hit: hit) | |
>>> for hit in hits | |
... conn.index(hit['_source'], 'new_index', 'type', hit['_id'], bulk=True) | |
... | |
>>> conn.flush() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
just begun elasticsearch, how i can send this request by python code please:
curl -XPOST 'http://localhost:9200/test/test/_search_with_clusters?pretty=true' -d '
{
"search_request": {
"fields" : [
"language",
"title",
"content"
],
"query" : {
"match" : {
"_all" : "words"
}
},
"size": 100
},
"query_hint" : "words",
"field_mapping" : {
"title" : [ "fields.title"],
"content" : [ "fields.text" ]
}
}
}'