@@ -22,6 +22,10 @@ protected boolean supportsOrIgnoresBoost() {
22
22
return false ;
23
23
}
24
24
25
+ protected boolean supportsMeta () {
26
+ return false ;
27
+ }
28
+
25
29
// Overriding fieldMapping to make it create derived mappings by default.
26
30
// This way, the parent tests are checking the right behavior for this Mapper.
27
31
@ Override
@@ -43,8 +47,11 @@ protected void registerParameters(ParameterChecker checker) throws IOException {
43
47
// supported for DerivedFieldMapper (we explicitly set these values on initialization)
44
48
}
45
49
46
- // TESTCASE: testDefaults() (no script provided and assuming field is not in the source either)
47
- // TODO: Might not need this (no default that really deviates it from testSerialization()
50
+ // TODO: Can update this once the query implementation is completed
51
+ // This is also being left blank because the super assertExistsQuery is trying to parse
52
+ // an empty source and fails.
53
+ @ Override
54
+ protected void assertExistsQuery (MapperService mapperService ) {}
48
55
49
56
public void testSerialization () throws IOException {
50
57
@@ -60,10 +67,12 @@ public void testSerialization() throws IOException {
60
67
61
68
public void testParsesScript () throws IOException {
62
69
63
- String scriptString = "{ \" source \" : \" doc['test'].value\" } " ;
70
+ String scriptString = "doc['test'].value" ;
64
71
DocumentMapper defaultMapper = createDocumentMapper (fieldMapping (b -> {
65
72
b .field ("type" , "keyword" );
66
- b .field ("script" , scriptString );
73
+ b .startObject ("script" );
74
+ b .field ("source" , scriptString );
75
+ b .endObject ();
67
76
}));
68
77
Mapper mapper = defaultMapper .mappers ().getMapper ("field" );
69
78
assertTrue (mapper instanceof DerivedFieldMapper );
@@ -73,11 +82,11 @@ public void testParsesScript() throws IOException {
73
82
XContentBuilder builder = XContentFactory .jsonBuilder ().startObject ();
74
83
mapper .toXContent (builder , ToXContent .EMPTY_PARAMS );
75
84
builder .endObject ();
76
- assertEquals ("{\" type\" : \" keyword\" ,\" script\" : {\" source\" : \" emit( doc['test'].value) \" }}" , builder .toString ());
85
+ assertEquals ("{\" field \" :{ \" type\" :\" keyword\" ,\" script\" :{\" source\" :\" doc['test'].value\" , \" lang \" : \" painless \" } }}" , builder .toString ());
77
86
}
78
87
79
88
// TODO: Is there a case where we want to allow the field to be defined in both 'derived' and 'properties'?
80
- // If the user wants to move a field they were testing as derived to be indexed they should be able to update
89
+ // If the user wants to move a field they were testing as derived to be indexed, they should be able to update
81
90
// the mappings in index template to move the field from 'derived' to 'properties' and it should take affect
82
91
// during the next index rollover (so even in this case, the field is only defined in one or the other).
83
92
public void testFieldInDerivedAndProperties () throws IOException {
@@ -96,8 +105,11 @@ public void testFieldInDerivedAndProperties() throws IOException {
96
105
b .endObject ();
97
106
}))
98
107
);
108
+ // TODO: Do we want to handle this as a different error? As it stands, it fails as a merge conflict which makes sense.
109
+ // If it didn't fail here, it would hit the MapperParsingException for the field being defined more than once
110
+ // when MappingLookup is initialized
99
111
assertEquals (
100
- "Field [ field] is defined more than once " ,
112
+ "Failed to parse mapping [_doc]: mapper [ field] cannot be changed from type [derived_field] to [keyword] " ,
101
113
ex .getMessage ()
102
114
);
103
115
}
0 commit comments