diff --git a/pom.xml b/pom.xml
index 3d4ba4f76918..f9494e2cf29f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -98,6 +98,7 @@
presto-docs
presto-verifier
presto-testing-server-launcher
+ presto-elasticsearch
@@ -133,6 +134,13 @@
zip
+
+ com.facebook.presto
+ presto-elasticsearch
+ ${project.version}
+ zip
+
+
com.facebook.presto
presto-example-http
diff --git a/presto-elasticsearch/pom.xml b/presto-elasticsearch/pom.xml
index 6375bb7e76aa..fc1d20a6ff18 100644
--- a/presto-elasticsearch/pom.xml
+++ b/presto-elasticsearch/pom.xml
@@ -1,123 +1,188 @@
-
- 4.0.0
-
- com.facebook.presto
- presto-root
- 0.108-SNAPSHOT
-
- com.facebook.presto.elasticsearch
- presto-elasticsearch
- 1.0-SNAPSHOT
- presto-elasticsearch
- http://maven.apache.org
-
-
- junit
- junit
- 3.8.1
- test
-
-
-
- org.elasticsearch
- elasticsearch
- 1.6.0
-
-
-
+
+ 4.0.0
+
com.facebook.presto
- presto-spi
- provided
-
-
-
- io.airlift
- bootstrap
- provided
-
-
-
- io.airlift
- json
- provided
-
-
-
- io.airlift
- log
- provided
-
-
-
- com.fasterxml.jackson.core
- jackson-annotations
- provided
-
-
-
- com.fasterxml.jackson.core
- jackson-core
- provided
-
-
-
- com.fasterxml.jackson.core
- jackson-databind
- provided
-
-
-
- io.airlift
- units
- provided
-
-
-
- io.airlift
- configuration
- provided
-
-
-
- io.airlift
- slice
- provided
-
-
-
- com.google.guava
- guava
- provided
-
-
-
- javax.inject
- javax.inject
- provided
-
-
-
- com.google.inject
- guice
- provided
-
-
-
- javax.validation
- validation-api
- provided
-
-
-
- org.json
- json
- 20080701
-
-
-
-
-
-
+ presto-root
+ 0.131-SNAPSHOT
+
+ presto-elasticsearch
+ Presto - Elasticsearch Connector
+ presto-plugin
+
+
+ ${project.parent.basedir}
+
+
+
+
+
+ org.elasticsearch
+ elasticsearch
+ 1.6.0
+
+
+ org.yaml
+ snakeyaml
+
+
+ org.ow2.asm
+ asm-all
+
+
+ org.ow2.asm
+ asm-commons
+
+
+ org.ow2.asm
+ asm
+
+
+
+
+
+ org.json
+ json
+ 20080701
+
+
+
+ com.facebook.presto
+ presto-spi
+ provided
+
+
+
+ io.airlift
+ bootstrap
+ provided
+
+
+
+ io.airlift
+ json
+ provided
+
+
+
+ io.airlift
+ log
+ provided
+
+
+
+ com.fasterxml.jackson.core
+ jackson-annotations
+ provided
+
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+ provided
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ provided
+
+
+
+ io.airlift
+ units
+ provided
+
+
+
+ io.airlift
+ configuration
+ provided
+
+
+
+ io.airlift
+ slice
+ provided
+
+
+
+ com.google.guava
+ guava
+ provided
+
+
+
+ javax.inject
+ javax.inject
+ provided
+
+
+
+ com.google.inject
+ guice
+ provided
+
+
+
+ javax.validation
+ validation-api
+ provided
+
+
+
+
+ com.facebook.presto
+ presto-main
+ test
+
+
+
+ org.testng
+ testng
+ test
+
+
+
+ io.airlift
+ testing
+ test
+
+
+
+ io.airlift
+ http-server
+ test
+
+
+
+ io.airlift
+ node
+ test
+
+
+
+ javax.servlet
+ javax.servlet-api
+ test
+
+
+
+
+
+
+
+
+ com.mycila
+ license-maven-plugin
+
+
+ **/*.java
+
+
+
+
+
+
+
diff --git a/presto-elasticsearch/src/main/java/com/facebook/presto/elasticsearch/ElasticsearchClient.java b/presto-elasticsearch/src/main/java/com/facebook/presto/elasticsearch/ElasticsearchClient.java
index d39a27be964e..dacdb7fafbdb 100644
--- a/presto-elasticsearch/src/main/java/com/facebook/presto/elasticsearch/ElasticsearchClient.java
+++ b/presto-elasticsearch/src/main/java/com/facebook/presto/elasticsearch/ElasticsearchClient.java
@@ -2,37 +2,40 @@
package com.facebook.presto.elasticsearch;
import com.facebook.presto.spi.type.Type;
-import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.base.Throwables;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.io.Resources;
import io.airlift.json.JsonCodec;
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest;
-import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.cluster.metadata.MappingMetaData;
import org.elasticsearch.common.collect.ImmutableOpenMap;
-import org.elasticsearch.common.hppc.cursors.ObjectObjectCursor;
+import org.elasticsearch.common.hppc.cursors.ObjectCursor;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
+import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import javax.inject.Inject;
import java.io.IOException;
-import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ExecutionException;
+import java.util.stream.Collectors;
import static com.facebook.presto.spi.type.BigintType.BIGINT;
import static com.facebook.presto.spi.type.DoubleType.DOUBLE;
@@ -41,10 +44,8 @@
import static com.google.common.collect.Iterables.transform;
import static com.google.common.collect.Maps.transformValues;
import static com.google.common.collect.Maps.uniqueIndex;
-import static io.airlift.json.JsonCodec.listJsonCodec;
import static java.nio.charset.StandardCharsets.UTF_8;
-
-
+import static java.util.Locale.ENGLISH;
public class ElasticsearchClient
{
@@ -68,58 +69,63 @@ public ElasticsearchClient(ElasticsearchConfig config, JsonCodec