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
# ---------------------------------------------------------------------------------------------------------------- | |
# Elasticsearch-Toronto Meetup: Zero Downtime (part 1 of 3) | |
# ---------------------------------------------------------------------------------------------------------------- | |
# My presentation at the second elasticsearch meetup in Toronto | |
# April 21, 2015 | |
# http://www.meetup.com/ElasticSearch-toronto | |
# http://www.meetup.com/Elasticsearch-Toronto/events/220384588/ | |
# ---------------------------------------------------------------------------------------------------------------- | |
# Demo with elasticsearch 1.5.1 and Marvel/Sense | |
# Installation: http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_installing_elasticsearch.html |
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
# source: https://github.com/elastic/elasticsearch-py/blob/master/elasticsearch/helpers/__init__.py | |
def reindex(client, source_index, target_index, query=None, target_client=None, chunk_size=500, scroll='5m', scan_kwargs={}, bulk_kwargs={}): | |
target_client = client if target_client is None else target_client | |
docs = helpers.scan(client, query=query, index=source_index, scroll=scroll, **scan_kwargs) | |
def _change_doc_index(hits, index): | |
for h in hits: | |
h['_index'] = index | |
# SOME MODIFICATION TO THE DOCUMENT: | |
h['_source']['first_name'] = h['_source']['username'].split()[0] | |
yield h |
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
# ---------------------------------------------------------------------------------------------------------------- | |
# Elasticsearch-Toronto Meetup: The Power of Mapping (part 1 of 3) | |
# ---------------------------------------------------------------------------------------------------------------- | |
# My presentation at the first elasticsearch meetup in Toronto | |
# January 19, 2015 | |
# http://www.meetup.com/ElasticSearch-toronto | |
# http://www.meetup.com/Elasticsearch-Toronto/events/218903340 | |
# ---------------------------------------------------------------------------------------------------------------- | |
# Demo with elasticsearch 1.4.2 and Marvel/Sense | |
# Installation: http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_installing_elasticsearch.html |
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
# reproduced with elasticsearch 1.0.1: | |
# index a document with 2 fields, both with the same value (the index will be implicitly generated) | |
curl -XPOST 'http://localhost:9200/test/test/2' -d '{ | |
"first_name": "Rochelle", | |
"last_name": "Rochelle" | |
}' | |
# multi-field terms facet counts the document twice ('count = 2' for the term 'Rochelle') |