Update to Jackson 2.8.1
This commit updates Jackson to the 2.8.1 version, which is more strict when it comes to build objects. It also adds the snakeyaml dependency that was previously shaded in jackson libs. It also closes #18076
This commit is contained in:
parent
a01475a20b
commit
841d5a210e
|
@ -676,7 +676,6 @@
|
|||
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]ingest[/\\]SimulatePipelineRequestParsingTests.java" checks="LineLength" />
|
||||
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]ingest[/\\]SimulatePipelineResponseTests.java" checks="LineLength" />
|
||||
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]ingest[/\\]WriteableIngestDocumentTests.java" checks="LineLength" />
|
||||
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]search[/\\]MultiSearchRequestTests.java" checks="LineLength" />
|
||||
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]search[/\\]SearchRequestBuilderTests.java" checks="LineLength" />
|
||||
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]support[/\\]AutoCreateIndexTests.java" checks="LineLength" />
|
||||
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]support[/\\]IndicesOptionsTests.java" checks="LineLength" />
|
||||
|
@ -1009,7 +1008,6 @@
|
|||
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]bucket[/\\]ShardReduceIT.java" checks="LineLength" />
|
||||
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]bucket[/\\]ShardSizeTestCase.java" checks="LineLength" />
|
||||
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]bucket[/\\]SignificantTermsIT.java" checks="LineLength" />
|
||||
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]bucket[/\\]SignificantTermsSignificanceScoreIT.java" checks="LineLength" />
|
||||
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]bucket[/\\]TermsDocCountErrorIT.java" checks="LineLength" />
|
||||
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]bucket[/\\]TermsShardMinDocCountIT.java" checks="LineLength" />
|
||||
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]bucket[/\\]nested[/\\]NestedAggregatorTests.java" checks="LineLength" />
|
||||
|
|
|
@ -4,7 +4,8 @@ lucene = 6.1.0
|
|||
# optional dependencies
|
||||
spatial4j = 0.6
|
||||
jts = 1.13
|
||||
jackson = 2.7.1
|
||||
jackson = 2.8.1
|
||||
snakeyaml = 1.15
|
||||
log4j = 1.2.17
|
||||
slf4j = 1.6.2
|
||||
jna = 4.2.2
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
4127b62db028f981e81caa248953c0899d720f98
|
|
@ -0,0 +1 @@
|
|||
fd13b1c033741d48291315c6370f7d475a42dccf
|
|
@ -69,6 +69,7 @@ dependencies {
|
|||
compile 'org.joda:joda-convert:1.2'
|
||||
|
||||
// json and yaml
|
||||
compile "org.yaml:snakeyaml:${versions.snakeyaml}"
|
||||
compile "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
|
||||
compile "com.fasterxml.jackson.dataformat:jackson-dataformat-smile:${versions.jackson}"
|
||||
compile "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${versions.jackson}"
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.fasterxml.jackson.core.JsonStreamContext;
|
|||
import com.fasterxml.jackson.core.base.GeneratorBase;
|
||||
import com.fasterxml.jackson.core.filter.FilteringGeneratorDelegate;
|
||||
import com.fasterxml.jackson.core.io.SerializedString;
|
||||
import com.fasterxml.jackson.core.json.JsonWriteContext;
|
||||
import com.fasterxml.jackson.core.util.DefaultIndenter;
|
||||
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
|
@ -271,7 +272,9 @@ public class JsonXContentGenerator implements XContentGenerator {
|
|||
public void writeEndRaw() {
|
||||
assert base != null : "JsonGenerator should be of instance GeneratorBase but was: " + generator.getClass();
|
||||
if (base != null) {
|
||||
base.getOutputContext().writeValue();
|
||||
JsonStreamContext context = base.getOutputContext();
|
||||
assert (context instanceof JsonWriteContext) : "Expected an instance of JsonWriteContext but was: " + context.getClass();
|
||||
((JsonWriteContext) context).writeValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,11 +87,6 @@ public class JsonXContentParser extends AbstractXContentParser {
|
|||
|
||||
@Override
|
||||
public BytesRef utf8Bytes() throws IOException {
|
||||
// Tentative workaround for https://github.com/elastic/elasticsearch/issues/8629
|
||||
// TODO: Remove this when we upgrade jackson to 2.6.x.
|
||||
if (parser.getTextLength() == 0) {
|
||||
return new BytesRef();
|
||||
}
|
||||
return new BytesRef(CharBuffer.wrap(parser.getTextCharacters(), parser.getTextOffset(), parser.getTextLength()));
|
||||
}
|
||||
|
||||
|
|
|
@ -44,19 +44,33 @@ import static org.hamcrest.Matchers.nullValue;
|
|||
public class MultiSearchRequestTests extends ESTestCase {
|
||||
public void testSimpleAdd() throws Exception {
|
||||
MultiSearchRequest request = parseMultiSearchRequest("/org/elasticsearch/action/search/simple-msearch1.json");
|
||||
assertThat(request.requests().size(), equalTo(8));
|
||||
assertThat(request.requests().get(0).indices()[0], equalTo("test"));
|
||||
assertThat(request.requests().get(0).indicesOptions(), equalTo(IndicesOptions.fromOptions(true, true, true, true, IndicesOptions.strictExpandOpenAndForbidClosed())));
|
||||
assertThat(request.requests().get(0).types().length, equalTo(0));
|
||||
assertThat(request.requests().get(1).indices()[0], equalTo("test"));
|
||||
assertThat(request.requests().get(1).indicesOptions(), equalTo(IndicesOptions.fromOptions(false, true, true, true, IndicesOptions.strictExpandOpenAndForbidClosed())));
|
||||
assertThat(request.requests().get(1).types()[0], equalTo("type1"));
|
||||
assertThat(request.requests().get(2).indices()[0], equalTo("test"));
|
||||
assertThat(request.requests().get(2).indicesOptions(), equalTo(IndicesOptions.fromOptions(false, true, true, false, IndicesOptions.strictExpandOpenAndForbidClosed())));
|
||||
assertThat(request.requests().get(3).indices()[0], equalTo("test"));
|
||||
assertThat(request.requests().get(3).indicesOptions(), equalTo(IndicesOptions.fromOptions(true, true, true, true, IndicesOptions.strictExpandOpenAndForbidClosed())));
|
||||
assertThat(request.requests().get(4).indices()[0], equalTo("test"));
|
||||
assertThat(request.requests().get(4).indicesOptions(), equalTo(IndicesOptions.fromOptions(true, false, false, true, IndicesOptions.strictExpandOpenAndForbidClosed())));
|
||||
assertThat(request.requests().size(),
|
||||
equalTo(8));
|
||||
assertThat(request.requests().get(0).indices()[0],
|
||||
equalTo("test"));
|
||||
assertThat(request.requests().get(0).indicesOptions(),
|
||||
equalTo(IndicesOptions.fromOptions(true, true, true, true, IndicesOptions.strictExpandOpenAndForbidClosed())));
|
||||
assertThat(request.requests().get(0).types().length,
|
||||
equalTo(0));
|
||||
assertThat(request.requests().get(1).indices()[0],
|
||||
equalTo("test"));
|
||||
assertThat(request.requests().get(1).indicesOptions(),
|
||||
equalTo(IndicesOptions.fromOptions(false, true, true, true, IndicesOptions.strictExpandOpenAndForbidClosed())));
|
||||
assertThat(request.requests().get(1).types()[0],
|
||||
equalTo("type1"));
|
||||
assertThat(request.requests().get(2).indices()[0],
|
||||
equalTo("test"));
|
||||
assertThat(request.requests().get(2).indicesOptions(),
|
||||
equalTo(IndicesOptions.fromOptions(false, true, true, false, IndicesOptions.strictExpandOpenAndForbidClosed())));
|
||||
assertThat(request.requests().get(3).indices()[0],
|
||||
equalTo("test"));
|
||||
assertThat(request.requests().get(3).indicesOptions(),
|
||||
equalTo(IndicesOptions.fromOptions(true, true, true, true, IndicesOptions.strictExpandOpenAndForbidClosed())));
|
||||
assertThat(request.requests().get(4).indices()[0],
|
||||
equalTo("test"));
|
||||
assertThat(request.requests().get(4).indicesOptions(),
|
||||
equalTo(IndicesOptions.fromOptions(true, false, false, true, IndicesOptions.strictExpandOpenAndForbidClosed())));
|
||||
|
||||
assertThat(request.requests().get(5).indices(), is(Strings.EMPTY_ARRAY));
|
||||
assertThat(request.requests().get(5).types().length, equalTo(0));
|
||||
assertThat(request.requests().get(6).indices(), is(Strings.EMPTY_ARRAY));
|
||||
|
@ -119,10 +133,27 @@ public class MultiSearchRequestTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testResponseErrorToXContent() throws IOException {
|
||||
MultiSearchResponse response = new MultiSearchResponse(new MultiSearchResponse.Item[]{new MultiSearchResponse.Item(null, new IllegalStateException("foobar")), new MultiSearchResponse.Item(null, new IllegalStateException("baaaaaazzzz"))});
|
||||
MultiSearchResponse response = new MultiSearchResponse(
|
||||
new MultiSearchResponse.Item[]{
|
||||
new MultiSearchResponse.Item(null, new IllegalStateException("foobar")),
|
||||
new MultiSearchResponse.Item(null, new IllegalStateException("baaaaaazzzz"))
|
||||
});
|
||||
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
builder.startObject();
|
||||
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
assertEquals("\"responses\"[{\"error\":{\"root_cause\":[{\"type\":\"illegal_state_exception\",\"reason\":\"foobar\"}],\"type\":\"illegal_state_exception\",\"reason\":\"foobar\"},\"status\":500},{\"error\":{\"root_cause\":[{\"type\":\"illegal_state_exception\",\"reason\":\"baaaaaazzzz\"}],\"type\":\"illegal_state_exception\",\"reason\":\"baaaaaazzzz\"},\"status\":500}]",
|
||||
builder.endObject();
|
||||
|
||||
assertEquals("{\"responses\":["
|
||||
+ "{"
|
||||
+ "\"error\":{\"root_cause\":[{\"type\":\"illegal_state_exception\",\"reason\":\"foobar\"}],"
|
||||
+ "\"type\":\"illegal_state_exception\",\"reason\":\"foobar\"},\"status\":500"
|
||||
+ "},"
|
||||
+ "{"
|
||||
+ "\"error\":{\"root_cause\":[{\"type\":\"illegal_state_exception\",\"reason\":\"baaaaaazzzz\"}],"
|
||||
+ "\"type\":\"illegal_state_exception\",\"reason\":\"baaaaaazzzz\"},\"status\":500"
|
||||
+ "}"
|
||||
+ "]}",
|
||||
builder.string());
|
||||
}
|
||||
|
||||
|
|
|
@ -356,6 +356,7 @@ public class XContentBuilderTests extends ESTestCase {
|
|||
public void testWriteFieldMapWithNullKeys() throws IOException {
|
||||
XContentBuilder builder = XContentFactory.contentBuilder(randomFrom(XContentType.values()));
|
||||
try {
|
||||
builder.startObject();
|
||||
builder.field("map", Collections.singletonMap(null, "test"));
|
||||
fail("write map should have failed");
|
||||
} catch(IllegalArgumentException e) {
|
||||
|
|
|
@ -319,9 +319,12 @@ public class TextFieldMapperTests extends ESSingleNodeTestCase {
|
|||
.endObject()
|
||||
.endObject().endObject().endObject().string();
|
||||
mapper = parser.parse("type", new CompressedXContent(mapping));
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
builder.startObject();
|
||||
mapper.toXContent(builder, new ToXContent.MapParams(Collections.singletonMap("include_defaults", "true")));
|
||||
builder.endObject();
|
||||
|
||||
String mappingString = builder.string();
|
||||
assertTrue(mappingString.contains("analyzer"));
|
||||
assertTrue(mappingString.contains("search_analyzer"));
|
||||
|
|
|
@ -337,9 +337,12 @@ public class SimpleStringMappingTests extends ESSingleNodeTestCase {
|
|||
.endObject()
|
||||
.endObject().endObject().endObject().string();
|
||||
mapper = parser.parse("type", new CompressedXContent(mapping));
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
builder.startObject();
|
||||
mapper.toXContent(builder, new ToXContent.MapParams(Collections.singletonMap("include_defaults", "true")));
|
||||
builder.endObject();
|
||||
|
||||
String mappingString = builder.string();
|
||||
assertTrue(mappingString.contains("analyzer"));
|
||||
assertTrue(mappingString.contains("search_analyzer"));
|
||||
|
|
|
@ -42,6 +42,9 @@ import org.elasticsearch.common.unit.ByteSizeValue;
|
|||
import org.elasticsearch.common.util.BigArrays;
|
||||
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
|
||||
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.index.VersionType;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.index.translog.Translog.Location;
|
||||
|
@ -351,10 +354,14 @@ public class TranslogTests extends ESTestCase {
|
|||
|
||||
assertEquals(6, copy.estimatedNumberOfOperations());
|
||||
assertEquals(431, copy.getTranslogSizeInBytes());
|
||||
assertEquals("\"translog\"{\n" +
|
||||
" \"operations\" : 6,\n" +
|
||||
" \"size_in_bytes\" : 431\n" +
|
||||
"}", copy.toString().trim());
|
||||
|
||||
try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
|
||||
builder.startObject();
|
||||
copy.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
builder.endObject();
|
||||
|
||||
assertEquals("{\"translog\":{\"operations\":6,\"size_in_bytes\":431}}", builder.string());
|
||||
}
|
||||
|
||||
try {
|
||||
new TranslogStats(1, -1);
|
||||
|
|
|
@ -109,9 +109,14 @@ public class NodeInfoStreamingTests extends ESTestCase {
|
|||
private void compareJsonOutput(ToXContent param1, ToXContent param2) throws IOException {
|
||||
ToXContent.Params params = ToXContent.EMPTY_PARAMS;
|
||||
XContentBuilder param1Builder = jsonBuilder();
|
||||
XContentBuilder param2Builder = jsonBuilder();
|
||||
param1Builder.startObject();
|
||||
param1.toXContent(param1Builder, params);
|
||||
param1Builder.endObject();
|
||||
|
||||
XContentBuilder param2Builder = jsonBuilder();
|
||||
param2Builder.startObject();
|
||||
param2.toXContent(param2Builder, params);
|
||||
param2Builder.endObject();
|
||||
assertThat(param1Builder.string(), equalTo(param2Builder.string()));
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.elasticsearch.script.NativeScriptFactory;
|
|||
import org.elasticsearch.script.Script;
|
||||
import org.elasticsearch.script.ScriptService.ScriptType;
|
||||
import org.elasticsearch.search.aggregations.Aggregation;
|
||||
import org.elasticsearch.search.aggregations.Aggregations;
|
||||
import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter;
|
||||
import org.elasticsearch.search.aggregations.bucket.script.NativeSignificanceScoreScriptNoParams;
|
||||
import org.elasticsearch.search.aggregations.bucket.script.NativeSignificanceScoreScriptWithParams;
|
||||
|
@ -116,7 +117,7 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
|
|||
.execute()
|
||||
.actionGet();
|
||||
assertSearchResponse(response);
|
||||
StringTerms classes = (StringTerms) response.getAggregations().get("class");
|
||||
StringTerms classes = response.getAggregations().get("class");
|
||||
assertThat(classes.getBuckets().size(), equalTo(2));
|
||||
for (Terms.Bucket classBucket : classes.getBuckets()) {
|
||||
Map<String, Aggregation> aggs = classBucket.getAggregations().asMap();
|
||||
|
@ -246,7 +247,7 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
|
|||
}
|
||||
|
||||
public void testXContentResponse() throws Exception {
|
||||
String type = false || randomBoolean() ? "text" : "long";
|
||||
String type = randomBoolean() ? "text" : "long";
|
||||
String settings = "{\"index.number_of_shards\": 1, \"index.number_of_replicas\": 0}";
|
||||
SharedSignificantTermsTestMethods.index01Docs(type, settings, this);
|
||||
SearchResponse response = client().prepareSearch(INDEX_NAME).setTypes(DOC_TYPE)
|
||||
|
@ -254,7 +255,7 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
|
|||
.execute()
|
||||
.actionGet();
|
||||
assertSearchResponse(response);
|
||||
StringTerms classes = (StringTerms) response.getAggregations().get("class");
|
||||
StringTerms classes = response.getAggregations().get("class");
|
||||
assertThat(classes.getBuckets().size(), equalTo(2));
|
||||
for (Terms.Bucket classBucket : classes.getBuckets()) {
|
||||
Map<String, Aggregation> aggs = classBucket.getAggregations().asMap();
|
||||
|
@ -267,13 +268,39 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
|
|||
}
|
||||
|
||||
XContentBuilder responseBuilder = XContentFactory.jsonBuilder();
|
||||
responseBuilder.startObject();
|
||||
classes.toXContent(responseBuilder, null);
|
||||
String result = null;
|
||||
if (type.equals("long")) {
|
||||
result = "\"class\"{\"doc_count_error_upper_bound\":0,\"sum_other_doc_count\":0,\"buckets\":[{\"key\":\"0\",\"doc_count\":4,\"sig_terms\":{\"doc_count\":4,\"buckets\":[{\"key\":0,\"doc_count\":4,\"score\":0.39999999999999997,\"bg_count\":5}]}},{\"key\":\"1\",\"doc_count\":3,\"sig_terms\":{\"doc_count\":3,\"buckets\":[{\"key\":1,\"doc_count\":3,\"score\":0.75,\"bg_count\":4}]}}]}";
|
||||
} else {
|
||||
result = "\"class\"{\"doc_count_error_upper_bound\":0,\"sum_other_doc_count\":0,\"buckets\":[{\"key\":\"0\",\"doc_count\":4,\"sig_terms\":{\"doc_count\":4,\"buckets\":[{\"key\":\"0\",\"doc_count\":4,\"score\":0.39999999999999997,\"bg_count\":5}]}},{\"key\":\"1\",\"doc_count\":3,\"sig_terms\":{\"doc_count\":3,\"buckets\":[{\"key\":\"1\",\"doc_count\":3,\"score\":0.75,\"bg_count\":4}]}}]}";
|
||||
}
|
||||
responseBuilder.endObject();
|
||||
|
||||
String result = "{\"class\":{\"doc_count_error_upper_bound\":0,\"sum_other_doc_count\":0,"
|
||||
+ "\"buckets\":["
|
||||
+ "{"
|
||||
+ "\"key\":\"0\","
|
||||
+ "\"doc_count\":4,"
|
||||
+ "\"sig_terms\":{"
|
||||
+ "\"doc_count\":4,"
|
||||
+ "\"buckets\":["
|
||||
+ "{"
|
||||
+ "\"key\":" + (type.equals("long") ? "0," : "\"0\",")
|
||||
+ "\"doc_count\":4,"
|
||||
+ "\"score\":0.39999999999999997,"
|
||||
+ "\"bg_count\":5"
|
||||
+ "}"
|
||||
+ "]"
|
||||
+ "}"
|
||||
+ "},"
|
||||
+ "{"
|
||||
+ "\"key\":\"1\","
|
||||
+ "\"doc_count\":3,"
|
||||
+ "\"sig_terms\":{"
|
||||
+ "\"doc_count\":3,"
|
||||
+ "\"buckets\":["
|
||||
+ "{"
|
||||
+ "\"key\":" + (type.equals("long") ? "1," : "\"1\",")
|
||||
+ "\"doc_count\":3,"
|
||||
+ "\"score\":0.75,"
|
||||
+ "\"bg_count\":4"
|
||||
+ "}]}}]}}";
|
||||
assertThat(responseBuilder.string(), equalTo(result));
|
||||
|
||||
}
|
||||
|
@ -309,7 +336,7 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
|
|||
}
|
||||
indexRandom(true, false, indexRequestBuilderList);
|
||||
|
||||
SearchResponse response1 = client().prepareSearch(INDEX_NAME).setTypes(DOC_TYPE)
|
||||
client().prepareSearch(INDEX_NAME).setTypes(DOC_TYPE)
|
||||
.addAggregation(
|
||||
terms("class")
|
||||
.field(CLASS_FIELD)
|
||||
|
@ -334,7 +361,8 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
|
|||
// 1. terms agg on class and significant terms
|
||||
// 2. filter buckets and set the background to the other class and set is_background false
|
||||
// both should yield exact same result
|
||||
public void testBackgroundVsSeparateSet(SignificanceHeuristic significanceHeuristicExpectingSuperset, SignificanceHeuristic significanceHeuristicExpectingSeparateSets) throws Exception {
|
||||
public void testBackgroundVsSeparateSet(SignificanceHeuristic significanceHeuristicExpectingSuperset,
|
||||
SignificanceHeuristic significanceHeuristicExpectingSeparateSets) throws Exception {
|
||||
|
||||
SearchResponse response1 = client().prepareSearch(INDEX_NAME).setTypes(DOC_TYPE)
|
||||
.addAggregation(terms("class")
|
||||
|
@ -364,18 +392,25 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
|
|||
.execute()
|
||||
.actionGet();
|
||||
|
||||
SignificantTerms sigTerms0 = ((SignificantTerms) (((StringTerms) response1.getAggregations().get("class")).getBucketByKey("0").getAggregations().asMap().get("sig_terms")));
|
||||
StringTerms classes = response1.getAggregations().get("class");
|
||||
|
||||
SignificantTerms sigTerms0 = ((SignificantTerms) (classes.getBucketByKey("0").getAggregations().asMap().get("sig_terms")));
|
||||
assertThat(sigTerms0.getBuckets().size(), equalTo(2));
|
||||
double score00Background = sigTerms0.getBucketByKey("0").getSignificanceScore();
|
||||
double score01Background = sigTerms0.getBucketByKey("1").getSignificanceScore();
|
||||
SignificantTerms sigTerms1 = ((SignificantTerms) (((StringTerms) response1.getAggregations().get("class")).getBucketByKey("1").getAggregations().asMap().get("sig_terms")));
|
||||
SignificantTerms sigTerms1 = ((SignificantTerms) (classes.getBucketByKey("1").getAggregations().asMap().get("sig_terms")));
|
||||
double score10Background = sigTerms1.getBucketByKey("0").getSignificanceScore();
|
||||
double score11Background = sigTerms1.getBucketByKey("1").getSignificanceScore();
|
||||
|
||||
double score00SeparateSets = ((SignificantTerms) ((InternalFilter) response2.getAggregations().get("0")).getAggregations().getAsMap().get("sig_terms")).getBucketByKey("0").getSignificanceScore();
|
||||
double score01SeparateSets = ((SignificantTerms) ((InternalFilter) response2.getAggregations().get("0")).getAggregations().getAsMap().get("sig_terms")).getBucketByKey("1").getSignificanceScore();
|
||||
double score10SeparateSets = ((SignificantTerms) ((InternalFilter) response2.getAggregations().get("1")).getAggregations().getAsMap().get("sig_terms")).getBucketByKey("0").getSignificanceScore();
|
||||
double score11SeparateSets = ((SignificantTerms) ((InternalFilter) response2.getAggregations().get("1")).getAggregations().getAsMap().get("sig_terms")).getBucketByKey("1").getSignificanceScore();
|
||||
Aggregations aggs = response2.getAggregations();
|
||||
|
||||
sigTerms0 = (SignificantTerms) ((InternalFilter) aggs.get("0")).getAggregations().getAsMap().get("sig_terms");
|
||||
double score00SeparateSets = sigTerms0.getBucketByKey("0").getSignificanceScore();
|
||||
double score01SeparateSets = sigTerms0.getBucketByKey("1").getSignificanceScore();
|
||||
|
||||
sigTerms1 = (SignificantTerms) ((InternalFilter) aggs.get("1")).getAggregations().getAsMap().get("sig_terms");
|
||||
double score10SeparateSets = sigTerms1.getBucketByKey("0").getSignificanceScore();
|
||||
double score11SeparateSets = sigTerms1.getBucketByKey("1").getSignificanceScore();
|
||||
|
||||
assertThat(score00Background, equalTo(score00SeparateSets));
|
||||
assertThat(score01Background, equalTo(score01SeparateSets));
|
||||
|
@ -401,11 +436,15 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
|
|||
.execute()
|
||||
.actionGet();
|
||||
assertSearchResponse(response);
|
||||
StringTerms classes = (StringTerms) response.getAggregations().get("class");
|
||||
StringTerms classes = response.getAggregations().get("class");
|
||||
assertThat(classes.getBuckets().size(), equalTo(2));
|
||||
Iterator<Terms.Bucket> classBuckets = classes.getBuckets().iterator();
|
||||
Collection<SignificantTerms.Bucket> classA = ((SignificantTerms) classBuckets.next().getAggregations().get("mySignificantTerms")).getBuckets();
|
||||
Iterator<SignificantTerms.Bucket> classBBucketIterator = ((SignificantTerms) classBuckets.next().getAggregations().get("mySignificantTerms")).getBuckets().iterator();
|
||||
|
||||
Aggregations aggregations = classBuckets.next().getAggregations();
|
||||
SignificantTerms sigTerms = aggregations.get("mySignificantTerms");
|
||||
|
||||
Collection<SignificantTerms.Bucket> classA = sigTerms.getBuckets();
|
||||
Iterator<SignificantTerms.Bucket> classBBucketIterator = sigTerms.getBuckets().iterator();
|
||||
assertThat(classA.size(), greaterThan(0));
|
||||
for (SignificantTerms.Bucket classABucket : classA) {
|
||||
SignificantTerms.Bucket classBBucket = classBBucketIterator.next();
|
||||
|
@ -462,8 +501,10 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
|
|||
.actionGet();
|
||||
assertSearchResponse(response);
|
||||
for (Terms.Bucket classBucket : ((Terms) response.getAggregations().get("class")).getBuckets()) {
|
||||
for (SignificantTerms.Bucket bucket : ((SignificantTerms) classBucket.getAggregations().get("mySignificantTerms")).getBuckets()) {
|
||||
assertThat(bucket.getSignificanceScore(), is((double) bucket.getSubsetDf() + bucket.getSubsetSize() + bucket.getSupersetDf() + bucket.getSupersetSize()));
|
||||
SignificantTerms sigTerms = classBucket.getAggregations().get("mySignificantTerms");
|
||||
for (SignificantTerms.Bucket bucket : sigTerms.getBuckets()) {
|
||||
assertThat(bucket.getSignificanceScore(),
|
||||
is((double) bucket.getSubsetDf() + bucket.getSubsetSize() + bucket.getSupersetDf() + bucket.getSupersetSize()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -478,9 +519,7 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
|
|||
} else {
|
||||
script = new Script("native_significance_score_script_no_params", ScriptType.INLINE, "native", null);
|
||||
}
|
||||
ScriptHeuristic scriptHeuristic = new ScriptHeuristic(script);
|
||||
|
||||
return scriptHeuristic;
|
||||
return new ScriptHeuristic(script);
|
||||
}
|
||||
|
||||
private void indexRandomFrequencies01(String type) throws ExecutionException, InterruptedException {
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.elasticsearch.search.SearchParseException;
|
|||
import org.elasticsearch.search.aggregations.bucket.histogram.ExtendedBounds;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.ThreadPoolStats;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.joda.time.Instant;
|
||||
|
||||
|
@ -41,6 +42,7 @@ import java.io.IOException;
|
|||
|
||||
import static java.lang.Math.max;
|
||||
import static java.lang.Math.min;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
@ -149,9 +151,21 @@ public class ExtendedBoundsTests extends ESTestCase {
|
|||
ExtendedBounds orig = randomExtendedBounds();
|
||||
|
||||
try (XContentBuilder out = JsonXContent.contentBuilder()) {
|
||||
out.startObject();
|
||||
orig.toXContent(out, ToXContent.EMPTY_PARAMS);
|
||||
out.endObject();
|
||||
|
||||
try (XContentParser in = JsonXContent.jsonXContent.createParser(out.bytes())) {
|
||||
in.nextToken();
|
||||
XContentParser.Token token = in.currentToken();
|
||||
assertNull(token);
|
||||
|
||||
token = in.nextToken();
|
||||
assertThat(token, equalTo(XContentParser.Token.START_OBJECT));
|
||||
|
||||
token = in.nextToken();
|
||||
assertThat(token, equalTo(XContentParser.Token.FIELD_NAME));
|
||||
assertThat(in.currentName(), equalTo(ExtendedBounds.EXTENDED_BOUNDS_FIELD.getPreferredName()));
|
||||
|
||||
ExtendedBounds read = ExtendedBounds.PARSER.apply(in, () -> ParseFieldMatcher.STRICT);
|
||||
assertEquals(orig, read);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -71,9 +71,11 @@ public class ThreadPoolStatsTests extends ESTestCase {
|
|||
stats.add(new ThreadPoolStats.Stats(ThreadPool.Names.FORCE_MERGE, -1, 0, 0, 0, 0, 0L));
|
||||
stats.add(new ThreadPoolStats.Stats(ThreadPool.Names.SAME, -1, 0, 0, 0, 0, 0L));
|
||||
|
||||
|
||||
ThreadPoolStats threadPoolStats = new ThreadPoolStats(stats);
|
||||
try (XContentBuilder builder = new XContentBuilder(XContentType.JSON.xContent(), os)) {
|
||||
new ThreadPoolStats(stats).toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
builder.startObject();
|
||||
threadPoolStats.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
builder.endObject();
|
||||
}
|
||||
|
||||
try (XContentParser parser = XContentType.JSON.xContent().createParser(os.bytes())) {
|
||||
|
@ -81,7 +83,11 @@ public class ThreadPoolStatsTests extends ESTestCase {
|
|||
assertNull(token);
|
||||
|
||||
token = parser.nextToken();
|
||||
assertThat(token, equalTo(XContentParser.Token.VALUE_STRING));
|
||||
assertThat(token, equalTo(XContentParser.Token.START_OBJECT));
|
||||
|
||||
token = parser.nextToken();
|
||||
assertThat(token, equalTo(XContentParser.Token.FIELD_NAME));
|
||||
assertThat(parser.currentName(), equalTo(ThreadPoolStats.Fields.THREAD_POOL));
|
||||
|
||||
token = parser.nextToken();
|
||||
assertThat(token, equalTo(XContentParser.Token.START_OBJECT));
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
4127b62db028f981e81caa248953c0899d720f98
|
|
@ -0,0 +1 @@
|
|||
fd13b1c033741d48291315c6370f7d475a42dccf
|
|
@ -1 +0,0 @@
|
|||
4282418817ad2be26ce18739461499eae679390f
|
|
@ -0,0 +1 @@
|
|||
3a6fb7e75c9972559a78cf5cfc5a48a41a13ea40
|
|
@ -1 +0,0 @@
|
|||
9ccde45d574388371d2c4032d4b853e2d596777e
|
|
@ -0,0 +1 @@
|
|||
005b73867bc12224946fc67fc8d49d9f5e698d7f
|
|
@ -1 +0,0 @@
|
|||
6c5235a523b7d720b2b0e1b850ea14083e342b07
|
|
@ -0,0 +1 @@
|
|||
eb63166c723b0b4b9fb5298fca232a2f6612ec34
|
|
@ -0,0 +1 @@
|
|||
3b132bea69e8ee099f416044970997bde80f4ea6
|
|
@ -0,0 +1,176 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
|
@ -0,0 +1,24 @@
|
|||
***The art of simplicity is a puzzle of complexity.***
|
||||
|
||||
## Overview ##
|
||||
[YAML](http://yaml.org) is a data serialization format designed for human readability and interaction with scripting languages.
|
||||
|
||||
SnakeYAML is a YAML processor for the Java Virtual Machine.
|
||||
|
||||
## SnakeYAML features ##
|
||||
|
||||
* a **complete** [YAML 1.1 processor](http://yaml.org/spec/1.1/current.html). In particular, SnakeYAML can parse all examples from the specification.
|
||||
* Unicode support including UTF-8/UTF-16 input/output.
|
||||
* high-level API for serializing and deserializing native Java objects.
|
||||
* support for all types from the [YAML types repository](http://yaml.org/type/index.html).
|
||||
* relatively sensible error messages.
|
||||
|
||||
## Info ##
|
||||
* [Changes](https://bitbucket.org/asomov/snakeyaml/wiki/Changes)
|
||||
* [Documentation](https://bitbucket.org/asomov/snakeyaml/wiki/Documentation)
|
||||
|
||||
## Contribute ##
|
||||
* Mercurial DVCS is used to dance with the [source code](https://bitbucket.org/asomov/snakeyaml/src).
|
||||
* If you find a bug in SnakeYAML, please [file a bug report](https://bitbucket.org/asomov/snakeyaml/issues?status=new&status=open).
|
||||
* You may discuss SnakeYAML at
|
||||
[the mailing list](http://groups.google.com/group/snakeyaml-core).
|
|
@ -98,7 +98,7 @@ setup:
|
|||
query_type: "unknown"
|
||||
|
||||
- match: { responses.0.hits.total: 2 }
|
||||
- match: { responses.1.error.root_cause.0.type: json_parse_exception }
|
||||
- match: { responses.1.error.root_cause.0.type: json_e_o_f_exception }
|
||||
- match: { responses.1.error.root_cause.0.reason: "/Unexpected.end.of.input/" }
|
||||
- match: { responses.2.hits.total: 1 }
|
||||
- match: { responses.3.error.root_cause.0.type: parsing_exception }
|
||||
|
|
Loading…
Reference in New Issue