Class RandomScoreFunctionBuilder
java.lang.Object
org.elasticsearch.index.query.functionscore.ScoreFunctionBuilder<RandomScoreFunctionBuilder>
org.elasticsearch.index.query.functionscore.RandomScoreFunctionBuilder
- All Implemented Interfaces:
NamedWriteable,Writeable,org.elasticsearch.common.xcontent.ToXContent,org.elasticsearch.common.xcontent.ToXContentFragment
public class RandomScoreFunctionBuilder extends ScoreFunctionBuilder<RandomScoreFunctionBuilder>
A function that computes a random score for the matched documents
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
Fields Modifier and Type Field Description static java.lang.StringNAME -
Constructor Summary
Constructors Constructor Description RandomScoreFunctionBuilder()RandomScoreFunctionBuilder(StreamInput in)Read from a stream. -
Method Summary
Modifier and Type Method Description protected booleandoEquals(RandomScoreFunctionBuilder functionBuilder)Check that two instances of the same subclass of ScoreFunctionBuilder are equal.protected intdoHashCode()Hashcode for fields defined in this subclass of ScoreFunctionBuilder.protected ScoreFunctiondoToFunction(QueryShardContext context)Build the Lucene ScoreFunction for this builder.protected voiddoWriteTo(StreamOutput out)Write the subclass's components into the stream.voiddoXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)Convert this subclass's data into XContent.static RandomScoreFunctionBuilderfromXContent(org.elasticsearch.common.xcontent.XContentParser parser)java.lang.StringgetField()Get the field to use for random number generation.java.lang.StringgetName()The name of this score function.java.lang.IntegergetSeed()RandomScoreFunctionBuilderseed(int seed)Sets the seed based on which the random number will be generated.RandomScoreFunctionBuilderseed(long seed)seed variant taking a long value.RandomScoreFunctionBuilderseed(java.lang.String seed)seed variant taking a String value.RandomScoreFunctionBuildersetField(java.lang.String field)Set the field to be used for random number generation.Methods inherited from class org.elasticsearch.index.query.functionscore.ScoreFunctionBuilder
equals, getWeight, getWriteableName, hashCode, setWeight, toFunction, toXContent, writeTo
-
Field Details
-
NAME
public static final java.lang.String NAME- See Also:
- Constant Field Values
-
-
Constructor Details
-
RandomScoreFunctionBuilder
public RandomScoreFunctionBuilder() -
RandomScoreFunctionBuilder
Read from a stream.- Throws:
java.io.IOException
-
-
Method Details
-
doWriteTo
Description copied from class:ScoreFunctionBuilderWrite the subclass's components into the stream.- Specified by:
doWriteToin classScoreFunctionBuilder<RandomScoreFunctionBuilder>- Throws:
java.io.IOException
-
getName
public java.lang.String getName()Description copied from class:ScoreFunctionBuilderThe name of this score function.- Specified by:
getNamein classScoreFunctionBuilder<RandomScoreFunctionBuilder>
-
seed
Sets the seed based on which the random number will be generated. Using the same seed is guaranteed to generate the same random number for a specific doc.- Parameters:
seed- The seed.
-
seed
seed variant taking a long value.- See Also:
seed(int)
-
seed
seed variant taking a String value.- See Also:
seed(int)
-
getSeed
public java.lang.Integer getSeed() -
setField
Set the field to be used for random number generation. This parameter is compulsory when aseedis set and ignored otherwise. Note that documents that have the same value for a field will get the same score. -
getField
public java.lang.String getField()Get the field to use for random number generation.- See Also:
setField(String)
-
doXContent
public void doXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOExceptionDescription copied from class:ScoreFunctionBuilderConvert this subclass's data into XContent.- Specified by:
doXContentin classScoreFunctionBuilder<RandomScoreFunctionBuilder>- Throws:
java.io.IOException
-
doEquals
Description copied from class:ScoreFunctionBuilderCheck that two instances of the same subclass of ScoreFunctionBuilder are equal. Implementers don't need to check any fields in ScoreFunctionBuilder, just fields that they define.- Specified by:
doEqualsin classScoreFunctionBuilder<RandomScoreFunctionBuilder>
-
doHashCode
protected int doHashCode()Description copied from class:ScoreFunctionBuilderHashcode for fields defined in this subclass of ScoreFunctionBuilder. Implementers should ignore fields defined in ScoreFunctionBuilder because they will already be in the hashCode.- Specified by:
doHashCodein classScoreFunctionBuilder<RandomScoreFunctionBuilder>
-
doToFunction
Description copied from class:ScoreFunctionBuilderBuild the Lucene ScoreFunction for this builder. Implementers should ignore things defined in ScoreFunctionBuilder like weight as they will be handled by the function that calls this one.- Specified by:
doToFunctionin classScoreFunctionBuilder<RandomScoreFunctionBuilder>
-
fromXContent
public static RandomScoreFunctionBuilder fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws java.io.IOException, ParsingException- Throws:
java.io.IOExceptionParsingException
-