mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-25 01:19:02 +00:00
Fix for ttl fieldmapper to support disabling correctly. Also returning only booleans, not enums in toXContent
This commit is contained in:
parent
230cbd3448
commit
fbdf89c636
@ -39,6 +39,7 @@ import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeBooleanValue;
|
||||
import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeTimeValue;
|
||||
import static org.elasticsearch.index.mapper.core.TypeParsers.parseField;
|
||||
|
||||
@ -96,8 +97,9 @@ public class TTLFieldMapper extends LongFieldMapper implements InternalMapper, R
|
||||
for (Map.Entry<String, Object> entry : node.entrySet()) {
|
||||
String fieldName = Strings.toUnderscoreCase(entry.getKey());
|
||||
Object fieldNode = entry.getValue();
|
||||
if (fieldName.equals("enabled") && ("true".equals(fieldNode.toString()) || "yes".equals(fieldNode.toString()))) {
|
||||
builder.enabled(EnabledAttributeMapper.ENABLED);
|
||||
if (fieldName.equals("enabled")) {
|
||||
EnabledAttributeMapper enabledState = nodeBooleanValue(fieldNode) ? EnabledAttributeMapper.ENABLED : EnabledAttributeMapper.DISABLED;
|
||||
builder.enabled(enabledState);
|
||||
} else if (fieldName.equals("default")) {
|
||||
TimeValue ttlTimeValue = nodeTimeValue(fieldNode, null);
|
||||
if (ttlTimeValue != null) {
|
||||
|
@ -228,7 +228,7 @@ public class TimestampFieldMapper extends DateFieldMapper implements InternalMap
|
||||
builder.field("store", fieldType.stored());
|
||||
}
|
||||
if (enabledState != Defaults.ENABLED) {
|
||||
builder.field("enabled", enabledState);
|
||||
builder.field("enabled", enabledState.enabled);
|
||||
}
|
||||
if (path != Defaults.PATH) {
|
||||
builder.field("path", path);
|
||||
|
Loading…
x
Reference in New Issue
Block a user