Skip to content

Commit 700173a

Browse files
authored
Add tests for #87 and #88 (#126) (#127)
1 parent 0d9b6e2 commit 700173a

File tree

5 files changed

+488
-0
lines changed

5 files changed

+488
-0
lines changed

java-client/src/test/java/co/elastic/clients/elasticsearch/end_to_end/RequestTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ public void testDataIngestion() throws Exception {
122122

123123
assertEquals("my/Id", docId);
124124

125+
// Check auto-created mapping
126+
GetMappingResponse mapping = client.indices().getMapping(b -> b.index(index));
127+
assertEquals(
128+
Property.Kind.Long,
129+
mapping.get("ingest-test").mappings().properties().get("intValue")._kind()
130+
);
131+
125132
// Query by id
126133
AppData esData = client.get(b -> b
127134
.index(index)

java-client/src/test/java/co/elastic/clients/elasticsearch/spec_issues/SpecIssuesTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package co.elastic.clients.elasticsearch.spec_issues;
2121

2222
import co.elastic.clients.elasticsearch.ElasticsearchTestServer;
23+
import co.elastic.clients.elasticsearch.cluster.ClusterStatsResponse;
2324
import co.elastic.clients.elasticsearch.core.SearchRequest;
2425
import co.elastic.clients.elasticsearch.core.SearchResponse;
2526
import co.elastic.clients.elasticsearch.model.ModelTestCase;
@@ -43,6 +44,26 @@ public void i0107_rangeBucketKey() {
4344
loadRsrc("issue-0107-response.json", SearchResponse.createSearchResponseDeserializer(JsonData._DESERIALIZER));
4445
}
4546

47+
@Test
48+
public void i0088_clusterStats() {
49+
// https://github.com/elastic/elasticsearch-java/issues/88
50+
loadRsrc("issue-0088-response.json", ClusterStatsResponse._DESERIALIZER);
51+
}
52+
53+
@Test
54+
public void i0087_filterAggSubAggregation() {
55+
// https://github.com/elastic/elasticsearch-java/issues/87
56+
SearchResponse<JsonData> resp = loadRsrc("issue-0087-response.json",
57+
SearchResponse.createSearchResponseDeserializer(JsonData._DESERIALIZER));
58+
59+
assertEquals(
60+
"cnn.com",
61+
resp.aggregations().get("login_filter").filter()
62+
.aggregations().get("to_domain").sterms()
63+
.buckets().array().get(0).key());
64+
65+
}
66+
4667
@Test
4768
public void i0078_deserializeSearchRequest() {
4869
// https://github.com/elastic/elasticsearch-java/issues/78
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
{
2+
"_source": {
3+
"excludes": [
4+
"attachmentContents.*"
5+
],
6+
"includes": [
7+
"*"
8+
]
9+
},
10+
"aggregations": {
11+
"count": {
12+
"value_count": {
13+
"field": "messageStorageId.messageId"
14+
}
15+
},
16+
"login_filter": {
17+
"aggregations": {
18+
"date": {
19+
"terms": {
20+
"field": "year",
21+
"order": [
22+
{
23+
"_key": "desc"
24+
}
25+
]
26+
}
27+
},
28+
"to_domain": {
29+
"terms": {
30+
"exclude": [
31+
"unknown"
32+
],
33+
"field": "to.domain"
34+
}
35+
},
36+
"file_ext": {
37+
"terms": {
38+
"exclude": [
39+
""
40+
],
41+
"field": "attachments.fileExt"
42+
}
43+
},
44+
"has_att": {
45+
"terms": {
46+
"field": "hasAttachments"
47+
}
48+
},
49+
"from": {
50+
"terms": {
51+
"exclude": [
52+
"unknown"
53+
],
54+
"field": "sender.name"
55+
}
56+
},
57+
"from_domain": {
58+
"terms": {
59+
"exclude": [
60+
"unknown"
61+
],
62+
"field": "sender.domain"
63+
}
64+
},
65+
"to": {
66+
"terms": {
67+
"exclude": [
68+
"unknown"
69+
],
70+
"field": "to.name"
71+
}
72+
}
73+
},
74+
"filter": {
75+
"bool": {
76+
"must": [
77+
{
78+
"bool": {
79+
"minimum_should_match": "1"
80+
}
81+
}
82+
]
83+
}
84+
}
85+
}
86+
},
87+
"from": 0,
88+
"highlight": {
89+
"fields": {
90+
"body": {
91+
"fragment_size": 0,
92+
"number_of_fragments": 0
93+
},
94+
"attachments.fileName": {
95+
"fragment_size": 0,
96+
"number_of_fragments": 0
97+
},
98+
"attachmentContents.*": {
99+
"fragment_size": 200,
100+
"number_of_fragments": 2
101+
},
102+
"subject": {
103+
"fragment_size": 0,
104+
"number_of_fragments": 0
105+
}
106+
},
107+
"post_tags": [
108+
"</span>"
109+
],
110+
"pre_tags": [
111+
"<span class=\"blue-hilite\">"
112+
]
113+
},
114+
"query": {
115+
"bool": {
116+
"must": [
117+
{
118+
"bool": {
119+
"must": [
120+
{
121+
"query_string": {
122+
"default_operator": "and",
123+
"query": "Tsang"
124+
}
125+
}
126+
]
127+
}
128+
},
129+
{
130+
"bool": {
131+
"minimum_should_match": "1",
132+
"should": [
133+
{
134+
"match_all": {}
135+
}
136+
]
137+
}
138+
}
139+
]
140+
}
141+
},
142+
"size": 10,
143+
"sort": [
144+
{
145+
"messageDate": {
146+
"order": "asc"
147+
}
148+
}
149+
],
150+
"stored_fields": [
151+
"_source"
152+
]
153+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"took": 190,
3+
"timed_out": false,
4+
"_shards": {
5+
"total": 1,
6+
"successful": 1,
7+
"skipped": 0,
8+
"failed": 0
9+
},
10+
"hits": {
11+
"total": {
12+
"value": 1,
13+
"relation": "eq"
14+
},
15+
"max_score": null,
16+
"hits": []
17+
},
18+
"aggregations": {
19+
"value_count#count": {
20+
"value": 1
21+
},
22+
"filter#login_filter": {
23+
"meta": {},
24+
"doc_count": 1,
25+
"sterms#to_domain": {
26+
"doc_count_error_upper_bound": 0,
27+
"sum_other_doc_count": 0,
28+
"buckets": [
29+
{
30+
"key": "cnn.com",
31+
"doc_count": 1
32+
}
33+
]
34+
},
35+
"sterms#date": {
36+
"doc_count_error_upper_bound": 0,
37+
"sum_other_doc_count": 0,
38+
"buckets": [
39+
{
40+
"key": "2008",
41+
"doc_count": 1
42+
}
43+
]
44+
},
45+
"lterms#has_att": {
46+
"doc_count_error_upper_bound": 0,
47+
"sum_other_doc_count": 0,
48+
"buckets": [
49+
{
50+
"key": 1,
51+
"key_as_string": "true",
52+
"doc_count": 1
53+
}
54+
]
55+
},
56+
"sterms#file_ext": {
57+
"doc_count_error_upper_bound": 0,
58+
"sum_other_doc_count": 0,
59+
"buckets": [
60+
{
61+
"key": "doc",
62+
"doc_count": 1
63+
}
64+
]
65+
},
66+
"sterms#from_domain": {
67+
"doc_count_error_upper_bound": 0,
68+
"sum_other_doc_count": 0,
69+
"buckets": [
70+
{
71+
"key": "gmail.com",
72+
"doc_count": 1
73+
}
74+
]
75+
},
76+
"sterms#from": {
77+
"doc_count_error_upper_bound": 0,
78+
"sum_other_doc_count": 0,
79+
"buckets": [
80+
{
81+
"key": "John Tsang",
82+
"doc_count": 1
83+
}
84+
]
85+
},
86+
"sterms#to": {
87+
"doc_count_error_upper_bound": 0,
88+
"sum_other_doc_count": 0,
89+
"buckets": [
90+
{
91+
"key": "John Smith",
92+
"doc_count": 1
93+
}
94+
]
95+
}
96+
}
97+
}
98+
}

0 commit comments

Comments
 (0)