Skip to content
Draft
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
14 changes: 14 additions & 0 deletions solr/modules/ltr/src/java/org/apache/solr/ltr/feature/Feature.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.solr.ltr.feature;

import java.io.IOException;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;

Expand Down Expand Up @@ -367,6 +368,19 @@ public DocIdSetIterator iterator() {
// because it doesn't always work and we don't yet know why, please see
// SOLR-15071 for more details.

@Override
public float smoothingScore(int docId) throws IOException {
return in.smoothingScore(docId);
}

public void setMinCompetitiveScore(float minScore) throws IOException {
in.setMinCompetitiveScore(minScore);
}

public Collection<ChildScorable> getChildren() throws IOException {
return in.getChildren();
}

@Override
public int advanceShallow(int target) throws IOException {
return in.advanceShallow(target);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.lang.reflect.Method;

import org.apache.lucene.search.Scorable;
import org.apache.lucene.search.Scorer;
import org.apache.solr.SolrTestCase;
import org.junit.Test;
Expand All @@ -26,16 +27,24 @@ public class TestFeature extends SolrTestCase {

@Test
public void testFilterFeatureScorerOverridesScorerMethods() {
implTestFilterFeatureScorerOverridesMethods(Scorer.class.getDeclaredMethods());
}

@Test
public void testFilterFeatureScorerOverridesScorableMethods() {
implTestFilterFeatureScorerOverridesMethods(Scorable.class.getDeclaredMethods());
}

public void implTestFilterFeatureScorerOverridesMethods(Method[] scorerClassMethods) {
final Class<?> ffsClass = Feature.FeatureWeight.FilterFeatureScorer.class;
for (final Method scorerClassMethod : Scorer.class.getDeclaredMethods()) {
for (final Method scorerClassMethod : scorerClassMethods) {
try {
// classes deriving from FilterFeatureScorer implement the score method
if (scorerClassMethod.getName().equals("score")) continue;

// the FilterFeatureScorer may simply inherit Scorer's default implementation
if (scorerClassMethod.getName().equals("twoPhaseIterator")) continue;

// the FilterFeatureScorer may simply inherit Scorer's default implementation
if (scorerClassMethod.getName().equals("smoothingScore")) continue;

// the FilterFeatureScorer's implementation does not influence its parent Weight
if (scorerClassMethod.getName().equals("getWeight")) continue;

Expand Down