elastic/elasticsearch-java

Cannot parse DynamicTemplate of component/index templates

fpeter8 opened this issue · 1 comments

Java API client version

8.9

Java version

17

Elasticsearch Version

8.9

Problem description

DynamicTemplates now have lists in the match / pathMatch fields, but the Java classes and deserializers expect a single String. Listing the default templates created by a new elastic cluster can reproduce this issue:

client.cluster().getComponentTemplate();

Example output of this call on a newly created single node cluster (truncated):

{"component_templates":[{"name":"metrics-mappings","component_template":{"template":{"mappings":{"dynamic_templates":[{"long_metrics":{"mapping":{"index":false,"type":"long"},"match_mapping_type":"long"}},{"double_metrics":{"mapping":{"index":false,"type":"float"},"match_mapping_type":"double"}}],"properties":{"data_stream":{"properties":{"type":{"type":"constant_keyword","value":"metrics"}}}}}},"version":3,"_meta":{"managed":true,"description":"default mappings for the metrics index template installed by x-pack"}}},{"name":"behavioral_analytics-events-mappings","component_template":{"template":{"mappings":{"dynamic":"strict","properties":{"search":{"properties":{"query":{"ignore_above":1024,"type":"keyword"},"filters":{"type":"flattened"},"page":{"properties":{"current":{"type":"integer"},"size":{"type":"integer"}}},"sort":{"properties":{"name":{"ignore_above":1024,"type":"keyword"},"direction":{"ignore_above":1024,"type":"keyword"}}},"results":{"properties":{"items":{"type":"object","enabled":false},"total_results":{"type":"integer"}}},"search_application":{"ignore_above":1024,"type":"keyword"}}},"@timestamp":{"type":"date"},"data_stream":{"properties":{"namespace":{"type":"keyword"},"type":{"type":"keyword"},"dataset":{"type":"keyword"}}},"session":{"properties":{"location":{"properties":{"continent_name":{"ignore_above":1024,"type":"keyword"},"region_iso_code":{"ignore_above":1024,"type":"keyword"},"city_name":{"ignore_above":1024,"type":"keyword"},"country_iso_code":{"ignore_above":1024,"type":"keyword"},"country_name":{"ignore_above":1024,"type":"keyword"},"region_name":{"ignore_above":1024,"type":"keyword"},"location":{"type":"geo_point"}}},"id":{"ignore_above":1024,"type":"keyword"},"user_agent":{"properties":{"os":{"properties":{"name":{"ignore_above":1024,"type":"keyword"},"version":{"ignore_above":1024,"type":"keyword"},"full":{"ignore_above":1024,"type":"keyword"}}},"browser":{"properties":{"name":{"ignore_above":1024,"type":"keyword"},"version":{"ignore_above":1024,"type":"keyword"}}},"device":{"properties":{"name":{"ignore_above":1024,"type":"keyword"},"type":{"ignore_above":1024,"type":"keyword"}}}}}}},"document":{"properties":{"index":{"ignore_above":1024,"type":"keyword"},"id":{"ignore_above":1024,"type":"keyword"}}},"page":{"properties":{"referrer":{"properties":{"path":{"ignore_above":1024,"type":"keyword"},"extension":{"ignore_above":1024,"type":"keyword"},"fragment":{"ignore_above":1024,"type":"keyword"},"original":{"ignore_above":1024,"type":"keyword"},"scheme":{"ignore_above":1024,"type":"keyword"},"port":{"type":"long"},"domain":{"ignore_above":1024,"type":"keyword"},"query":{"ignore_above":1024,"type":"keyword"}}},"title":{"ignore_above":1024,"type":"keyword"},"url":{"properties":{"path":{"ignore_above":1024,"type":"keyword"},"extension":{"ignore_above":1024,"type":"keyword"},"fragment":{"ignore_above":1024,"type":"keyword"},"original":{"ignore_above":1024,"type":"keyword"},"scheme":{"ignore_above":1024,"type":"keyword"},"port":{"type":"long"},"domain":{"ignore_above":1024,"type":"keyword"},"query":{"ignore_above":1024,"type":"keyword"}}}}},"event":{"properties":{"action":{"ignore_above":1024,"type":"keyword"},"source":{"ignore_above":1024,"type":"keyword"}}},"user":{"properties":{"id":{"ignore_above":1024,"type":"keyword"}}},"tags":{"ignore_above":1024,"type":"keyword"}}}},"version":2,"_meta":{"managed":true,"description":"Built-in mapping applied by default to behavioral analytics event data streams."}}},{"name":".deprecation-indexing-mappings","component_template":{"template":{"mappings":{"dynamic_templates":[{"strings_as_keyword":{"mapping":{"ignore_above":1024,"type":"keyword"},"match_mapping_type":"string"}}],"date_detection":false,"properties":{"@timestamp":{"type":"date"},"ecs":{"properties":{"version":{"ignore_above":1024,"type":"keyword"}}},"data_stream":{"properties":{"namespace":{"type":"constant_keyword"},"type":{"type":"constant_keyword","value":"logs"},"dataset":{"type":"constant_keyword"}}},"host":{"properties":{"ip":{"type":"ip"}}},"message":{"type":"text"}}}},"version":1,"_meta":{"managed":true,"description":"default mappings for Stack deprecation logs index template installed by x-pack"}}},{"name":"behavioral_analytics-events-settings","component_template":{"template":{"settings":{"index":{"lifecycle":{"name":"behavioral_analytics-events-default_policy"},"codec":"best_compression","refresh_interval":"1s","number_of_shards":"1","auto_expand_replicas":"0-1","final_pipeline":"behavioral_analytics-events-final_pipeline","sort":{"field":["session.id","@timestamp"],"order":["asc","asc"]},"number_of_replicas":"0"}}},"version":2,"_meta":{"managed":true,"description":"Built-in settings applied by default to behavioral analytics event data streams."}}},{"name":"synthetics-mappings","component_template":{"template":{"mappings":{"properties":{"data_stream":{"properties":{"type":{"type":"constant_keyword","value":"synthetics"}}}}}},"version":3,"_meta":{"managed":true,"description":"default mappings for the synthetics index template installed by x-pack"}}},{"name":"metrics-settings","component_template":{"template":{"settings":{"index":{"lifecycle":{"name":"metrics"},"codec":"best_compression","query":{"default_field":["message"]}}}},"version":3,"_meta":{"managed":true,"description":"default settings for the metrics index template installed by x-pack"}}},{"name":"ecs@dynamic_templates","component_template":{"template":{"mappings":{"dynamic_templates":[{"ecs_timestamp":{"mapping":{"ignore_malformed":false,"type":"date"},"match":"@timestamp"}},{"ecs_message_match_only_text":{"path_match":["message","*.message"],"mapping":{"type":"match_only_text"}}},{"ecs_ip":{"path_match":["ip","*.ip","*_ip"],"mapping":{"type":"ip"},"match_mapping_type":"string"}},{"ecs_wildcard":{"path_match":["*.io.text","*.message_id","*registry.data.strings","*url.path"],"mapping":{"type":"wildcard"}}},{"ecs_path_match_wildcard_and_match_only_text":{"path_match":["*.body.content","*url.full","*url.original"],"mapping":{"fields":{"text":{"type":"match_only_text"}},"type":"wildcard"}}},{"ecs_match_wildcard_and_match_only_text":{"mapping":{"fields":{"text":{"type":"match_only_text"}},"type":"wildcard"},"match":["*command_line","*stack_trace"]}},{"ecs_path_match_keyword_and_match_only_text":{"path_match":["*file.path","*file.target_path","*os.full","user_agent.original"],"mapping":{"fields":{"text":{"type":"match_only_text"}},"type":"keyword"}}},{"ecs_match_keyword_and_match_only_text":{"path_match":["*.title","*.executable","*.name","*.working_directory","*.full_name"],"mapping":{"fields":{"text":{"type":"match_only_text"}},"type":"keyword"}}},{"ecs_date":{"path_match":["*.timestamp","*_timestamp","*.not_after","*.not_before","*.accessed","created","*.created","*.installed","*.creation_date","*.ctime","*.mtime","ingested","*.ingested","*.start","*.end"],"mapping":{"type":"date"}}},{"ecs_path_match_float":{"path_match":["*.score.*","*_score*"],"mapping":{"type":"float"},"path_unmatch":"*.version"}},{"ecs_usage_scaled_float":{"path_match":"*.usage","mapping":{"scaling_factor":1000,"type":"scaled_float"}}},{"ecs_geo_point":{"path_match":["location","*.location"],"mapping":{"type":"geo_point"}}},{"ecs_flattened":{"path_match":["*structured_data","*exports","*imports"],"mapping":{"type":"flattened"}}},{"all_strings_to_keywords":{"mapping":{"ignore_above":1024,"type":"keyword"},"match_mapping_type":"string"}}]}},"version":3,"_meta":{"managed":true,"description":"dynamic mappings based on ECS, installed by x-pack"}}},{"name":"logs-settings","component_template":{"template":{"settings":{"index":{"lifecycle":{"name":"logs"},"codec":"best_compression","default_pipeline":"logs-default-pipeline","mapping":{"ignore_malformed":"true"},"query":{"default_field":["message"]}}}},"version":3,"_meta":{"managed":true,"description":"default settings for the logs index template installed by x-pack"}}},{"name":".deprecation-indexing-settings","component_template":{"template":{"settings":{"index":{"lifecycle":{"name":".deprecation-indexing-ilm-policy"},"codec":"best_compression","hidden":"true","auto_expand_replicas":"0-1","query":{"default_field":["message"]}}}},"

Thanks for the report! It's an error in the API specification used to produce the Java code (or most probably it wasn't updated after the server side change). We'll fix it and regenerate the client!