1010import org .elasticsearch .cluster .metadata .IndexMetadata ;
1111import org .elasticsearch .common .settings .Settings ;
1212import org .elasticsearch .indices .SystemIndexDescriptor ;
13+ import org .elasticsearch .inference .ModelConfigurations ;
1314import org .elasticsearch .xcontent .XContentBuilder ;
1415
1516import java .io .IOException ;
@@ -27,7 +28,7 @@ private InferenceIndex() {}
2728 public static final String INDEX_ALIAS = ".inference-alias" ;
2829
2930 // Increment this version number when the mappings change
30- private static final int INDEX_MAPPING_VERSION = 2 ;
31+ private static final int INDEX_MAPPING_VERSION = 3 ;
3132
3233 public static Settings settings () {
3334 return Settings .builder ()
@@ -58,6 +59,56 @@ public static Settings settings() {
5859 * @return The index mappings
5960 */
6061 public static XContentBuilder mappings () {
62+ try {
63+ var jsonBuilder = jsonBuilder ().startObject ().startObject (SINGLE_MAPPING_NAME );
64+ {
65+ jsonBuilder .startObject ("_meta" ).field (SystemIndexDescriptor .VERSION_META_KEY , INDEX_MAPPING_VERSION ).endObject ();
66+
67+ jsonBuilder .field ("dynamic" , "strict" );
68+
69+ jsonBuilder .startObject ("properties" );
70+ {
71+ jsonBuilder .startObject ("model_id" ).field ("type" , "keyword" ).endObject ();
72+
73+ jsonBuilder .startObject ("task_type" ).field ("type" , "keyword" ).endObject ();
74+
75+ jsonBuilder .startObject ("service" ).field ("type" , "keyword" ).endObject ();
76+
77+ jsonBuilder .startObject ("service_settings" ).field ("dynamic" , "false" );
78+ {
79+ jsonBuilder .startObject ("properties" ).endObject ();
80+ }
81+ jsonBuilder .endObject ();
82+
83+ jsonBuilder .startObject ("task_settings" ).field ("dynamic" , "false" );
84+ {
85+ jsonBuilder .startObject ("properties" ).endObject ();
86+ }
87+ jsonBuilder .endObject ();
88+
89+ jsonBuilder .startObject ("chunking_settings" );
90+ {
91+ jsonBuilder .field ("dynamic" , "false" );
92+ jsonBuilder .startObject ("properties" );
93+ {
94+ jsonBuilder .startObject ("strategy" ).field ("type" , "keyword" ).endObject ();
95+ }
96+ jsonBuilder .endObject ();
97+ }
98+ jsonBuilder .endObject ();
99+
100+ jsonBuilder .startObject ("endpoint_version" ).field ("dynamic" , "false" ).field ("type" , "keyword" ).endObject ();
101+ }
102+ jsonBuilder .endObject ().endObject ().endObject ();
103+ }
104+
105+ return jsonBuilder ;
106+ } catch (IOException e ) {
107+ throw new UncheckedIOException ("Failed to build mappings for index " + INDEX_NAME , e );
108+ }
109+ }
110+
111+ public static XContentBuilder mappingsV2 () {
61112 try {
62113 return jsonBuilder ().startObject ()
63114 .startObject (SINGLE_MAPPING_NAME )
0 commit comments