From c69b94d76923d025a6554b01b81005d35352ced9 Mon Sep 17 00:00:00 2001 From: kimchy Date: Mon, 8 Nov 2010 11:07:34 +0200 Subject: [PATCH] rename field to path in _analyzer mapping --- .../index/mapper/xcontent/AnalyzerMapper.java | 20 +++++++++---------- .../XContentDocumentMapperParser.java | 2 +- .../analyzer/AnalyzerMapperTests.java | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/AnalyzerMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/AnalyzerMapper.java index b66d129bf14..cb78b5959bf 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/AnalyzerMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/AnalyzerMapper.java @@ -60,7 +60,7 @@ public class AnalyzerMapper implements XContentMapper { // for (Map.Entry entry : node.entrySet()) { // String fieldName = Strings.toUnderscoreCase(entry.getKey()); // Object fieldNode = entry.getValue(); -// if ("field".equals(fieldName)) { +// if ("path".equals(fieldName)) { // builder.field(fieldNode.toString()); // } // } @@ -68,10 +68,10 @@ public class AnalyzerMapper implements XContentMapper { // } // } - private final String field; + private final String path; - public AnalyzerMapper(String field) { - this.field = field; + public AnalyzerMapper(String path) { + this.path = path; } @Override public String name() { @@ -80,12 +80,12 @@ public class AnalyzerMapper implements XContentMapper { @Override public void parse(ParseContext context) throws IOException { Analyzer analyzer = context.docMapper().mappers().indexAnalyzer(); - if (field != null) { - String value = context.doc().get(field); + if (path != null) { + String value = context.doc().get(path); if (value != null) { analyzer = context.analysisService().analyzer(value); if (analyzer == null) { - throw new MapperParsingException("No analyzer found for [" + value + "] from field [" + field + "]"); + throw new MapperParsingException("No analyzer found for [" + value + "] from path [" + path + "]"); } analyzer = context.docMapper().mappers().indexAnalyzer(analyzer); } @@ -100,12 +100,12 @@ public class AnalyzerMapper implements XContentMapper { } @Override public void toXContent(XContentBuilder builder, Params params) throws IOException { - if (field == null) { + if (path == null) { return; } builder.startObject(CONTENT_TYPE); - if (field != null) { - builder.field("field", field); + if (path != null) { + builder.field("path", path); } builder.endObject(); } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDocumentMapperParser.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDocumentMapperParser.java index f950cb15db0..aa1ed51c3a8 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDocumentMapperParser.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDocumentMapperParser.java @@ -216,7 +216,7 @@ public class XContentDocumentMapperParser extends AbstractIndexComponent impleme for (Map.Entry entry : analyzerNode.entrySet()) { String fieldName = Strings.toUnderscoreCase(entry.getKey()); Object fieldNode = entry.getValue(); - if (fieldName.equals("field")) { + if (fieldName.equals("path")) { builder.field(fieldNode.toString()); } } diff --git a/modules/elasticsearch/src/test/java/org/elasticsearch/index/mapper/xcontent/analyzer/AnalyzerMapperTests.java b/modules/elasticsearch/src/test/java/org/elasticsearch/index/mapper/xcontent/analyzer/AnalyzerMapperTests.java index b00a7e70ff8..c25d697b196 100644 --- a/modules/elasticsearch/src/test/java/org/elasticsearch/index/mapper/xcontent/analyzer/AnalyzerMapperTests.java +++ b/modules/elasticsearch/src/test/java/org/elasticsearch/index/mapper/xcontent/analyzer/AnalyzerMapperTests.java @@ -37,7 +37,7 @@ public class AnalyzerMapperTests { @Test public void testLatLonValues() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") - .startObject("_analyzer").field("field", "field_analyzer").endObject() + .startObject("_analyzer").field("path", "field_analyzer").endObject() .startObject("properties") .startObject("field_analyzer").field("type", "string").endObject() .startObject("field1").field("type", "string").endObject()