rename field to path in _analyzer mapping
This commit is contained in:
parent
c9228ed26d
commit
c69b94d769
|
@ -60,7 +60,7 @@ public class AnalyzerMapper implements XContentMapper {
|
|||
// for (Map.Entry<String, Object> 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();
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ public class XContentDocumentMapperParser extends AbstractIndexComponent impleme
|
|||
for (Map.Entry<String, Object> 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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue