Skip to content

Moving ScoreFunctionBuilders under VersionedNamedWriteable #83358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.elasticsearch.search.functionscore;

import org.apache.lucene.search.Explanation;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionFuture;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
Expand Down Expand Up @@ -134,6 +135,11 @@ public DecayFunction getDecayFunction() {
return decayFunction;
}

@Override
public Version getMinimalSupportedVersion() {
return Version.V_EMPTY;
}

private static final DecayFunction decayFunction = new LinearMultScoreFunction();

private static class LinearMultScoreFunction implements DecayFunction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.elasticsearch.index.query.functionscore;

import org.apache.lucene.search.Explanation;
import org.elasticsearch.Version;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.StreamInput;

Expand Down Expand Up @@ -80,4 +81,9 @@ public boolean equals(Object obj) {
return obj != null && getClass() != obj.getClass();
}
}

@Override
public Version getMinimalSupportedVersion() {
return Version.V_EMPTY;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.elasticsearch.index.query.functionscore;

import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.Version;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
Expand Down Expand Up @@ -130,6 +131,11 @@ protected int doHashCode() {
return Objects.hash(this.field, this.factor, this.missing, this.modifier);
}

@Override
public Version getMinimalSupportedVersion() {
return Version.V_EMPTY;
}

@Override
protected ScoreFunction doToFunction(SearchExecutionContext context) {
IndexNumericFieldData fieldData = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.elasticsearch.index.query.functionscore;

import org.apache.lucene.search.Explanation;
import org.elasticsearch.Version;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.xcontent.ParseField;
Expand Down Expand Up @@ -50,6 +51,11 @@ public DecayFunction getDecayFunction() {
return GAUSS_DECAY_FUNCTION;
}

@Override
public Version getMinimalSupportedVersion() {
return Version.V_EMPTY;
}

private static final class GaussScoreFunction implements DecayFunction {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.elasticsearch.index.query.functionscore;

import org.apache.lucene.search.Explanation;
import org.elasticsearch.Version;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.StreamInput;

Expand Down Expand Up @@ -48,6 +49,11 @@ public DecayFunction getDecayFunction() {
return LINEAR_DECAY_FUNCTION;
}

@Override
public Version getMinimalSupportedVersion() {
return Version.V_EMPTY;
}

private static final class LinearDecayScoreFunction implements DecayFunction {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
package org.elasticsearch.index.query.functionscore;

import org.elasticsearch.Version;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
Expand Down Expand Up @@ -173,6 +174,11 @@ private static int hash(long value) {
return Long.hashCode(value);
}

@Override
public Version getMinimalSupportedVersion() {
return Version.V_EMPTY;
}

public static RandomScoreFunctionBuilder fromXContent(XContentParser parser) throws IOException, ParsingException {
RandomScoreFunctionBuilder randomScoreFunctionBuilder = new RandomScoreFunctionBuilder();
String currentFieldName = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

package org.elasticsearch.index.query.functionscore;

import org.elasticsearch.common.io.stream.NamedWriteable;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.VersionedNamedWriteable;
import org.elasticsearch.common.lucene.search.function.ScoreFunction;
import org.elasticsearch.common.lucene.search.function.WeightFactorFunction;
import org.elasticsearch.index.query.SearchExecutionContext;
Expand All @@ -20,7 +20,7 @@
import java.io.IOException;
import java.util.Objects;

public abstract class ScoreFunctionBuilder<FB extends ScoreFunctionBuilder<FB>> implements ToXContentFragment, NamedWriteable {
public abstract class ScoreFunctionBuilder<FB extends ScoreFunctionBuilder<FB>> implements ToXContentFragment, VersionedNamedWriteable {

private Float weight;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.elasticsearch.index.query.functionscore;

import org.elasticsearch.Version;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
Expand Down Expand Up @@ -79,6 +80,11 @@ protected int doHashCode() {
return Objects.hash(this.script);
}

@Override
public Version getMinimalSupportedVersion() {
return Version.V_EMPTY;
}

@Override
protected ScoreFunction doToFunction(SearchExecutionContext context) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.elasticsearch.index.query.functionscore;

import org.elasticsearch.Version;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.lucene.search.function.ScoreFunction;
Expand Down Expand Up @@ -55,6 +56,11 @@ protected int doHashCode() {
return 0;
}

@Override
public Version getMinimalSupportedVersion() {
return Version.V_EMPTY;
}

@Override
protected ScoreFunction doToFunction(SearchExecutionContext context) throws IOException {
// nothing to do here, weight will be applied by the parent class, no score function
Expand Down