Mapping: Disable automatic ip type detection on new fields, closes #674.

This commit is contained in:
kimchy 2011-02-08 01:14:34 +02:00
parent 4319e3cb05
commit 689b20a518
1 changed files with 14 additions and 14 deletions

View File

@ -28,7 +28,6 @@ import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.mapper.*;
import org.elasticsearch.index.mapper.xcontent.ip.IpFieldMapper;
import java.io.IOException;
import java.util.HashMap;
@ -440,20 +439,21 @@ public class ObjectMapper implements XContentMapper, IncludeInAllMapper {
}
}
}
// DON'T do automatic ip detection logic, since it messes up with docs that have hosts and ips
// check if its an ip
if (!resolved && text.indexOf('.') != -1) {
try {
IpFieldMapper.ipToLong(text);
XContentMapper.Builder builder = context.root().findTemplateBuilder(context, currentFieldName, "ip");
if (builder == null) {
builder = ipField(currentFieldName);
}
mapper = builder.build(builderContext);
resolved = true;
} catch (Exception e) {
// failure to parse, not ip...
}
}
// if (!resolved && text.indexOf('.') != -1) {
// try {
// IpFieldMapper.ipToLong(text);
// XContentMapper.Builder builder = context.root().findTemplateBuilder(context, currentFieldName, "ip");
// if (builder == null) {
// builder = ipField(currentFieldName);
// }
// mapper = builder.build(builderContext);
// resolved = true;
// } catch (Exception e) {
// // failure to parse, not ip...
// }
// }
if (!resolved) {
XContentMapper.Builder builder = context.root().findTemplateBuilder(context, currentFieldName, "string");
if (builder == null) {