23
23
import org .opensearch .index .query .DerivedFieldQuery ;
24
24
import org .opensearch .index .query .QueryShardContext ;
25
25
import org .opensearch .script .DerivedFieldScript ;
26
- import org .opensearch .script .Script ;
27
26
import org .opensearch .search .lookup .SearchLookup ;
28
27
29
28
import java .io .IOException ;
40
39
*/
41
40
@ PublicApi (since = "2.14.0" )
42
41
public final class DerivedFieldType extends MappedFieldType {
43
- private final String type ;
44
42
45
- private final Script script ;
43
+ private final DerivedField derivedField ;
46
44
47
45
FieldMapper typeFieldMapper ;
48
46
49
47
final Function <Object , IndexableField > indexableFieldGenerator ;
50
48
51
49
public DerivedFieldType (
52
- String name ,
53
- String type ,
54
- Script script ,
50
+ DerivedField derivedField ,
55
51
boolean isIndexed ,
56
52
boolean isStored ,
57
53
boolean hasDocValues ,
58
54
Map <String , String > meta ,
59
55
FieldMapper typeFieldMapper ,
60
56
Function <Object , IndexableField > fieldFunction
61
57
) {
62
- super (name , isIndexed , isStored , hasDocValues , typeFieldMapper .fieldType ().getTextSearchInfo (), meta );
63
- this .type = type ;
64
- this .script = script ;
58
+ super (derivedField .getName (), isIndexed , isStored , hasDocValues , typeFieldMapper .fieldType ().getTextSearchInfo (), meta );
59
+ this .derivedField = derivedField ;
65
60
this .typeFieldMapper = typeFieldMapper ;
66
61
this .indexableFieldGenerator = fieldFunction ;
67
62
}
68
63
69
- public DerivedFieldType (
70
- String name ,
71
- String type ,
72
- Script script ,
73
- FieldMapper typeFieldMapper ,
74
- Function <Object , IndexableField > fieldFunction
75
- ) {
76
- this (name , type , script , false , false , false , Collections .emptyMap (), typeFieldMapper , fieldFunction );
64
+ public DerivedFieldType (DerivedField derivedField , FieldMapper typeFieldMapper , Function <Object , IndexableField > fieldFunction ) {
65
+ this (derivedField , false , false , false , Collections .emptyMap (), typeFieldMapper , fieldFunction );
77
66
}
78
67
79
68
@ Override
@@ -82,7 +71,7 @@ public String typeName() {
82
71
}
83
72
84
73
public String getType () {
85
- return type ;
74
+ return derivedField . getType () ;
86
75
}
87
76
88
77
public NamedAnalyzer getIndexAnalyzer () {
@@ -280,7 +269,7 @@ private DerivedFieldScript.LeafFactory getDerivedFieldLeafFactory(QueryShardCont
280
269
+ "]"
281
270
);
282
271
}
283
- DerivedFieldScript .Factory factory = context .compile (script , DerivedFieldScript .CONTEXT );
284
- return factory .newFactory (script .getParams (), context .lookup ());
272
+ DerivedFieldScript .Factory factory = context .compile (derivedField . getScript () , DerivedFieldScript .CONTEXT );
273
+ return factory .newFactory (derivedField . getScript () .getParams (), context .lookup ());
285
274
}
286
275
}
0 commit comments