SOLR-11931: contrib/ltr tests: s/getCanonicalName/getName

This commit is contained in:
Christine Poerschke 2018-02-09 18:09:26 +00:00
parent a1a9341a9c
commit 1a6d0f585f
26 changed files with 122 additions and 122 deletions

View File

@ -262,26 +262,26 @@ public class TestLTROnSolrCloud extends TestRerankBase {
loadFeature(
featureNames[0],
SolrFeature.class.getCanonicalName(),
SolrFeature.class.getName(),
featureStore,
"{\"q\":\"{!func}pow(popularity,2)\"}"
);
loadFeature(
featureNames[1],
ValueFeature.class.getCanonicalName(),
ValueFeature.class.getName(),
featureStore,
"{\"value\":2}"
);
loadFeature(
featureNames[2],
OriginalScoreFeature.class.getCanonicalName(),
OriginalScoreFeature.class.getName(),
featureStore,
null
);
loadModel(
"powpularityS-model",
LinearModel.class.getCanonicalName(),
LinearModel.class.getName(),
featureNames,
featureStore,
jsonModelParams

View File

@ -38,7 +38,7 @@ public class TestLTRQParserExplain extends TestRerankBase {
@Test
public void testRerankedExplain() throws Exception {
loadModel("linear2", LinearModel.class.getCanonicalName(), new String[] {
loadModel("linear2", LinearModel.class.getName(), new String[] {
"constant1", "constant2", "pop"},
"{\"weights\":{\"pop\":1.0,\"constant1\":1.5,\"constant2\":3.5}}");

View File

@ -77,7 +77,7 @@ public class TestLTRReRankingPipeline extends LuceneTestCase {
final Map<String,Object> params = new HashMap<String,Object>();
params.put("field", field);
final Feature f = Feature.getInstance(solrResourceLoader,
FieldValueFeature.class.getCanonicalName(),
FieldValueFeature.class.getName(),
"f" + i, params);
f.setIndex(i);
features.add(f);

View File

@ -68,7 +68,7 @@ public class TestLTRScoringQuery extends LuceneTestCase {
Map<String,Object> params = new HashMap<String,Object>();
params.put("value", i);
final Feature f = Feature.getInstance(solrResourceLoader,
ValueFeature.class.getCanonicalName(),
ValueFeature.class.getName(),
"f" + i, params);
f.setIndex(i);
features.add(f);
@ -82,7 +82,7 @@ public class TestLTRScoringQuery extends LuceneTestCase {
Map<String,Object> params = new HashMap<String,Object>();
params.put("value", i);
final Feature f = Feature.getInstance(solrResourceLoader,
ValueFeature.class.getCanonicalName(),
ValueFeature.class.getName(),
"f" + i, params);
f.setIndex(i);
features.add(f);

View File

@ -52,10 +52,10 @@ public class TestLTRWithFacet extends TestRerankBase {
@Test
public void testRankingSolrFacet() throws Exception {
// before();
loadFeature("powpularityS", SolrFeature.class.getCanonicalName(),
loadFeature("powpularityS", SolrFeature.class.getName(),
"{\"q\":\"{!func}pow(popularity,2)\"}");
loadModel("powpularityS-model", LinearModel.class.getCanonicalName(),
loadModel("powpularityS-model", LinearModel.class.getName(),
new String[] {"powpularityS"}, "{\"weights\":{\"powpularityS\":1.0}}");
final SolrQuery query = new SolrQuery();

View File

@ -51,10 +51,10 @@ public class TestLTRWithSort extends TestRerankBase {
@Test
public void testRankingSolrSort() throws Exception {
// before();
loadFeature("powpularityS", SolrFeature.class.getCanonicalName(),
loadFeature("powpularityS", SolrFeature.class.getName(),
"{\"q\":\"{!func}pow(popularity,2)\"}");
loadModel("powpularityS-model", LinearModel.class.getCanonicalName(),
loadModel("powpularityS-model", LinearModel.class.getName(),
new String[] {"powpularityS"}, "{\"weights\":{\"powpularityS\":1.0}}");
final SolrQuery query = new SolrQuery();

View File

@ -63,7 +63,7 @@ public class TestSelectiveWeightCreation extends TestRerankBase {
Map<String,Object> params = new HashMap<String,Object>();
params.put("value", i);
final Feature f = Feature.getInstance(solrResourceLoader,
ValueFeature.class.getCanonicalName(),
ValueFeature.class.getName(),
"f" + i, params);
f.setIndex(i);
features.add(f);

View File

@ -57,10 +57,10 @@ public class TestEdisMaxSolrFeature extends TestRerankBase {
public void testEdisMaxSolrFeature() throws Exception {
loadFeature(
"SomeEdisMax",
SolrFeature.class.getCanonicalName(),
SolrFeature.class.getName(),
"{\"q\":\"{!edismax qf='title description' pf='description' mm=100% boost='pow(popularity, 0.1)' v='w1' tie=0.1}\"}");
loadModel("EdisMax-model", LinearModel.class.getCanonicalName(),
loadModel("EdisMax-model", LinearModel.class.getName(),
new String[] {"SomeEdisMax"}, "{\"weights\":{\"SomeEdisMax\":1.0}}");
final SolrQuery query = new SolrQuery();

View File

@ -39,20 +39,20 @@ public class TestFeatureLogging extends TestRerankBase {
@Test
public void testGeneratedFeatures() throws Exception {
loadFeature("c1", ValueFeature.class.getCanonicalName(), "test1",
loadFeature("c1", ValueFeature.class.getName(), "test1",
"{\"value\":1.0}");
loadFeature("c2", ValueFeature.class.getCanonicalName(), "test1",
loadFeature("c2", ValueFeature.class.getName(), "test1",
"{\"value\":2.0}");
loadFeature("c3", ValueFeature.class.getCanonicalName(), "test1",
loadFeature("c3", ValueFeature.class.getName(), "test1",
"{\"value\":3.0}");
loadFeature("pop", FieldValueFeature.class.getCanonicalName(), "test1",
loadFeature("pop", FieldValueFeature.class.getName(), "test1",
"{\"field\":\"popularity\"}");
loadFeature("nomatch", SolrFeature.class.getCanonicalName(), "test1",
loadFeature("nomatch", SolrFeature.class.getName(), "test1",
"{\"q\":\"{!terms f=title}foobarbat\"}");
loadFeature("yesmatch", SolrFeature.class.getCanonicalName(), "test1",
loadFeature("yesmatch", SolrFeature.class.getName(), "test1",
"{\"q\":\"{!terms f=popularity}2\"}");
loadModel("sum1", LinearModel.class.getCanonicalName(), new String[] {
loadModel("sum1", LinearModel.class.getName(), new String[] {
"c1", "c2", "c3"}, "test1",
"{\"weights\":{\"c1\":1.0,\"c2\":1.0,\"c3\":1.0}}");
@ -96,16 +96,16 @@ public class TestFeatureLogging extends TestRerankBase {
@Test
public void testDefaultStoreFeatureExtraction() throws Exception {
loadFeature("defaultf1", ValueFeature.class.getCanonicalName(),
loadFeature("defaultf1", ValueFeature.class.getName(),
FeatureStore.DEFAULT_FEATURE_STORE_NAME,
"{\"value\":1.0}");
loadFeature("store8f1", ValueFeature.class.getCanonicalName(),
loadFeature("store8f1", ValueFeature.class.getName(),
"store8",
"{\"value\":2.0}");
loadFeature("store9f1", ValueFeature.class.getCanonicalName(),
loadFeature("store9f1", ValueFeature.class.getName(),
"store9",
"{\"value\":3.0}");
loadModel("store9m1", LinearModel.class.getCanonicalName(),
loadModel("store9m1", LinearModel.class.getName(),
new String[] {"store9f1"},
"store9",
"{\"weights\":{\"store9f1\":1.0}}");
@ -140,16 +140,16 @@ public class TestFeatureLogging extends TestRerankBase {
@Test
public void testGeneratedGroup() throws Exception {
loadFeature("c1", ValueFeature.class.getCanonicalName(), "testgroup",
loadFeature("c1", ValueFeature.class.getName(), "testgroup",
"{\"value\":1.0}");
loadFeature("c2", ValueFeature.class.getCanonicalName(), "testgroup",
loadFeature("c2", ValueFeature.class.getName(), "testgroup",
"{\"value\":2.0}");
loadFeature("c3", ValueFeature.class.getCanonicalName(), "testgroup",
loadFeature("c3", ValueFeature.class.getName(), "testgroup",
"{\"value\":3.0}");
loadFeature("pop", FieldValueFeature.class.getCanonicalName(), "testgroup",
loadFeature("pop", FieldValueFeature.class.getName(), "testgroup",
"{\"field\":\"popularity\"}");
loadModel("sumgroup", LinearModel.class.getCanonicalName(), new String[] {
loadModel("sumgroup", LinearModel.class.getName(), new String[] {
"c1", "c2", "c3"}, "testgroup",
"{\"weights\":{\"c1\":1.0,\"c2\":1.0,\"c3\":1.0}}");
@ -180,12 +180,12 @@ public class TestFeatureLogging extends TestRerankBase {
@Test
public void testSparseDenseFeatures() throws Exception {
loadFeature("match", SolrFeature.class.getCanonicalName(), "test4",
loadFeature("match", SolrFeature.class.getName(), "test4",
"{\"q\":\"{!terms f=title}different\"}");
loadFeature("c4", ValueFeature.class.getCanonicalName(), "test4",
loadFeature("c4", ValueFeature.class.getName(), "test4",
"{\"value\":1.0}");
loadModel("sum4", LinearModel.class.getCanonicalName(), new String[] {
loadModel("sum4", LinearModel.class.getName(), new String[] {
"match"}, "test4",
"{\"weights\":{\"match\":1.0}}");

View File

@ -54,10 +54,10 @@ public class TestFieldLengthFeature extends TestRerankBase {
assertU(adoc("id", "42", "title", "w10"));
assertU(commit());
loadFeature("description-length2", FieldLengthFeature.class.getCanonicalName(),
loadFeature("description-length2", FieldLengthFeature.class.getName(),
"{\"field\":\"description\"}");
loadModel("description-model2", LinearModel.class.getCanonicalName(),
loadModel("description-model2", LinearModel.class.getName(),
new String[] {"description-length2"}, "{\"weights\":{\"description-length2\":1.0}}");
final SolrQuery query = new SolrQuery();
@ -75,10 +75,10 @@ public class TestFieldLengthFeature extends TestRerankBase {
assertU(adoc("id", "43", "title", "w11", "description", ""));
assertU(commit());
loadFeature("description-length3", FieldLengthFeature.class.getCanonicalName(),
loadFeature("description-length3", FieldLengthFeature.class.getName(),
"{\"field\":\"description\"}");
loadModel("description-model3", LinearModel.class.getCanonicalName(),
loadModel("description-model3", LinearModel.class.getName(),
new String[] {"description-length3"}, "{\"weights\":{\"description-length3\":1.0}}");
final SolrQuery query = new SolrQuery();
@ -92,10 +92,10 @@ public class TestFieldLengthFeature extends TestRerankBase {
@Test
public void testRanking() throws Exception {
loadFeature("title-length", FieldLengthFeature.class.getCanonicalName(),
loadFeature("title-length", FieldLengthFeature.class.getName(),
"{\"field\":\"title\"}");
loadModel("title-model", LinearModel.class.getCanonicalName(),
loadModel("title-model", LinearModel.class.getName(),
new String[] {"title-length"}, "{\"weights\":{\"title-length\":1.0}}");
final SolrQuery query = new SolrQuery();
@ -131,9 +131,9 @@ public class TestFieldLengthFeature extends TestRerankBase {
assertJQ("/query" + query.toQueryString(), "/response/docs/[3]/id=='6'");
loadFeature("description-length",
FieldLengthFeature.class.getCanonicalName(),
FieldLengthFeature.class.getName(),
"{\"field\":\"description\"}");
loadModel("description-model", LinearModel.class.getCanonicalName(),
loadModel("description-model", LinearModel.class.getName(),
new String[] {"description-length"},
"{\"weights\":{\"description-length\":1.0}}");
query.setQuery("title:w1");

View File

@ -54,10 +54,10 @@ public class TestFieldValueFeature extends TestRerankBase {
assertU(commit());
loadFeature("popularity", FieldValueFeature.class.getCanonicalName(),
loadFeature("popularity", FieldValueFeature.class.getName(),
"{\"field\":\"popularity\"}");
loadModel("popularity-model", LinearModel.class.getCanonicalName(),
loadModel("popularity-model", LinearModel.class.getName(),
new String[] {"popularity"}, "{\"weights\":{\"popularity\":1.0}}");
}
@ -127,7 +127,7 @@ public class TestFieldValueFeature extends TestRerankBase {
final String fstore = "testIfADocumentDoesntHaveAFieldASetDefaultValueIsReturned";
loadFeature("popularity42", FieldValueFeature.class.getCanonicalName(), fstore,
loadFeature("popularity42", FieldValueFeature.class.getName(), fstore,
"{\"field\":\"popularity\",\"defaultValue\":\"42.0\"}");
SolrQuery query = new SolrQuery();
@ -135,7 +135,7 @@ public class TestFieldValueFeature extends TestRerankBase {
query.add("fl", "*, score");
query.add("rows", "4");
loadModel("popularity-model42", LinearModel.class.getCanonicalName(),
loadModel("popularity-model42", LinearModel.class.getName(),
new String[] {"popularity42"}, fstore, "{\"weights\":{\"popularity42\":1.0}}");
assertJQ("/query" + query.toQueryString(), "/response/numFound/==1");
@ -154,10 +154,10 @@ public class TestFieldValueFeature extends TestRerankBase {
public void testThatIfaFieldDoesNotExistDefaultValueIsReturned() throws Exception {
// using a different fstore to avoid a clash with the other tests
final String fstore = "testThatIfaFieldDoesNotExistDefaultValueIsReturned";
loadFeature("not-existing-field", FieldValueFeature.class.getCanonicalName(), fstore,
loadFeature("not-existing-field", FieldValueFeature.class.getName(), fstore,
"{\"field\":\"cowabunga\"}");
loadModel("not-existing-field-model", LinearModel.class.getCanonicalName(),
loadModel("not-existing-field-model", LinearModel.class.getName(),
new String[] {"not-existing-field"}, fstore, "{\"weights\":{\"not-existing-field\":1.0}}");
final SolrQuery query = new SolrQuery();
@ -173,10 +173,10 @@ public class TestFieldValueFeature extends TestRerankBase {
@Test
public void testBooleanValue() throws Exception {
final String fstore = "test_boolean_store";
loadFeature("trendy", FieldValueFeature.class.getCanonicalName(), fstore,
loadFeature("trendy", FieldValueFeature.class.getName(), fstore,
"{\"field\":\"isTrendy\"}");
loadModel("trendy-model", LinearModel.class.getCanonicalName(),
loadModel("trendy-model", LinearModel.class.getName(),
new String[] {"trendy"}, fstore, "{\"weights\":{\"trendy\":1.0}}");
SolrQuery query = new SolrQuery();

View File

@ -56,11 +56,11 @@ public class TestFilterSolrFeature extends TestRerankBase {
@Test
public void testUserTermScoreWithFQ() throws Exception {
loadFeature("SomeTermFQ", SolrFeature.class.getCanonicalName(),
loadFeature("SomeTermFQ", SolrFeature.class.getName(),
"{\"fq\":[\"{!terms f=popularity}88888\"]}");
loadFeature("SomeEfiFQ", SolrFeature.class.getCanonicalName(),
loadFeature("SomeEfiFQ", SolrFeature.class.getName(),
"{\"fq\":[\"{!terms f=title}${user_query}\"]}");
loadModel("Term-modelFQ", LinearModel.class.getCanonicalName(),
loadModel("Term-modelFQ", LinearModel.class.getName(),
new String[] {"SomeTermFQ", "SomeEfiFQ"},
"{\"weights\":{\"SomeTermFQ\":1.6, \"SomeEfiFQ\":2.0}}");
final SolrQuery query = new SolrQuery();
@ -80,7 +80,7 @@ public class TestFilterSolrFeature extends TestRerankBase {
public void testBadFeature() throws Exception {
// Missing q/fq
final String feature = getFeatureInJson("badFeature", "test",
SolrFeature.class.getCanonicalName(), "{\"df\":\"foo\"]}");
SolrFeature.class.getName(), "{\"df\":\"foo\"]}");
assertJPut(ManagedFeatureStore.REST_END_POINT, feature,
"/responseHeader/status==500");
}

View File

@ -53,27 +53,27 @@ public class TestNoMatchSolrFeature extends TestRerankBase {
"w1 w1 w1 w2 w2", "popularity", "8"));
assertU(commit());
loadFeature("nomatchfeature", SolrFeature.class.getCanonicalName(),
loadFeature("nomatchfeature", SolrFeature.class.getName(),
"{\"q\":\"foobarbat12345\",\"df\":\"title\"}");
loadFeature("yesmatchfeature", SolrFeature.class.getCanonicalName(),
loadFeature("yesmatchfeature", SolrFeature.class.getName(),
"{\"q\":\"w1\",\"df\":\"title\"}");
loadFeature("nomatchfeature2", SolrFeature.class.getCanonicalName(),
loadFeature("nomatchfeature2", SolrFeature.class.getName(),
"{\"q\":\"foobarbat12345\",\"df\":\"title\"}");
loadModel(
"nomatchmodel",
LinearModel.class.getCanonicalName(),
LinearModel.class.getName(),
new String[] {"nomatchfeature", "yesmatchfeature", "nomatchfeature2"},
"{\"weights\":{\"nomatchfeature\":1.0,\"yesmatchfeature\":1.1,\"nomatchfeature2\":1.1}}");
loadFeature("nomatchfeature3", SolrFeature.class.getCanonicalName(),
loadFeature("nomatchfeature3", SolrFeature.class.getName(),
"{\"q\":\"foobarbat12345\",\"df\":\"title\"}");
loadModel("nomatchmodel2", LinearModel.class.getCanonicalName(),
loadModel("nomatchmodel2", LinearModel.class.getName(),
new String[] {"nomatchfeature3"},
"{\"weights\":{\"nomatchfeature3\":1.0}}");
loadFeature("nomatchfeature4", SolrFeature.class.getCanonicalName(),
loadFeature("nomatchfeature4", SolrFeature.class.getName(),
"noMatchFeaturesStore", "{\"q\":\"foobarbat12345\",\"df\":\"title\"}");
loadModel("nomatchmodel3", LinearModel.class.getCanonicalName(),
loadModel("nomatchmodel3", LinearModel.class.getName(),
new String[] {"nomatchfeature4"}, "noMatchFeaturesStore",
"{\"weights\":{\"nomatchfeature4\":1.0}}");
}
@ -239,7 +239,7 @@ public class TestNoMatchSolrFeature extends TestRerankBase {
// MultipleAdditiveTrees will return scores even for docs without any feature matches
loadModel(
"nomatchmodel4",
MultipleAdditiveTreesModel.class.getCanonicalName(),
MultipleAdditiveTreesModel.class.getName(),
new String[] {"nomatchfeature4"},
"noMatchFeaturesStore",
"{\"trees\":[{\"weight\":\"1f\", \"root\":{\"feature\": \"matchedTitle\",\"threshold\": \"0.5f\",\"left\":{\"value\" : \"-10\"},\"right\":{\"value\" : \"9\"}}}]}");

View File

@ -53,8 +53,8 @@ public class TestOriginalScoreFeature extends TestRerankBase {
@Test
public void testOriginalScore() throws Exception {
loadFeature("score", OriginalScoreFeature.class.getCanonicalName(), "{}");
loadModel("originalScore", LinearModel.class.getCanonicalName(),
loadFeature("score", OriginalScoreFeature.class.getName(), "{}");
loadModel("originalScore", LinearModel.class.getName(),
new String[] {"score"}, "{\"weights\":{\"score\":1.0}}");
implTestOriginalScoreResponseDocsCheck("originalScore", "score", null, null);
@ -62,12 +62,12 @@ public class TestOriginalScoreFeature extends TestRerankBase {
@Test
public void testOriginalScoreWithNonScoringFeatures() throws Exception {
loadFeature("origScore", OriginalScoreFeature.class.getCanonicalName(),
loadFeature("origScore", OriginalScoreFeature.class.getName(),
"store2", "{}");
loadFeature("c2", ValueFeature.class.getCanonicalName(), "store2",
loadFeature("c2", ValueFeature.class.getName(), "store2",
"{\"value\":2.0}");
loadModel("origScore", LinearModel.class.getCanonicalName(),
loadModel("origScore", LinearModel.class.getName(),
new String[] {"origScore"}, "store2",
"{\"weights\":{\"origScore\":1.0}}");

View File

@ -57,14 +57,14 @@ public class TestRankingFeature extends TestRerankBase {
@Test
public void testRankingSolrFeature() throws Exception {
// before();
loadFeature("powpularityS", SolrFeature.class.getCanonicalName(),
loadFeature("powpularityS", SolrFeature.class.getName(),
"{\"q\":\"{!func}pow(popularity,2)\"}");
loadFeature("unpopularityS", SolrFeature.class.getCanonicalName(),
loadFeature("unpopularityS", SolrFeature.class.getName(),
"{\"q\":\"{!func}div(1,popularity)\"}");
loadModel("powpularityS-model", LinearModel.class.getCanonicalName(),
loadModel("powpularityS-model", LinearModel.class.getName(),
new String[] {"powpularityS"}, "{\"weights\":{\"powpularityS\":1.0}}");
loadModel("unpopularityS-model", LinearModel.class.getCanonicalName(),
loadModel("unpopularityS-model", LinearModel.class.getName(),
new String[] {"unpopularityS"}, "{\"weights\":{\"unpopularityS\":1.0}}");
final SolrQuery query = new SolrQuery();
@ -104,16 +104,16 @@ public class TestRankingFeature extends TestRerankBase {
assertJQ("/query" + query.toQueryString(), "/response/docs/[3]/id=='8'");
//bad solr ranking feature
loadFeature("powdesS", SolrFeature.class.getCanonicalName(),
loadFeature("powdesS", SolrFeature.class.getName(),
"{\"q\":\"{!func}pow(description,2)\"}");
loadModel("powdesS-model", LinearModel.class.getCanonicalName(),
loadModel("powdesS-model", LinearModel.class.getName(),
new String[] {"powdesS"}, "{\"weights\":{\"powdesS\":1.0}}");
query.remove("rq");
query.add("rq", "{!ltr model=powdesS-model reRankDocs=4}");
assertJQ("/query" + query.toQueryString(),
"/error/msg/=='"+FeatureException.class.getCanonicalName()+": " +
"/error/msg/=='"+FeatureException.class.getName()+": " +
"java.lang.UnsupportedOperationException: " +
"Unable to extract feature for powdesS'");
// aftertest();

View File

@ -56,9 +56,9 @@ public class TestUserTermScoreWithQ extends TestRerankBase {
@Test
public void testUserTermScoreWithQ() throws Exception {
// before();
loadFeature("SomeTermQ", SolrFeature.class.getCanonicalName(),
loadFeature("SomeTermQ", SolrFeature.class.getName(),
"{\"q\":\"{!terms f=popularity}88888\"}");
loadModel("Term-modelQ", LinearModel.class.getCanonicalName(),
loadModel("Term-modelQ", LinearModel.class.getName(),
new String[] {"SomeTermQ"}, "{\"weights\":{\"SomeTermQ\":1.0}}");
final SolrQuery query = new SolrQuery();
query.setQuery("title:w1");

View File

@ -56,9 +56,9 @@ public class TestUserTermScorerQuery extends TestRerankBase {
@Test
public void testUserTermScorerQuery() throws Exception {
// before();
loadFeature("matchedTitleDFExt", SolrFeature.class.getCanonicalName(),
loadFeature("matchedTitleDFExt", SolrFeature.class.getName(),
"{\"q\":\"${user_query}\",\"df\":\"title\"}");
loadModel("Term-matchedTitleDFExt", LinearModel.class.getCanonicalName(),
loadModel("Term-matchedTitleDFExt", LinearModel.class.getName(),
new String[] {"matchedTitleDFExt"},
"{\"weights\":{\"matchedTitleDFExt\":1.1}}");
final SolrQuery query = new SolrQuery();

View File

@ -56,9 +56,9 @@ public class TestUserTermScorereQDF extends TestRerankBase {
@Test
public void testUserTermScorerQWithDF() throws Exception {
// before();
loadFeature("matchedTitleDF", SolrFeature.class.getCanonicalName(),
loadFeature("matchedTitleDF", SolrFeature.class.getName(),
"{\"q\":\"w5\",\"df\":\"title\"}");
loadModel("Term-matchedTitleDF", LinearModel.class.getCanonicalName(),
loadModel("Term-matchedTitleDF", LinearModel.class.getName(),
new String[] {"matchedTitleDF"},
"{\"weights\":{\"matchedTitleDF\":1.0}}");
final SolrQuery query = new SolrQuery();

View File

@ -50,7 +50,7 @@ public class TestValueFeature extends TestRerankBase {
final RuntimeException expectedException =
new RuntimeException("mismatch: '0'!='500' @ responseHeader/status");
try {
loadFeature("c2", ValueFeature.class.getCanonicalName(), "{\"value\":\"\"}");
loadFeature("c2", ValueFeature.class.getName(), "{\"value\":\"\"}");
fail("testValueFeatureWithEmptyValue failed to throw exception: "+expectedException);
} catch (RuntimeException actualException) {
assertEquals(expectedException.toString(), actualException.toString());
@ -62,7 +62,7 @@ public class TestValueFeature extends TestRerankBase {
final RuntimeException expectedException =
new RuntimeException("mismatch: '0'!='500' @ responseHeader/status");
try {
loadFeature("c2", ValueFeature.class.getCanonicalName(),
loadFeature("c2", ValueFeature.class.getName(),
"{\"value\":\" \"}");
fail("testValueFeatureWithWhitespaceValue failed to throw exception: "+expectedException);
} catch (RuntimeException actualException) {
@ -72,9 +72,9 @@ public class TestValueFeature extends TestRerankBase {
@Test
public void testRerankingWithConstantValueFeatureReplacesDocScore() throws Exception {
loadFeature("c3", ValueFeature.class.getCanonicalName(), "c3",
loadFeature("c3", ValueFeature.class.getName(), "c3",
"{\"value\":2}");
loadModel("m3", LinearModel.class.getCanonicalName(), new String[] {"c3"},
loadModel("m3", LinearModel.class.getName(), new String[] {"c3"},
"c3", "{\"weights\":{\"c3\":1.0}}");
final SolrQuery query = new SolrQuery();
@ -92,9 +92,9 @@ public class TestValueFeature extends TestRerankBase {
@Test
public void testRerankingWithEfiValueFeatureReplacesDocScore() throws Exception {
loadFeature("c6", ValueFeature.class.getCanonicalName(), "c6",
loadFeature("c6", ValueFeature.class.getName(), "c6",
"{\"value\":\"${val6}\"}");
loadModel("m6", LinearModel.class.getCanonicalName(), new String[] {"c6"},
loadModel("m6", LinearModel.class.getName(), new String[] {"c6"},
"c6", "{\"weights\":{\"c6\":1.0}}");
final SolrQuery query = new SolrQuery();
@ -113,9 +113,9 @@ public class TestValueFeature extends TestRerankBase {
@Test
public void testValueFeatureImplicitlyNotRequiredShouldReturnOkStatusCode() throws Exception {
loadFeature("c5", ValueFeature.class.getCanonicalName(), "c5",
loadFeature("c5", ValueFeature.class.getName(), "c5",
"{\"value\":\"${val6}\"}");
loadModel("m5", LinearModel.class.getCanonicalName(), new String[] {"c5"},
loadModel("m5", LinearModel.class.getName(), new String[] {"c5"},
"c5", "{\"weights\":{\"c5\":1.0}}");
final SolrQuery query = new SolrQuery();
@ -130,9 +130,9 @@ public class TestValueFeature extends TestRerankBase {
@Test
public void testValueFeatureExplictlyNotRequiredShouldReturnOkStatusCode() throws Exception {
loadFeature("c7", ValueFeature.class.getCanonicalName(), "c7",
loadFeature("c7", ValueFeature.class.getName(), "c7",
"{\"value\":\"${val7}\",\"required\":false}");
loadModel("m7", LinearModel.class.getCanonicalName(), new String[] {"c7"},
loadModel("m7", LinearModel.class.getName(), new String[] {"c7"},
"c7", "{\"weights\":{\"c7\":1.0}}");
final SolrQuery query = new SolrQuery();
@ -147,9 +147,9 @@ public class TestValueFeature extends TestRerankBase {
@Test
public void testValueFeatureRequiredShouldReturn400StatusCode() throws Exception {
loadFeature("c8", ValueFeature.class.getCanonicalName(), "c8",
loadFeature("c8", ValueFeature.class.getName(), "c8",
"{\"value\":\"${val8}\",\"required\":true}");
loadModel("m8", LinearModel.class.getCanonicalName(), new String[] {"c8"},
loadModel("m8", LinearModel.class.getName(), new String[] {"c8"},
"c8", "{\"weights\":{\"c8\":1.0}}");
final SolrQuery query = new SolrQuery();

View File

@ -52,13 +52,13 @@ public class TestDefaultWrapperModel extends TestRerankBase {
assertU(adoc("id", "5", "title", "w5", "description", "w5", "popularity", "5"));
assertU(commit());
loadFeature("popularity", FieldValueFeature.class.getCanonicalName(), "test", "{\"field\":\"popularity\"}");
loadFeature("const", ValueFeature.class.getCanonicalName(), "test", "{\"value\":5}");
loadFeature("popularity", FieldValueFeature.class.getName(), "test", "{\"field\":\"popularity\"}");
loadFeature("const", ValueFeature.class.getName(), "test", "{\"value\":5}");
features = new ArrayList<>();
features.add(getManagedFeatureStore().getFeatureStore("test").get("popularity"));
features.add(getManagedFeatureStore().getFeatureStore("test").get("const"));
baseModelJson = getModelInJson("linear", LinearModel.class.getCanonicalName(),
baseModelJson = getModelInJson("linear", LinearModel.class.getName(),
new String[] {"popularity", "const"},
featureStoreName,
"{\"weights\":{\"popularity\":-1.0, \"const\":1.0}}");
@ -72,7 +72,7 @@ public class TestDefaultWrapperModel extends TestRerankBase {
}
private static String getDefaultWrapperModelInJson(String wrapperModelName, String[] features, String params) {
return getModelInJson(wrapperModelName, DefaultWrapperModel.class.getCanonicalName(),
return getModelInJson(wrapperModelName, DefaultWrapperModel.class.getName(),
features, featureStoreName, params);
}

View File

@ -39,7 +39,7 @@ public class TestLinearModel extends TestRerankBase {
String featureStoreName, List<Feature> allFeatures,
Map<String,Object> params) throws ModelException {
final LTRScoringModel model = LTRScoringModel.getInstance(solrResourceLoader,
LinearModel.class.getCanonicalName(),
LinearModel.class.getName(),
name,
features, norms, featureStoreName, allFeatures, params);
return model;
@ -111,7 +111,7 @@ public class TestLinearModel extends TestRerankBase {
public void existingNameTest() {
final SolrException expectedException =
new SolrException(SolrException.ErrorCode.BAD_REQUEST,
ModelException.class.getCanonicalName()+": model 'test3' already exists. Please use a different name");
ModelException.class.getName()+": model 'test3' already exists. Please use a different name");
try {
final List<Feature> features = getFeatures(new String[]
{"constant1", "constant5"});

View File

@ -34,7 +34,7 @@ public class TestMinMaxNormalizer {
float expectedMin, float expectedMax) {
final Normalizer n = Normalizer.getInstance(
solrResourceLoader,
MinMaxNormalizer.class.getCanonicalName(),
MinMaxNormalizer.class.getName(),
params);
assertTrue(n instanceof MinMaxNormalizer);
final MinMaxNormalizer mmn = (MinMaxNormalizer)n;

View File

@ -34,7 +34,7 @@ public class TestStandardNormalizer {
float expectedAvg, float expectedStd) {
final Normalizer n = Normalizer.getInstance(
solrResourceLoader,
StandardNormalizer.class.getCanonicalName(),
StandardNormalizer.class.getName(),
params);
assertTrue(n instanceof StandardNormalizer);
final StandardNormalizer sn = (StandardNormalizer)n;
@ -122,7 +122,7 @@ public class TestStandardNormalizer {
params.put("std", "1.5f");
final Normalizer norm = Normalizer.getInstance(
solrResourceLoader,
StandardNormalizer.class.getCanonicalName(),
StandardNormalizer.class.getName(),
params);
for (final float v : new float[] {10f, 20f, 25f, 30f, 31f, 40f, 42f, 100f,

View File

@ -66,7 +66,7 @@ public class TestManagedFeatureStore extends SolrTestCaseJ4 {
final String name = "c" + i;
fstore.addFeature(createMap(name,
OriginalScoreFeature.class.getCanonicalName(), null),
OriginalScoreFeature.class.getName(), null),
"fstore-testFeature");
final Feature f = fs.get(name);
@ -87,7 +87,7 @@ public class TestManagedFeatureStore extends SolrTestCaseJ4 {
final String name = "c" + i;
fstore.addFeature(createMap(name,
ValueFeature.class.getCanonicalName(), params),
ValueFeature.class.getName(), params),
"fstore-testFeature2");
}
@ -109,7 +109,7 @@ public class TestManagedFeatureStore extends SolrTestCaseJ4 {
params.put("value", i);
final String name = "testc" + (float) i;
fstore.addFeature(createMap(name,
ValueFeature.class.getCanonicalName(), params),
ValueFeature.class.getName(), params),
"fstore-testFeature3");
}
@ -120,13 +120,13 @@ public class TestManagedFeatureStore extends SolrTestCaseJ4 {
public void getInstanceTest() throws FeatureException
{
fstore.addFeature(createMap("test",
OriginalScoreFeature.class.getCanonicalName(), null),
OriginalScoreFeature.class.getName(), null),
"testFstore");
final Feature feature = fstore.getFeatureStore("testFstore").get("test");
assertNotNull(feature);
assertEquals("test", feature.getName());
assertEquals(OriginalScoreFeature.class.getCanonicalName(), feature
.getClass().getCanonicalName());
assertEquals(OriginalScoreFeature.class.getName(), feature
.getClass().getName());
}
@Test

View File

@ -74,7 +74,7 @@ public class TestModelManager extends TestRerankBase {
// schema-rest.xml used by this test
assertJQ("/schema/managed", "/responseHeader/status==0");
final String valueFeatureClassName = ValueFeature.class.getCanonicalName();
final String valueFeatureClassName = ValueFeature.class.getName();
// Add features
String feature = "{\"name\": \"test1\", \"class\": \""+valueFeatureClassName+"\", \"params\": {\"value\": 1} }";
@ -98,14 +98,14 @@ public class TestModelManager extends TestRerankBase {
assertJPut(ManagedFeatureStore.REST_END_POINT, multipleFeatures,
"/responseHeader/status==0");
final String fieldValueFeatureClassName = FieldValueFeature.class.getCanonicalName();
final String fieldValueFeatureClassName = FieldValueFeature.class.getName();
// Add bad feature (wrong params)_
final String badfeature = "{\"name\": \"fvalue\", \"class\": \""+fieldValueFeatureClassName+"\", \"params\": {\"value\": 1} }";
assertJPut(ManagedFeatureStore.REST_END_POINT, badfeature,
"/error/msg/=='No setter corrresponding to \\'value\\' in "+fieldValueFeatureClassName+"'");
final String linearModelClassName = LinearModel.class.getCanonicalName();
final String linearModelClassName = LinearModel.class.getName();
// Add models
String model = "{ \"name\":\"testmodel1\", \"class\":\""+linearModelClassName+"\", \"features\":[] }";

View File

@ -49,18 +49,18 @@ public class TestModelManagerPersistence extends TestRerankBase {
@Test
public void testFeaturePersistence() throws Exception {
loadFeature("feature", ValueFeature.class.getCanonicalName(), "test",
loadFeature("feature", ValueFeature.class.getName(), "test",
"{\"value\":2}");
assertJQ(ManagedFeatureStore.REST_END_POINT + "/test",
"/features/[0]/name=='feature'");
restTestHarness.reload();
assertJQ(ManagedFeatureStore.REST_END_POINT + "/test",
"/features/[0]/name=='feature'");
loadFeature("feature1", ValueFeature.class.getCanonicalName(), "test1",
loadFeature("feature1", ValueFeature.class.getName(), "test1",
"{\"value\":2}");
loadFeature("feature2", ValueFeature.class.getCanonicalName(), "test",
loadFeature("feature2", ValueFeature.class.getName(), "test",
"{\"value\":2}");
loadFeature("feature3", ValueFeature.class.getCanonicalName(), "test2",
loadFeature("feature3", ValueFeature.class.getName(), "test2",
"{\"value\":2}");
assertJQ(ManagedFeatureStore.REST_END_POINT + "/test",
"/features/[0]/name=='feature'");
@ -79,9 +79,9 @@ public class TestModelManagerPersistence extends TestRerankBase {
"/features/[0]/name=='feature1'");
assertJQ(ManagedFeatureStore.REST_END_POINT + "/test2",
"/features/[0]/name=='feature3'");
loadModel("test-model", LinearModel.class.getCanonicalName(),
loadModel("test-model", LinearModel.class.getName(),
new String[] {"feature"}, "test", "{\"weights\":{\"feature\":1.0}}");
loadModel("test-model2", LinearModel.class.getCanonicalName(),
loadModel("test-model2", LinearModel.class.getName(),
new String[] {"feature1"}, "test1", "{\"weights\":{\"feature1\":1.0}}");
final String fstorecontent = FileUtils
.readFileToString(fstorefile, "UTF-8");
@ -204,7 +204,7 @@ public class TestModelManagerPersistence extends TestRerankBase {
"!/models/[1]/name=='"+modelName+"'",
// but the wrapper model should be registered
"/models/[0]/name=='"+modelName+"'",
"/models/[0]/class=='" + DefaultWrapperModel.class.getCanonicalName() + "'",
"/models/[0]/class=='" + DefaultWrapperModel.class.getName() + "'",
"/models/[0]/store=='" + featureStoreName + "'",
// the wrapper model shouldn't contain the definitions of the wrapped model
"/models/[0]/features/==[]",
@ -224,11 +224,11 @@ public class TestModelManagerPersistence extends TestRerankBase {
"/features/==[]");
// setup features
loadFeature("popularity", FieldValueFeature.class.getCanonicalName(), FS_NAME, "{\"field\":\"popularity\"}");
loadFeature("const", ValueFeature.class.getCanonicalName(), FS_NAME, "{\"value\":5}");
loadFeature("popularity", FieldValueFeature.class.getName(), FS_NAME, "{\"field\":\"popularity\"}");
loadFeature("const", ValueFeature.class.getName(), FS_NAME, "{\"value\":5}");
// setup base model
String baseModelJson = getModelInJson(modelName, LinearModel.class.getCanonicalName(),
String baseModelJson = getModelInJson(modelName, LinearModel.class.getName(),
new String[] {"popularity", "const"}, FS_NAME,
"{\"weights\":{\"popularity\":-1.0, \"const\":1.0}}");
File baseModelFile = new File(tmpConfDir, "baseModelForPersistence.json");
@ -239,7 +239,7 @@ public class TestModelManagerPersistence extends TestRerankBase {
baseModelFile.deleteOnExit();
// setup wrapper model
String wrapperModelJson = getModelInJson(modelName, DefaultWrapperModel.class.getCanonicalName(),
String wrapperModelJson = getModelInJson(modelName, DefaultWrapperModel.class.getName(),
new String[0], FS_NAME,
"{\"resource\":\"" + baseModelFile.getName() + "\"}");
assertJPut(ManagedModelStore.REST_END_POINT, wrapperModelJson, "/responseHeader/status==0");