diff --git a/java-client/src/test/java/co/elastic/clients/elasticsearch/end_to_end/RequestTest.java b/java-client/src/test/java/co/elastic/clients/elasticsearch/end_to_end/RequestTest.java index 0718ffc20..f267163b6 100644 --- a/java-client/src/test/java/co/elastic/clients/elasticsearch/end_to_end/RequestTest.java +++ b/java-client/src/test/java/co/elastic/clients/elasticsearch/end_to_end/RequestTest.java @@ -122,6 +122,13 @@ public void testDataIngestion() throws Exception { assertEquals("my/Id", docId); + // Check auto-created mapping + GetMappingResponse mapping = client.indices().getMapping(b -> b.index(index)); + assertEquals( + Property.Kind.Long, + mapping.get("ingest-test").mappings().properties().get("intValue")._kind() + ); + // Query by id AppData esData = client.get(b -> b .index(index) diff --git a/java-client/src/test/java/co/elastic/clients/elasticsearch/spec_issues/SpecIssuesTest.java b/java-client/src/test/java/co/elastic/clients/elasticsearch/spec_issues/SpecIssuesTest.java index a9427ed45..ee3a6aeb6 100644 --- a/java-client/src/test/java/co/elastic/clients/elasticsearch/spec_issues/SpecIssuesTest.java +++ b/java-client/src/test/java/co/elastic/clients/elasticsearch/spec_issues/SpecIssuesTest.java @@ -20,6 +20,7 @@ package co.elastic.clients.elasticsearch.spec_issues; import co.elastic.clients.elasticsearch.ElasticsearchTestServer; +import co.elastic.clients.elasticsearch.cluster.ClusterStatsResponse; import co.elastic.clients.elasticsearch.core.SearchRequest; import co.elastic.clients.elasticsearch.core.SearchResponse; import co.elastic.clients.elasticsearch.model.ModelTestCase; @@ -43,6 +44,26 @@ public void i0107_rangeBucketKey() { loadRsrc("issue-0107-response.json", SearchResponse.createSearchResponseDeserializer(JsonData._DESERIALIZER)); } + @Test + public void i0088_clusterStats() { + // https://github.com/elastic/elasticsearch-java/issues/88 + loadRsrc("issue-0088-response.json", ClusterStatsResponse._DESERIALIZER); + } + + @Test + public void i0087_filterAggSubAggregation() { + // https://github.com/elastic/elasticsearch-java/issues/87 + SearchResponse resp = loadRsrc("issue-0087-response.json", + SearchResponse.createSearchResponseDeserializer(JsonData._DESERIALIZER)); + + assertEquals( + "cnn.com", + resp.aggregations().get("login_filter").filter() + .aggregations().get("to_domain").sterms() + .buckets().array().get(0).key()); + + } + @Test public void i0078_deserializeSearchRequest() { // https://github.com/elastic/elasticsearch-java/issues/78 diff --git a/java-client/src/test/resources/co/elastic/clients/elasticsearch/spec_issues/issue-0087-request.json b/java-client/src/test/resources/co/elastic/clients/elasticsearch/spec_issues/issue-0087-request.json new file mode 100644 index 000000000..d12d55110 --- /dev/null +++ b/java-client/src/test/resources/co/elastic/clients/elasticsearch/spec_issues/issue-0087-request.json @@ -0,0 +1,153 @@ +{ + "_source": { + "excludes": [ + "attachmentContents.*" + ], + "includes": [ + "*" + ] + }, + "aggregations": { + "count": { + "value_count": { + "field": "messageStorageId.messageId" + } + }, + "login_filter": { + "aggregations": { + "date": { + "terms": { + "field": "year", + "order": [ + { + "_key": "desc" + } + ] + } + }, + "to_domain": { + "terms": { + "exclude": [ + "unknown" + ], + "field": "to.domain" + } + }, + "file_ext": { + "terms": { + "exclude": [ + "" + ], + "field": "attachments.fileExt" + } + }, + "has_att": { + "terms": { + "field": "hasAttachments" + } + }, + "from": { + "terms": { + "exclude": [ + "unknown" + ], + "field": "sender.name" + } + }, + "from_domain": { + "terms": { + "exclude": [ + "unknown" + ], + "field": "sender.domain" + } + }, + "to": { + "terms": { + "exclude": [ + "unknown" + ], + "field": "to.name" + } + } + }, + "filter": { + "bool": { + "must": [ + { + "bool": { + "minimum_should_match": "1" + } + } + ] + } + } + } + }, + "from": 0, + "highlight": { + "fields": { + "body": { + "fragment_size": 0, + "number_of_fragments": 0 + }, + "attachments.fileName": { + "fragment_size": 0, + "number_of_fragments": 0 + }, + "attachmentContents.*": { + "fragment_size": 200, + "number_of_fragments": 2 + }, + "subject": { + "fragment_size": 0, + "number_of_fragments": 0 + } + }, + "post_tags": [ + "" + ], + "pre_tags": [ + "" + ] + }, + "query": { + "bool": { + "must": [ + { + "bool": { + "must": [ + { + "query_string": { + "default_operator": "and", + "query": "Tsang" + } + } + ] + } + }, + { + "bool": { + "minimum_should_match": "1", + "should": [ + { + "match_all": {} + } + ] + } + } + ] + } + }, + "size": 10, + "sort": [ + { + "messageDate": { + "order": "asc" + } + } + ], + "stored_fields": [ + "_source" + ] +} diff --git a/java-client/src/test/resources/co/elastic/clients/elasticsearch/spec_issues/issue-0087-response.json b/java-client/src/test/resources/co/elastic/clients/elasticsearch/spec_issues/issue-0087-response.json new file mode 100644 index 000000000..9fccd399c --- /dev/null +++ b/java-client/src/test/resources/co/elastic/clients/elasticsearch/spec_issues/issue-0087-response.json @@ -0,0 +1,98 @@ +{ + "took": 190, + "timed_out": false, + "_shards": { + "total": 1, + "successful": 1, + "skipped": 0, + "failed": 0 + }, + "hits": { + "total": { + "value": 1, + "relation": "eq" + }, + "max_score": null, + "hits": [] + }, + "aggregations": { + "value_count#count": { + "value": 1 + }, + "filter#login_filter": { + "meta": {}, + "doc_count": 1, + "sterms#to_domain": { + "doc_count_error_upper_bound": 0, + "sum_other_doc_count": 0, + "buckets": [ + { + "key": "cnn.com", + "doc_count": 1 + } + ] + }, + "sterms#date": { + "doc_count_error_upper_bound": 0, + "sum_other_doc_count": 0, + "buckets": [ + { + "key": "2008", + "doc_count": 1 + } + ] + }, + "lterms#has_att": { + "doc_count_error_upper_bound": 0, + "sum_other_doc_count": 0, + "buckets": [ + { + "key": 1, + "key_as_string": "true", + "doc_count": 1 + } + ] + }, + "sterms#file_ext": { + "doc_count_error_upper_bound": 0, + "sum_other_doc_count": 0, + "buckets": [ + { + "key": "doc", + "doc_count": 1 + } + ] + }, + "sterms#from_domain": { + "doc_count_error_upper_bound": 0, + "sum_other_doc_count": 0, + "buckets": [ + { + "key": "gmail.com", + "doc_count": 1 + } + ] + }, + "sterms#from": { + "doc_count_error_upper_bound": 0, + "sum_other_doc_count": 0, + "buckets": [ + { + "key": "John Tsang", + "doc_count": 1 + } + ] + }, + "sterms#to": { + "doc_count_error_upper_bound": 0, + "sum_other_doc_count": 0, + "buckets": [ + { + "key": "John Smith", + "doc_count": 1 + } + ] + } + } + } +} diff --git a/java-client/src/test/resources/co/elastic/clients/elasticsearch/spec_issues/issue-0088-response.json b/java-client/src/test/resources/co/elastic/clients/elasticsearch/spec_issues/issue-0088-response.json new file mode 100644 index 000000000..7d2d2ea1c --- /dev/null +++ b/java-client/src/test/resources/co/elastic/clients/elasticsearch/spec_issues/issue-0088-response.json @@ -0,0 +1,209 @@ +{ + "_nodes": { + "total": 2, + "successful": 2, + "failed": 0 + }, + "cluster_name": "testCluster", + "cluster_uuid": "mFsnsmy6R4mIEyAcxOdRGg", + "timestamp": 1640886234666, + "status": "green", + "indices": { + "count": 0, + "shards": {}, + "docs": { + "count": 0, + "deleted": 0 + }, + "store": { + "size_in_bytes": 0, + "total_data_set_size_in_bytes": 0, + "reserved_in_bytes": 0 + }, + "fielddata": { + "memory_size_in_bytes": 0, + "evictions": 0 + }, + "query_cache": { + "memory_size_in_bytes": 0, + "total_count": 0, + "hit_count": 0, + "miss_count": 0, + "cache_size": 0, + "cache_count": 0, + "evictions": 0 + }, + "completion": { + "size_in_bytes": 0 + }, + "segments": { + "count": 0, + "memory_in_bytes": 0, + "terms_memory_in_bytes": 0, + "stored_fields_memory_in_bytes": 0, + "term_vectors_memory_in_bytes": 0, + "norms_memory_in_bytes": 0, + "points_memory_in_bytes": 0, + "doc_values_memory_in_bytes": 0, + "index_writer_memory_in_bytes": 0, + "version_map_memory_in_bytes": 0, + "fixed_bit_set_memory_in_bytes": 0, + "max_unsafe_auto_id_timestamp": -9223372036854775808, + "file_sizes": {} + }, + "mappings": { + "field_types": [], + "runtime_field_types": [] + }, + "analysis": { + "char_filter_types": [], + "tokenizer_types": [], + "filter_types": [], + "analyzer_types": [], + "built_in_char_filters": [], + "built_in_tokenizers": [], + "built_in_filters": [], + "built_in_analyzers": [] + }, + "versions": [] + }, + "nodes": { + "count": { + "total": 2, + "coordinating_only": 0, + "data": 2, + "data_cold": 2, + "data_content": 2, + "data_frozen": 2, + "data_hot": 2, + "data_warm": 2, + "ingest": 2, + "master": 2, + "ml": 0, + "remote_cluster_client": 2, + "transform": 2, + "voting_only": 0 + }, + "versions": [ + "7.16.1" + ], + "os": { + "available_processors": 16, + "allocated_processors": 16, + "names": [ + { + "name": "Mac OS X", + "count": 2 + } + ], + "pretty_names": [ + { + "pretty_name": "Mac OS X", + "count": 2 + } + ], + "architectures": [ + { + "arch": "aarch64", + "count": 2 + } + ], + "mem": { + "total_in_bytes": 34359738368, + "free_in_bytes": 118784000, + "used_in_bytes": 34240954368, + "free_percent": 0, + "used_percent": 100 + } + }, + "process": { + "cpu": { + "percent": 0 + }, + "open_file_descriptors": { + "min": 337, + "max": 338, + "avg": 337 + } + }, + "jvm": { + "max_uptime_in_millis": 51439, + "versions": [ + { + "version": "17.0.1", + "vm_name": "OpenJDK 64-Bit Server VM", + "vm_version": "17.0.1+12", + "vm_vendor": "Eclipse Adoptium", + "bundled_jdk": true, + "using_bundled_jdk": true, + "count": 2 + } + ], + "mem": { + "heap_used_in_bytes": 824238880, + "heap_max_in_bytes": 17179869184 + }, + "threads": 72 + }, + "fs": { + "total_in_bytes": 994662584320, + "free_in_bytes": 722047512576, + "available_in_bytes": 722047512576 + }, + "plugins": [], + "network_types": { + "transport_types": { + "netty4": 2 + }, + "http_types": { + "netty4": 2 + } + }, + "discovery_types": { + "zen": 2 + }, + "packaging_types": [ + { + "flavor": "default", + "type": "tar", + "count": 2 + } + ], + "ingest": { + "number_of_pipelines": 2, + "processor_stats": { + "gsub": { + "count": 0, + "failed": 0, + "current": 0, + "time_in_millis": 0 + }, + "script": { + "count": 0, + "failed": 0, + "current": 0, + "time_in_millis": 0 + } + } + }, + "indexing_pressure": { + "memory": { + "limit_in_bytes": 0, + "current": { + "all_in_bytes": 0, + "combined_coordinating_and_primary_in_bytes": 0, + "coordinating_in_bytes": 0, + "primary_in_bytes": 0, + "replica_in_bytes": 0 + }, + "total": { + "all_in_bytes": 0, + "combined_coordinating_and_primary_in_bytes": 0, + "coordinating_in_bytes": 0, + "primary_in_bytes": 0, + "replica_in_bytes": 0 + } + } + } + } +}