-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update config index mappings to use correct field types #2710
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,11 +27,18 @@ public class MLConfig implements ToXContentObject, Writeable { | |
|
||
public static final String TYPE_FIELD = "type"; | ||
|
||
public static final String CONFIG_TYPE_FIELD = "config_type"; | ||
|
||
public static final String CONFIGURATION_FIELD = "configuration"; | ||
|
||
public static final String ML_CONFIGURATION_FIELD = "ml_configuration"; | ||
|
||
public static final String CREATE_TIME_FIELD = "create_time"; | ||
public static final String LAST_UPDATE_TIME_FIELD = "last_update_time"; | ||
|
||
public static final String LAST_UPDATED_TIME_FIELD = "last_updated_time"; | ||
|
||
|
||
@Setter | ||
private String type; | ||
|
||
|
@@ -78,10 +85,10 @@ public void writeTo(StreamOutput out) throws IOException { | |
public XContentBuilder toXContent(XContentBuilder xContentBuilder, Params params) throws IOException { | ||
XContentBuilder builder = xContentBuilder.startObject(); | ||
if (type != null) { | ||
builder.field(TYPE_FIELD, type); | ||
builder.field(CONFIG_TYPE_FIELD, type); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before this PR
Now we have
This is a breaking change. How about changing to
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for line 91, that's also breaking |
||
} | ||
if (configuration != null) { | ||
builder.field(CONFIGURATION_FIELD, configuration); | ||
builder.field(ML_CONFIGURATION_FIELD, configuration); | ||
} | ||
if (createTime != null) { | ||
builder.field(CREATE_TIME_FIELD, createTime.toEpochMilli()); | ||
|
@@ -99,9 +106,12 @@ public static MLConfig fromStream(StreamInput in) throws IOException { | |
|
||
public static MLConfig parse(XContentParser parser) throws IOException { | ||
String type = null; | ||
String configType = null; | ||
Configuration configuration = null; | ||
Configuration mlConfiguration = null; | ||
Instant createTime = null; | ||
Instant lastUpdateTime = null; | ||
Instant lastUpdatedTime = null; | ||
|
||
ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.currentToken(), parser); | ||
while (parser.nextToken() != XContentParser.Token.END_OBJECT) { | ||
|
@@ -112,25 +122,34 @@ public static MLConfig parse(XContentParser parser) throws IOException { | |
case TYPE_FIELD: | ||
type = parser.text(); | ||
break; | ||
case CONFIG_TYPE_FIELD: | ||
configType = parser.text(); | ||
break; | ||
case CONFIGURATION_FIELD: | ||
configuration = Configuration.parse(parser); | ||
break; | ||
case ML_CONFIGURATION_FIELD: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another field added in 2.13, |
||
mlConfiguration = Configuration.parse(parser); | ||
break; | ||
case CREATE_TIME_FIELD: | ||
createTime = Instant.ofEpochMilli(parser.longValue()); | ||
break; | ||
case LAST_UPDATE_TIME_FIELD: | ||
lastUpdateTime = Instant.ofEpochMilli(parser.longValue()); | ||
break; | ||
case LAST_UPDATED_TIME_FIELD: | ||
lastUpdatedTime = Instant.ofEpochMilli(parser.longValue()); | ||
break; | ||
default: | ||
parser.skipChildren(); | ||
break; | ||
} | ||
} | ||
return MLConfig.builder() | ||
.type(type) | ||
.configuration(configuration) | ||
.type(configType == null ? type : configType) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Parse new field value to new field
|
||
.configuration(mlConfiguration == null ? configuration : mlConfiguration) | ||
.createTime(createTime) | ||
.lastUpdateTime(lastUpdateTime) | ||
.lastUpdateTime(lastUpdatedTime == null ? lastUpdateTime : lastUpdatedTime) | ||
.build(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to reuse the old Field names for CX experience BWC, rather than defining new ones?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using old names and trying to update their types is failing. OpenSearch does not allow conversion between certain types and flat_object is one of them