@@ -16,104 +16,76 @@ public FunctionScoreFunctionsDescriptor()
1616 this . _Functions = new List < FunctionScoreFunction < T > > ( ) ;
1717 }
1818
19- public FunctionScoreFunction < T > Gauss ( Expression < Func < T , object > > objectPath , Action < FunctionScoreDecayFieldDescriptor > db )
19+ public FunctionScoreFunction < T > Gauss ( string field , Action < FunctionScoreDecayFieldDescriptor > descriptorBuilder )
2020 {
21- var fn = new GaussFunction < T > ( objectPath , db ) ;
21+ var fn = new GaussFunction < T > ( field , descriptorBuilder ) ;
2222 this . _Functions . Add ( fn ) ;
2323 return fn ;
2424 }
2525
26- public FunctionScoreFunction < T > Linear ( Expression < Func < T , object > > objectPath , Action < FunctionScoreDecayFieldDescriptor > db )
26+ public FunctionScoreFunction < T > Gauss ( Expression < Func < T , object > > objectPath , Action < FunctionScoreDecayFieldDescriptor > descriptorBuilder )
2727 {
28- var fn = new LinearFunction < T > ( objectPath , db ) ;
28+ var fn = new GaussFunction < T > ( objectPath , descriptorBuilder ) ;
2929 this . _Functions . Add ( fn ) ;
3030 return fn ;
3131 }
3232
33- public FunctionScoreFunction < T > Exp ( Expression < Func < T , object > > objectPath , Action < FunctionScoreDecayFieldDescriptor > db )
33+ public FunctionScoreFunction < T > Linear ( string field , Action < FunctionScoreDecayFieldDescriptor > descriptorBuilder )
3434 {
35- var fn = new ExpFunction < T > ( objectPath , db ) ;
35+ var fn = new LinearFunction < T > ( field , descriptorBuilder ) ;
3636 this . _Functions . Add ( fn ) ;
3737 return fn ;
3838 }
3939
40- public BoostFactorFunction < T > BoostFactor ( double value )
40+ public FunctionScoreFunction < T > Linear ( Expression < Func < T , object > > objectPath , Action < FunctionScoreDecayFieldDescriptor > descriptorBuilder )
4141 {
42- var fn = new BoostFactorFunction < T > ( value ) ;
42+ var fn = new LinearFunction < T > ( objectPath , descriptorBuilder ) ;
4343 this . _Functions . Add ( fn ) ;
4444 return fn ;
4545 }
4646
47- public ScriptScoreFunction < T > ScriptScore ( Action < ScriptFilterDescriptor > scriptSelector )
47+ public FunctionScoreFunction < T > Exp ( string field , Action < FunctionScoreDecayFieldDescriptor > descriptorBuilder )
4848 {
49- var fn = new ScriptScoreFunction < T > ( scriptSelector ) ;
49+ var fn = new ExpFunction < T > ( field , descriptorBuilder ) ;
5050 this . _Functions . Add ( fn ) ;
5151 return fn ;
5252 }
5353
54- public FieldValueFactor < T > FieldValueFactor ( Action < FieldValueFactorDescriptor < T > > db )
54+ public FunctionScoreFunction < T > Exp ( Expression < Func < T , object > > objectPath , Action < FunctionScoreDecayFieldDescriptor > descriptorBuilder )
5555 {
56- var fn = new FieldValueFactor < T > ( db ) ;
56+ var fn = new ExpFunction < T > ( objectPath , descriptorBuilder ) ;
5757 this . _Functions . Add ( fn ) ;
5858 return fn ;
5959 }
60- public IEnumerator < FunctionScoreFunction < T > > GetEnumerator ( )
61- {
62- return _Functions . GetEnumerator ( ) ;
63- }
6460
65- IEnumerator IEnumerable . GetEnumerator ( )
61+ public FunctionScoreFunction < T > BoostFactor ( double value )
6662 {
67- return _Functions . GetEnumerator ( ) ;
63+ var fn = new BoostFactorFunction < T > ( value ) ;
64+ this . _Functions . Add ( fn ) ;
65+ return fn ;
6866 }
69- }
70-
71-
72- public class FieldValueFactorDescriptor < T >
73- {
74- [ JsonProperty ( "field" ) ]
75- internal PropertyPathMarker _Field { get ; set ; }
7667
77- [ JsonProperty ( "factor" ) ]
78- internal double ? _Factor { get ; set ; }
79-
80- [ JsonProperty ( "modifier" ) ]
81- [ JsonConverter ( typeof ( StringEnumConverter ) ) ]
82- internal FieldValueFactorModifier ? _Modifier { get ; set ; }
83-
84- public FieldValueFactorDescriptor < T > Field ( Expression < Func < T , object > > field )
68+ public FunctionScoreFunction < T > ScriptScore ( Action < ScriptFilterDescriptor > scriptSelector )
8569 {
86- this . _Field = field ;
87- return this ;
70+ var fn = new ScriptScoreFunction < T > ( scriptSelector ) ;
71+ this . _Functions . Add ( fn ) ;
72+ return fn ;
8873 }
8974
90- public FieldValueFactorDescriptor < T > Factor ( double factor )
75+ public FunctionScoreFunction < T > FieldValueFactor ( Action < FieldValueFactorDescriptor < T > > db )
9176 {
92- this . _Factor = factor ;
93- return this ;
77+ var fn = new FieldValueFactor < T > ( db ) ;
78+ this . _Functions . Add ( fn ) ;
79+ return fn ;
9480 }
95-
96- public FieldValueFactorDescriptor < T > Modifier ( FieldValueFactorModifier modifier )
81+ public IEnumerator < FunctionScoreFunction < T > > GetEnumerator ( )
9782 {
98- this . _Modifier = modifier ;
99- return this ;
83+ return _Functions . GetEnumerator ( ) ;
10084 }
101- }
102-
103- [ JsonObject ( MemberSerialization = MemberSerialization . OptIn ) ]
104- public class FieldValueFactor < T > : FunctionScoreFilteredFunction < T > where T : class
105- {
106- [ JsonProperty ( PropertyName = "field_value_factor" ) ]
107- internal FieldValueFactorDescriptor < T > _FieldValueFactor { get ; set ; }
10885
109- public FieldValueFactor ( Action < FieldValueFactorDescriptor < T > > descriptorBuilder )
86+ IEnumerator IEnumerable . GetEnumerator ( )
11087 {
111- var descriptor = new FieldValueFactorDescriptor < T > ( ) ;
112- descriptorBuilder ( descriptor ) ;
113- if ( descriptor . _Field . IsConditionless ( ) )
114- throw new DslException ( "Field name not set for field value factor function" ) ;
115-
116- this . _FieldValueFactor = descriptor ;
88+ return _Functions . GetEnumerator ( ) ;
11789 }
11890 }
11991}
0 commit comments