Skip to content

Instantly share code, notes, and snippets.

@itsadok
Forked from bracki/reindex.py
Last active January 1, 2016 07:09
Show Gist options
  • Save itsadok/8110092 to your computer and use it in GitHub Desktop.
Save itsadok/8110092 to your computer and use it in GitHub Desktop.
Simple reindex for elasticsearch using pyes >= 0.19.1
>>> 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()
@elastic10
Copy link

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" ]

}
}

}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment