Class DecayFunctionParser<DFB extends DecayFunctionBuilder<DFB>>
- java.lang.Object
-
- org.elasticsearch.index.query.functionscore.DecayFunctionParser<DFB>
-
- All Implemented Interfaces:
ScoreFunctionParser<DFB>
public final class DecayFunctionParser<DFB extends DecayFunctionBuilder<DFB>> extends java.lang.Object implements ScoreFunctionParser<DFB>
Parser used for all decay functions, one instance each. It parses this kind of input:{ "fieldname1" : { "origin" = "someValue", "scale" = "someValue" }, "multi_value_mode" : "min" }
For example, you might want to retrieve an event that took place around the 20 May 2010 somewhere near Berlin. You are mainly interested in events that are close to the 20 May 2010 but you are unsure about your guess, maybe it was a week before or after that. Your "origin" for the date field would be "20 May 2010" and your "scale" would be "7d".
This class parses the input and creates a scoring function from the parameters origin and scale.
To write a new decay scoring function, create a new class that extends
DecayFunctionBuilder
, setup a PARSER field with this class, and register them inSearchModule.registerScoreFunctions(java.util.List<org.elasticsearch.plugins.SearchPlugin>)
orSearchPlugin.getScoreFunctions()
SeeGaussDecayFunctionBuilder.PARSER
for an example.
-
-
Field Summary
Fields Modifier and Type Field Description static ParseField
MULTI_VALUE_MODE
-
Constructor Summary
Constructors Constructor Description DecayFunctionParser(java.util.function.BiFunction<java.lang.String,BytesReference,DFB> createFromBytes)
Create the parser using a method reference to a "create from bytes" constructor for the DecayFunctionBuilder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DFB
fromXContent(XContentParser parser)
Parses bodies of the kind
-
-
-
Field Detail
-
MULTI_VALUE_MODE
public static final ParseField MULTI_VALUE_MODE
-
-
Constructor Detail
-
DecayFunctionParser
public DecayFunctionParser(java.util.function.BiFunction<java.lang.String,BytesReference,DFB> createFromBytes)
Create the parser using a method reference to a "create from bytes" constructor for the DecayFunctionBuilder. We use a method reference here so each use of this class doesn't have to subclass it.
-
-
Method Detail
-
fromXContent
public DFB fromXContent(XContentParser parser) throws java.io.IOException, ParsingException
Parses bodies of the kind{ "fieldname1" : { "origin" : "someValue", "scale" : "someValue" }, "multi_value_mode" : "min" }
- Specified by:
fromXContent
in interfaceScoreFunctionParser<DFB extends DecayFunctionBuilder<DFB>>
- Throws:
java.io.IOException
ParsingException
-
-