fixed some NORELEASE comments in tests
This commit is contained in:
parent
80d236e1a0
commit
669a5893bb
|
@ -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>
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<SimpleQueryStringBuilder> {
|
||||
|
||||
|
@ -327,4 +340,14 @@ public class SimpleQueryStringBuilderTests extends AbstractQueryTestCase<SimpleQ
|
|||
assertThat(query, instanceOf(TermQuery.class));
|
||||
assertThat(query.getBoost(), equalTo(10f));
|
||||
}
|
||||
|
||||
public void testNegativeFlags() throws IOException {
|
||||
String query = "{\"simple_query_string\": {\"query\": \"foo bar\", \"flags\": -1}}";
|
||||
SimpleQueryStringBuilder builder = new SimpleQueryStringBuilder("foo bar");
|
||||
builder.flags(SimpleQueryStringFlag.ALL);
|
||||
assertParsedQuery(query, builder);
|
||||
SimpleQueryStringBuilder otherBuilder = new SimpleQueryStringBuilder("foo bar");
|
||||
otherBuilder.flags(-1);
|
||||
assertThat(builder, equalTo(otherBuilder));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.search.fetch;
|
||||
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.search.fetch.fielddata.FieldDataFieldsParseElement;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.TestSearchContext;
|
||||
import org.junit.Test;
|
||||
|
||||
public class FieldDataFieldsTests extends ESTestCase {
|
||||
|
||||
public void testValidFieldDataFieldString() throws Exception {
|
||||
FieldDataFieldsParseElement parseElement = new FieldDataFieldsParseElement();
|
||||
|
||||
BytesArray data = new BytesArray(new BytesRef("{\"fielddata_fields\": \"foobar\"}"));
|
||||
XContentParser parser = XContentFactory.xContent(data).createParser(data);
|
||||
parser.nextToken();
|
||||
parser.nextToken();
|
||||
parser.nextToken();
|
||||
SearchContext context = new TestSearchContext();
|
||||
parseElement.parse(parser, context);
|
||||
}
|
||||
|
||||
public void testValidFieldDataFieldArray() throws Exception {
|
||||
FieldDataFieldsParseElement parseElement = new FieldDataFieldsParseElement();
|
||||
|
||||
BytesArray data = new BytesArray(new BytesRef("{\"fielddata_fields\": [ \"foo\", \"bar\", \"baz\"]}}"));
|
||||
XContentParser parser = XContentFactory.xContent(data).createParser(data);
|
||||
parser.nextToken();
|
||||
parser.nextToken();
|
||||
parser.nextToken();
|
||||
SearchContext context = new TestSearchContext();
|
||||
parseElement.parse(parser, context);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testInvalidFieldDataField() throws Exception {
|
||||
FieldDataFieldsParseElement parseElement = new FieldDataFieldsParseElement();
|
||||
|
||||
BytesArray data;
|
||||
if (randomBoolean()) {
|
||||
data = new BytesArray(new BytesRef("{\"fielddata_fields\": {}}}"));
|
||||
} else {
|
||||
data = new BytesArray(new BytesRef("{\"fielddata_fields\": 1.0}}"));
|
||||
}
|
||||
XContentParser parser = XContentFactory.xContent(data).createParser(data);
|
||||
parser.nextToken();
|
||||
parser.nextToken();
|
||||
parser.nextToken();
|
||||
SearchContext context = new TestSearchContext();
|
||||
parseElement.parse(parser, context);
|
||||
}
|
||||
}
|
|
@ -792,55 +792,6 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
|
|||
assertThat((double) (sh.getAt(0).getScore()), closeTo((sh.getAt(1).getScore()), 1.e-6d));
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void errorMessageForFaultyFunctionScoreBody() throws Exception {
|
||||
// assertAcked(prepareCreate("test").addMapping(
|
||||
// "type",
|
||||
// jsonBuilder().startObject().startObject("type").startObject("properties").startObject("test").field("type",
|
||||
// "string")
|
||||
// .endObject().startObject("num").field("type",
|
||||
// "double").endObject().endObject().endObject().endObject()));
|
||||
// ensureYellow();
|
||||
// client().index(
|
||||
// indexRequest("test").type("type").source(jsonBuilder().startObject().field("test",
|
||||
// "value").field("num", 1.0).endObject()))
|
||||
// .actionGet();
|
||||
// refresh();
|
||||
//
|
||||
// XContentBuilder query = XContentFactory.jsonBuilder();
|
||||
// // query that contains a single function and a functions[] array
|
||||
// query.startObject().startObject("query").startObject("function_score").field("weight",
|
||||
// "1").startArray("functions").startObject().startObject("script_score").field("script",
|
||||
// "3").endObject().endObject().endArray().endObject().endObject().endObject();
|
||||
// try {
|
||||
// client().search(searchRequest().source(query.bytes())).actionGet();
|
||||
// fail("Search should result in SearchPhaseExecutionException");
|
||||
// } catch (SearchPhaseExecutionException e) {
|
||||
// logger.info(e.shardFailures()[0].reason());
|
||||
// assertThat(e.shardFailures()[0].reason(),
|
||||
// containsString("already found [weight], now encountering [functions]."));
|
||||
// }
|
||||
//
|
||||
// query = XContentFactory.jsonBuilder();
|
||||
// // query that contains a single function (but not boost factor) and a
|
||||
// functions[] array
|
||||
// query.startObject().startObject("query").startObject("function_score").startObject("random_score").field("seed",
|
||||
// 3).endObject().startArray("functions").startObject().startObject("random_score").field("seed",
|
||||
// 3).endObject().endObject().endArray().endObject().endObject().endObject();
|
||||
// try {
|
||||
// client().search(searchRequest().source(query.bytes())).actionGet();
|
||||
// fail("Search should result in SearchPhaseExecutionException");
|
||||
// } catch (SearchPhaseExecutionException e) {
|
||||
// logger.info(e.shardFailures()[0].reason());
|
||||
// assertThat(e.shardFailures()[0].reason(),
|
||||
// containsString("already found [random_score], now encountering [functions]"));
|
||||
// assertThat(e.shardFailures()[0].reason(),
|
||||
// not(containsString("did you mean [boost] instead?")));
|
||||
//
|
||||
// } NORELEASE this needs to be tested in a unit test
|
||||
// (FunctionScoreQueryBuilderTests)
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void testExplainString() throws IOException, ExecutionException, InterruptedException {
|
||||
assertAcked(prepareCreate("test").addMapping(
|
||||
|
|
|
@ -540,22 +540,6 @@ public class GeoFilterIT extends ESIntegTestCase {
|
|||
throw new AssertionError(error.getMessage() + "\n geohash_cell filter:" + builder, error);
|
||||
}
|
||||
}
|
||||
// NORELEASE these should be tested in GeohashCellQueryBuilderTests
|
||||
// logger.info("Testing lat/lon format");
|
||||
// String pointTest1 = "{\"geohash_cell\": {\"pin\": {\"lat\": " + point.lat() + ",\"lon\": " + point.lon() + "},\"precision\": " + precision + ",\"neighbors\": true}}";
|
||||
// SearchResponse results3 = client().prepareSearch("locations").setQuery(QueryBuilders.matchAllQuery()).setPostFilter(pointTest1).execute().actionGet();
|
||||
// assertHitCount(results3, neighbors.size() + 1);
|
||||
//
|
||||
//
|
||||
// logger.info("Testing String format");
|
||||
// String pointTest2 = "{\"geohash_cell\": {\"pin\": \"" + point.lat() + "," + point.lon() + "\",\"precision\": " + precision + ",\"neighbors\": true}}";
|
||||
// SearchResponse results4 = client().prepareSearch("locations").setQuery(QueryBuilders.matchAllQuery()).setPostFilter(pointTest2).execute().actionGet();
|
||||
// assertHitCount(results4, neighbors.size() + 1);
|
||||
//
|
||||
// logger.info("Testing Array format");
|
||||
// String pointTest3 = "{\"geohash_cell\": {\"pin\": [" + point.lon() + "," + point.lat() + "],\"precision\": " + precision + ",\"neighbors\": true}}";
|
||||
// SearchResponse results5 = client().prepareSearch("locations").setQuery(QueryBuilders.matchAllQuery()).setPostFilter(pointTest3).execute().actionGet();
|
||||
// assertHitCount(results5, neighbors.size() + 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -225,45 +225,6 @@ public class GeoShapeIntegrationIT extends ESIntegTestCase {
|
|||
assertThat(before, equalTo(after));
|
||||
}
|
||||
|
||||
// NORELEASE these should be tested in GeoShapeQueryBuilderTests
|
||||
// @Test
|
||||
// public void testParsingMultipleShapes() throws Exception {
|
||||
// String mapping = XContentFactory.jsonBuilder()
|
||||
// .startObject()
|
||||
// .startObject("type1")
|
||||
// .startObject("properties")
|
||||
// .startObject("location1")
|
||||
// .field("type", "geo_shape")
|
||||
// .endObject()
|
||||
// .startObject("location2")
|
||||
// .field("type", "geo_shape")
|
||||
// .endObject()
|
||||
// .endObject()
|
||||
// .endObject()
|
||||
// .endObject()
|
||||
// .string();
|
||||
//
|
||||
// assertAcked(prepareCreate("test").addMapping("type1", mapping));
|
||||
// ensureYellow();
|
||||
//
|
||||
// String p1 = "\"location1\" : {\"type\":\"polygon\", \"coordinates\":[[[-10,-10],[10,-10],[10,10],[-10,10],[-10,-10]]]}";
|
||||
// String p2 = "\"location2\" : {\"type\":\"polygon\", \"coordinates\":[[[-20,-20],[20,-20],[20,20],[-20,20],[-20,-20]]]}";
|
||||
// String o1 = "{" + p1 + ", " + p2 + "}";
|
||||
//
|
||||
// indexRandom(true, client().prepareIndex("test", "type1", "1").setSource(o1));
|
||||
//
|
||||
// String filter = "{\"geo_shape\": {\"location2\": {\"indexed_shape\": {"
|
||||
// + "\"id\": \"1\","
|
||||
// + "\"type\": \"type1\","
|
||||
// + "\"index\": \"test\","
|
||||
// + "\"path\": \"location2\""
|
||||
// + "}}}}";
|
||||
//
|
||||
// SearchResponse result = client().prepareSearch("test").setQuery(QueryBuilders.matchAllQuery()).setPostFilter(filter).execute().actionGet();
|
||||
// assertSearchResponse(result);
|
||||
// assertHitCount(result, 1);
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void testShapeFetchingPath() throws Exception {
|
||||
createIndex("shapes");
|
||||
|
|
|
@ -252,13 +252,6 @@ public class SimpleQueryStringIT extends ESIntegTestCase {
|
|||
assertHitCount(searchResponse, 3l);
|
||||
assertSearchHits(searchResponse, "1", "2", "3");
|
||||
|
||||
|
||||
// NORELEASE This should be tested in SimpleQueryStringQueryBuilderTests
|
||||
// // Sending a negative 'flags' value is the same as SimpleQueryStringFlag.ALL
|
||||
// searchResponse = client().prepareSearch().setQuery("{\"simple_query_string\": {\"query\": \"foo bar\", \"flags\": -1}}").get();
|
||||
// assertHitCount(searchResponse, 3l);
|
||||
// assertSearchHits(searchResponse, "1", "2", "3");
|
||||
|
||||
searchResponse = client().prepareSearch().setQuery(
|
||||
simpleQueryStringQuery("foo | bar")
|
||||
.defaultOperator(Operator.AND)
|
||||
|
|
|
@ -31,8 +31,8 @@ import org.elasticsearch.common.joda.Joda;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.index.mapper.internal.TimestampFieldMapper;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.script.Script;
|
||||
import org.elasticsearch.script.ScriptService.ScriptType;
|
||||
|
@ -80,7 +80,7 @@ public class SearchFieldsTests extends ESIntegTestCase {
|
|||
protected Collection<Class<? extends Plugin>> 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");
|
||||
|
|
Loading…
Reference in New Issue