Class RandomScoreFunctionBuilder
- java.lang.Object
-
- org.elasticsearch.index.query.functionscore.ScoreFunctionBuilder<RandomScoreFunctionBuilder>
-
- org.elasticsearch.index.query.functionscore.RandomScoreFunctionBuilder
-
- All Implemented Interfaces:
NamedWriteable
,Writeable
,ToXContent
,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
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
Nested 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.String
NAME
-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Constructor Summary
Constructors Constructor Description RandomScoreFunctionBuilder()
RandomScoreFunctionBuilder(StreamInput in)
Read from a stream.
-
Method Summary
Modifier and Type Method Description protected boolean
doEquals(RandomScoreFunctionBuilder functionBuilder)
Check that two instances of the same subclass of ScoreFunctionBuilder are equal.protected int
doHashCode()
Hashcode for fields defined in this subclass of ScoreFunctionBuilder.protected ScoreFunction
doToFunction(QueryShardContext context)
Build the Lucene ScoreFunction for this builder.protected void
doWriteTo(StreamOutput out)
Write the subclass's components into the stream.void
doXContent(XContentBuilder builder, ToXContent.Params params)
Convert this subclass's data into XContent.static RandomScoreFunctionBuilder
fromXContent(XContentParser parser)
java.lang.String
getField()
Get the field to use for random number generation.java.lang.String
getName()
The name of this score function.java.lang.Integer
getSeed()
RandomScoreFunctionBuilder
seed(int seed)
Sets the seed based on which the random number will be generated.RandomScoreFunctionBuilder
seed(long seed)
seed variant taking a long value.RandomScoreFunctionBuilder
seed(java.lang.String seed)
seed variant taking a String value.RandomScoreFunctionBuilder
setField(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
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment
isFragment
-
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RandomScoreFunctionBuilder
public RandomScoreFunctionBuilder()
-
RandomScoreFunctionBuilder
public RandomScoreFunctionBuilder(StreamInput in) throws java.io.IOException
Read from a stream.- Throws:
java.io.IOException
-
-
Method Detail
-
doWriteTo
protected void doWriteTo(StreamOutput out) throws java.io.IOException
Description copied from class:ScoreFunctionBuilder
Write the subclass's components into the stream.- Specified by:
doWriteTo
in classScoreFunctionBuilder<RandomScoreFunctionBuilder>
- Throws:
java.io.IOException
-
getName
public java.lang.String getName()
Description copied from class:ScoreFunctionBuilder
The name of this score function.- Specified by:
getName
in classScoreFunctionBuilder<RandomScoreFunctionBuilder>
-
seed
public RandomScoreFunctionBuilder seed(int 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
public RandomScoreFunctionBuilder seed(long seed)
seed variant taking a long value.- See Also:
seed(int)
-
seed
public RandomScoreFunctionBuilder seed(java.lang.String seed)
seed variant taking a String value.- See Also:
seed(int)
-
getSeed
public java.lang.Integer getSeed()
-
setField
public RandomScoreFunctionBuilder setField(java.lang.String field)
Set the field to be used for random number generation. This parameter is compulsory when aseed
is 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(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
Description copied from class:ScoreFunctionBuilder
Convert this subclass's data into XContent.- Specified by:
doXContent
in classScoreFunctionBuilder<RandomScoreFunctionBuilder>
- Throws:
java.io.IOException
-
doEquals
protected boolean doEquals(RandomScoreFunctionBuilder functionBuilder)
Description copied from class:ScoreFunctionBuilder
Check 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:
doEquals
in classScoreFunctionBuilder<RandomScoreFunctionBuilder>
-
doHashCode
protected int doHashCode()
Description copied from class:ScoreFunctionBuilder
Hashcode 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:
doHashCode
in classScoreFunctionBuilder<RandomScoreFunctionBuilder>
-
doToFunction
protected ScoreFunction doToFunction(QueryShardContext context)
Description copied from class:ScoreFunctionBuilder
Build 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:
doToFunction
in classScoreFunctionBuilder<RandomScoreFunctionBuilder>
-
fromXContent
public static RandomScoreFunctionBuilder fromXContent(XContentParser parser) throws java.io.IOException, ParsingException
- Throws:
java.io.IOException
ParsingException
-
-