From 15bdba30e5901361a0408d8e8b4068bef66169ec Mon Sep 17 00:00:00 2001 From: kimchy Date: Sat, 3 Apr 2010 21:07:01 +0300 Subject: [PATCH] allow for _ separator on top of camel case for mapping definitions --- .../mapper/json/JsonBooleanFieldMapper.java | 2 +- .../index/mapper/json/JsonDateFieldMapper.java | 2 +- .../index/mapper/json/JsonDoubleFieldMapper.java | 2 +- .../index/mapper/json/JsonFloatFieldMapper.java | 2 +- .../index/mapper/json/JsonObjectMapper.java | 6 +++--- .../index/mapper/json/JsonShortFieldMapper.java | 2 +- .../index/mapper/json/JsonTypeParsers.java | 16 ++++++++-------- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonBooleanFieldMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonBooleanFieldMapper.java index 0d26c7d543a..ddcab94a0c6 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonBooleanFieldMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonBooleanFieldMapper.java @@ -103,7 +103,7 @@ public class JsonBooleanFieldMapper extends JsonFieldMapper { Map.Entry entry = propsIt.next(); String propName = entry.getKey(); JsonNode propNode = entry.getValue(); - if (propName.equals("nullValue")) { + if (propName.equals("nullValue") || propName.equals("null_value")) { builder.nullValue(nodeBooleanValue(propNode)); } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonDateFieldMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonDateFieldMapper.java index 775b744ef98..8a109ab3bda 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonDateFieldMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonDateFieldMapper.java @@ -92,7 +92,7 @@ public class JsonDateFieldMapper extends JsonNumberFieldMapper { Map.Entry entry = propsIt.next(); String propName = entry.getKey(); JsonNode propNode = entry.getValue(); - if (propName.equals("nullValue")) { + if (propName.equals("nullValue") || propName.equals("null_value")) { builder.nullValue(propNode.getValueAsText()); } else if (propName.equals("format")) { builder.dateTimeFormatter(parseDateTimeFormatter(propName, propNode)); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonDoubleFieldMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonDoubleFieldMapper.java index 03e652c724e..26df95b1831 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonDoubleFieldMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonDoubleFieldMapper.java @@ -82,7 +82,7 @@ public class JsonDoubleFieldMapper extends JsonNumberFieldMapper { Map.Entry entry = propsIt.next(); String propName = entry.getKey(); JsonNode propNode = entry.getValue(); - if (propName.equals("nullValue")) { + if (propName.equals("nullValue") || propName.equals("null_value")) { builder.nullValue(nodeDoubleValue(propNode)); } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonFloatFieldMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonFloatFieldMapper.java index c6f9c6b470b..d4b92454b50 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonFloatFieldMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonFloatFieldMapper.java @@ -82,7 +82,7 @@ public class JsonFloatFieldMapper extends JsonNumberFieldMapper { Map.Entry entry = propsIt.next(); String propName = entry.getKey(); JsonNode propNode = entry.getValue(); - if (propName.equals("nullValue")) { + if (propName.equals("nullValue") || propName.equals("null_value")) { builder.nullValue(nodeFloatValue(propNode)); } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonObjectMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonObjectMapper.java index b4c9fde8c6a..0f8492a0423 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonObjectMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonObjectMapper.java @@ -169,7 +169,7 @@ public class JsonObjectMapper implements JsonMapper, JsonIncludeInAllMapper { if (!type.equals("object")) { throw new MapperParsingException("Trying to parse an object but has a different type [" + type + "] for [" + name + "]"); } - } else if (fieldName.equals("dateFormats")) { + } else if (fieldName.equals("dateFormats") || fieldName.equals("date_formats")) { List dateTimeFormatters = newArrayList(); if (fieldNode.isArray()) { for (JsonNode node1 : (ArrayNode) fieldNode) { @@ -187,11 +187,11 @@ public class JsonObjectMapper implements JsonMapper, JsonIncludeInAllMapper { } } else if (fieldName.equals("enabled")) { builder.enabled(nodeBooleanValue(fieldNode)); - } else if (fieldName.equals("pathType")) { + } else if (fieldName.equals("pathType") || fieldName.equals("path_type")) { builder.pathType(parsePathType(name, fieldNode.getValueAsText())); } else if (fieldName.equals("properties")) { parseProperties(builder, (ObjectNode) fieldNode, parserContext); - } else if (fieldName.equals("includeInAll")) { + } else if (fieldName.equals("includeInAll") || fieldName.equals("include_in_all")) { builder.includeInAll(nodeBooleanValue(fieldNode)); } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonShortFieldMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonShortFieldMapper.java index 11ba6b1b258..32e7801834f 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonShortFieldMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonShortFieldMapper.java @@ -82,7 +82,7 @@ public class JsonShortFieldMapper extends JsonNumberFieldMapper { Map.Entry entry = propsIt.next(); String propName = entry.getKey(); JsonNode propNode = entry.getValue(); - if (propName.equals("nullValue")) { + if (propName.equals("nullValue") || propName.equals("null_value")) { builder.nullValue(nodeShortValue(propNode)); } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonTypeParsers.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonTypeParsers.java index 9385ca5b241..7e2ba49127c 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonTypeParsers.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/json/JsonTypeParsers.java @@ -42,7 +42,7 @@ public class JsonTypeParsers { Map.Entry entry = propsIt.next(); String propName = entry.getKey(); JsonNode propNode = entry.getValue(); - if (propName.equals("precisionStep")) { + if (propName.equals("precisionStep") || propName.equals("precision_step")) { builder.precisionStep(nodeIntegerValue(propNode)); } } @@ -53,28 +53,28 @@ public class JsonTypeParsers { Map.Entry entry = propsIt.next(); String propName = entry.getKey(); JsonNode propNode = entry.getValue(); - if (propName.equals("indexName")) { + if (propName.equals("indexName") || propName.equals("index_name")) { builder.indexName(propNode.getTextValue()); } else if (propName.equals("store")) { builder.store(parseStore(name, propNode.getTextValue())); } else if (propName.equals("index")) { builder.index(parseIndex(name, propNode.getTextValue())); - } else if (propName.equals("termVector")) { + } else if (propName.equals("termVector") || propName.equals("term_vector")) { builder.termVector(parseTermVector(name, propNode.getTextValue())); } else if (propName.equals("boost")) { builder.boost(nodeFloatValue(propNode)); - } else if (propName.equals("omitNorms")) { + } else if (propName.equals("omitNorms") || propName.equals("omit_norms")) { builder.omitNorms(nodeBooleanValue(propNode)); - } else if (propName.equals("omitTermFreqAndPositions")) { + } else if (propName.equals("omitTermFreqAndPositions") || propName.equals("omit_termFreq_and_positions")) { builder.omitTermFreqAndPositions(nodeBooleanValue(propNode)); - } else if (propName.equals("indexAnalyzer")) { + } else if (propName.equals("indexAnalyzer") || propName.equals("index_analyzer")) { builder.indexAnalyzer(parserContext.analysisService().analyzer(propNode.getTextValue())); - } else if (propName.equals("searchAnalyzer")) { + } else if (propName.equals("searchAnalyzer") || propName.equals("search_analyzer")) { builder.searchAnalyzer(parserContext.analysisService().analyzer(propNode.getTextValue())); } else if (propName.equals("analyzer")) { builder.indexAnalyzer(parserContext.analysisService().analyzer(propNode.getTextValue())); builder.searchAnalyzer(parserContext.analysisService().analyzer(propNode.getTextValue())); - } else if (propName.equals("includeInAll")) { + } else if (propName.equals("includeInAll") || propName.equals("include_in_all")) { builder.includeInAll(nodeBooleanValue(propNode)); } }