diff --git a/core/src/test/java/org/elasticsearch/index/query/GeohashCellQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/GeohashCellQueryBuilderTests.java index 0db757f4a5f..022c2e11253 100644 --- a/core/src/test/java/org/elasticsearch/index/query/GeohashCellQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/GeohashCellQueryBuilderTests.java @@ -19,6 +19,8 @@ package org.elasticsearch.index.query; +import com.spatial4j.core.shape.Point; + import org.apache.lucene.index.Term; import org.apache.lucene.queries.TermsQuery; import org.apache.lucene.search.Query; @@ -27,6 +29,7 @@ import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.unit.DistanceUnit; import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper; import org.elasticsearch.index.query.GeohashCellQuery.Builder; +import org.elasticsearch.test.geo.RandomShapeGenerator; import org.junit.Test; import java.io.IOException; @@ -105,4 +108,15 @@ public class GeohashCellQueryBuilderTests extends AbstractQueryTestCase builder.precision(-1); } + @Test + public void testLocationParsing() throws IOException { + Point point = RandomShapeGenerator.xRandomPoint(getRandom()); + Builder pointTestBuilder = new GeohashCellQuery.Builder("pin", new GeoPoint(point.getY(), point.getX())); + String pointTest1 = "{\"geohash_cell\": {\"pin\": {\"lat\": " + point.getY() + ",\"lon\": " + point.getX() + "}}}"; + assertParsedQuery(pointTest1, pointTestBuilder); + String pointTest2 = "{\"geohash_cell\": {\"pin\": \"" + point.getY() + "," + point.getX() + "\"}}"; + assertParsedQuery(pointTest2, pointTestBuilder); + String pointTest3 = "{\"geohash_cell\": {\"pin\": [" + point.getX() + "," + point.getY() + "]}}"; + assertParsedQuery(pointTest3, pointTestBuilder); + } } diff --git a/core/src/test/java/org/elasticsearch/index/query/SimpleQueryStringBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/SimpleQueryStringBuilderTests.java index 5ae54d4078a..2ca94419862 100644 --- a/core/src/test/java/org/elasticsearch/index/query/SimpleQueryStringBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/SimpleQueryStringBuilderTests.java @@ -20,7 +20,11 @@ package org.elasticsearch.index.query; import org.apache.lucene.index.Term; -import org.apache.lucene.search.*; +import org.apache.lucene.search.BooleanClause; +import org.apache.lucene.search.BooleanQuery; +import org.apache.lucene.search.MatchNoDocsQuery; +import org.apache.lucene.search.Query; +import org.apache.lucene.search.TermQuery; import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.common.xcontent.XContentFactory; @@ -28,9 +32,18 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.junit.Test; import java.io.IOException; -import java.util.*; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Locale; +import java.util.Map; +import java.util.Set; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; public class SimpleQueryStringBuilderTests extends AbstractQueryTestCase { @@ -327,4 +340,14 @@ public class SimpleQueryStringBuilderTests extends AbstractQueryTestCase> nodePlugins() { return Collections.singleton(GroovyPlugin.class); } - + @Test public void testStoredFields() throws Exception { createIndex("test"); @@ -536,16 +536,6 @@ public class SearchFieldsTests extends ESIntegTestCase { assertThat((String)fields.get("test_field").value(), equalTo("foobar")); } -// @Test(expected = SearchPhaseExecutionException.class) -// public void testInvalidFieldDataField() throws ExecutionException, InterruptedException { -// createIndex("test"); -// if (randomBoolean()) { -// client().prepareSearch("test").setTypes("type").setSource(new BytesArray(new BytesRef("{\"query\":{\"match_all\":{}},\"fielddata_fields\": {}}"))).get(); -// } else { -// client().prepareSearch("test").setTypes("type").setSource(new BytesArray(new BytesRef("{\"query\":{\"match_all\":{}},\"fielddata_fields\": 1.0}"))).get(); -// } -// } NORELEASE need a unit test for this - @Test public void testFieldsPulledFromFieldData() throws Exception { createIndex("test");