public abstract class DecayFunctionParser<DFB extends DecayFunctionBuilder<DFB>> extends java.lang.Object implements ScoreFunctionParser<DFB>
{
"fieldname1" : {
"origin" = "someValue",
"scale" = "someValue"
},
"multi_value_mode" : "min"
}
"origin" here refers to the reference point and "scale" to the level of
uncertainty you have in your origin.
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 scoring function, create a new class that inherits from this
one and implements ScoreFunctionParser.getBuilderPrototype()
and ScoreFunctionParser.getNames()
.
Also create its corresponding DecayFunctionBuilder
. The latter needs to
implement DecayFunctionBuilder.doReadFrom(StreamInput)
and
DecayFunctionBuilder.doWriteTo(StreamOutput)
for serialization purposes,
DecayFunctionBuilder.doEquals(DecayFunctionBuilder)
and
DecayFunctionBuilder.doHashCode()
for equality checks,
ScoreFunctionBuilder.getName()
that returns the name of the function and
DecayFunctionBuilder.getDecayFunction()
which returns the corresponding lucene function.
See GaussDecayFunctionBuilder
and GaussDecayFunctionParser
for an example. The parser furthermore needs to be registered in the
SearchModule
.
Modifier and Type | Field and Description |
---|---|
static ParseField |
MULTI_VALUE_MODE |
Constructor and Description |
---|
DecayFunctionParser() |
Modifier and Type | Method and Description |
---|---|
DFB |
fromXContent(QueryParseContext context,
XContentParser parser)
Parses bodies of the kind
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getBuilderPrototype, getNames
public static final ParseField MULTI_VALUE_MODE
public DFB fromXContent(QueryParseContext context, XContentParser parser) throws java.io.IOException, ParsingException
{
"fieldname1" : {
"origin" : "someValue",
"scale" : "someValue"
},
"multi_value_mode" : "min"
}
fromXContent
in interface ScoreFunctionParser<DFB extends DecayFunctionBuilder<DFB>>
java.io.IOException
ParsingException