in supporting-blog-content/spotify-to-elasticsearch/python/services.py [0:0]
def check_index(self):
if self.client.indices.exists(index=self.index).body is False:
self.client.indices.create(
index=self.index,
settings={"final_pipeline": "spotify"},
mappings={
"dynamic": "true",
"dynamic_date_formats": [
"strict_date_optional_time",
"yyyy/MM/dd HH:mm:ss Z||yyyy/MM/dd Z",
],
"dynamic_templates": [
{
"stringsaskeywords": {
"match": "*",
"match_mapping_type": "string",
"mapping": {"type": "keyword"},
}
}
],
"date_detection": True,
"numeric_detection": False,
"properties": {
"@timestamp": {
"type": "date",
"format": "strict_date_optional_time",
},
"album": {"type": "keyword"},
"artist": {"type": "keyword"},
"dayOfWeek": {"type": "keyword"},
"duration": {"type": "long"},
"explicit": {"type": "boolean"},
"geoip": {
"properties": {
"city_name": {"type": "keyword"},
"continent_name": {"type": "keyword"},
"country_iso_code": {"type": "keyword"},
"country_name": {"type": "keyword"},
"location": {"type": "geo_point"},
"region_iso_code": {"type": "keyword"},
"region_name": {"type": "keyword"},
}
},
"hourOfDay": {"type": "long"},
"ip": {"type": "ip"},
"not_found": {"type": "boolean"},
"offline": {"type": "boolean"},
"platform": {"type": "keyword"},
"played_at": {
"type": "date",
"format": "strict_date_optional_time",
},
"reason_end": {"type": "keyword"},
"reason_start": {"type": "keyword"},
"skipped": {"type": "boolean"},
"title": {"type": "keyword"},
"url": {"type": "keyword"},
"user": {"type": "keyword"},
},
},
)