 	log: 'trace'
 	apiVersion: '1.5'
 
-createIndex = (name) ->
+
+# Add ID mapping to index
+# @param [string] name of index
+# @private
+_putIdMapping = (name) ->
+	client.indices.putMapping
+
+
+# Create Elastic Search index with given name.
+# @param [string] name of the index
+# @private
+_createIndex = (name) ->
+	params =
+		'index': name
+		'mappings': {}
+
+
+	if name is 'events'
+		params.mappings.event = '_id': 'path': 'id'
+	else
+		params.mappings.group = '_id': 'path': 'id'
+
 	client.indices.exists
 		'index': name
 	.then(

			if not exists
				client.indices.create
					'index': name
				.then(
					(body) ->
						console.log "Created #{name} index successfully"
					(error) ->
						console.error 'Failed to create event index')
			else
				console.log "Index already exists"
	
		(error) ->
			console.error error)
  

# Make sure elastic search is running
client.ping

###
db is a database module that handles storage and retrieval of events and groups.
It uses ElasticSearch as a database backend and the elasticsearch JavaScript
client.

@author Snorre Davøen
###
