From 07a9b6b64716cf9d88e5abd74ba922df19255fb5 Mon Sep 17 00:00:00 2001 From: jdorando Date: Fri, 19 Aug 2016 11:52:48 -0400 Subject: [PATCH] Changed type to class as param (#48) * changed type to class as param * code review comments --- .../apache/solr/ltr/feature/ModelStore.java | 7 +++--- .../solr/ltr/feature/norm/Normalizer.java | 6 ++--- .../org/apache/solr/ltr/ranking/Feature.java | 9 +++---- .../solr/ltr/rest/ManagedFeatureStore.java | 2 +- .../solr/ltr/rest/ManagedModelStore.java | 2 +- .../apache/solr/ltr/util/CommonLTRParams.java | 8 ++++++- .../featureExamples/external_features.json | 18 +++++++------- ...ternal_features_for_sparse_processing.json | 6 ++--- .../features-file-simple-params.json | 4 ++-- .../featureExamples/features-file-simple.json | 4 ++-- .../featureExamples/features-ranksvm-efi.json | 6 ++--- .../featureExamples/features-ranksvm.json | 16 ++++++------- .../features-store-test-model.json | 14 +++++------ .../test-files/featureExamples/features.json | 6 ++--- .../featureExamples/lambdamart_features.json | 4 ++-- .../modelExamples/external_model.json | 2 +- .../modelExamples/lambdamart_model.json | 2 +- ...damart_model_external_binary_features.json | 4 ++-- .../lambdamart_model_no_feature.json | 2 +- .../lambdamart_model_no_features.json | 2 +- .../lambdamart_model_no_left.json | 2 +- .../lambdamart_model_no_params.json | 2 +- .../lambdamart_model_no_right.json | 2 +- .../lambdamart_model_no_threshold.json | 2 +- .../lambdamart_model_no_tree.json | 2 +- .../lambdamart_model_no_trees.json | 2 +- .../lambdamart_model_no_weight.json | 2 +- .../modelExamples/ranksvm-model.json | 6 ++--- .../modelExamples/svm-model-efi.json | 4 ++-- .../modelExamples/svm-model-normalized.json | 4 ++-- .../test-files/modelExamples/svm-model.json | 4 ++-- .../test-files/modelExamples/svm-model1.json | 4 ++-- .../modelExamples/svm-sum-model.json | 2 +- .../org/apache/solr/ltr/TestRerankBase.java | 4 ++-- .../solr/ltr/rest/TestModelManager.java | 24 +++++++++---------- 35 files changed, 99 insertions(+), 91 deletions(-) diff --git a/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/ModelStore.java b/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/ModelStore.java index 3c7ed01a5ce8..c733c5ce21e2 100644 --- a/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/ModelStore.java +++ b/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/ModelStore.java @@ -25,6 +25,7 @@ import org.apache.solr.ltr.feature.norm.Normalizer; import org.apache.solr.ltr.ranking.Feature; +import org.apache.solr.ltr.util.CommonLTRParams; import org.apache.solr.ltr.util.ModelException; /** @@ -60,9 +61,9 @@ public List modelAsManagedResources() { final List list = new ArrayList<>(availableModels.size()); for (final LTRScoringAlgorithm modelmeta : availableModels.values()) { final Map modelMap = new HashMap<>(5, 1.0f); - modelMap.put("name", modelmeta.getName()); - modelMap.put("type", modelmeta.getClass().getCanonicalName()); - modelMap.put("store", modelmeta.getFeatureStoreName()); + modelMap.put((String)CommonLTRParams.MODEL_NAME, modelmeta.getName()); + modelMap.put((String)CommonLTRParams.MODEL_CLASS, modelmeta.getClass().getCanonicalName()); + modelMap.put((String)CommonLTRParams.MODEL_FEATURE_STORE, modelmeta.getFeatureStoreName()); final List> features = new ArrayList<>(modelmeta.numFeatures()); for (final Feature meta : modelmeta.getFeatures()) { final Map map = new HashMap(2, 1.0f); diff --git a/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/norm/Normalizer.java b/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/norm/Normalizer.java index 953063e0708e..1eb6211ef472 100644 --- a/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/norm/Normalizer.java +++ b/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/norm/Normalizer.java @@ -31,7 +31,7 @@ public abstract class Normalizer { /** name of the attribute containing the normalizer type **/ - private static final String TYPE_KEY = "type"; + private static final String CLASS_KEY = "class"; /** name of the attribute containing the normalizer params **/ private static final String PARAMS_KEY = "params"; @@ -58,7 +58,7 @@ public static Normalizer getInstance(SolrResourceLoader solrResourceLoader, public static Normalizer fromMap(SolrResourceLoader solrResourceLoader, Map normMap) { final String type = - (String) normMap.get(TYPE_KEY); + (String) normMap.get(CLASS_KEY); @SuppressWarnings("unchecked") final Map params = @@ -71,7 +71,7 @@ public static Normalizer fromMap(SolrResourceLoader solrResourceLoader, public LinkedHashMap toMap() { final LinkedHashMap normalizer = new LinkedHashMap<>(2, 1.0f); - normalizer.put(TYPE_KEY, getClass().getCanonicalName()); + normalizer.put(CLASS_KEY, getClass().getCanonicalName()); final LinkedHashMap params = paramsToMap(); if (params != null) { diff --git a/solr/contrib/ltr/src/java/org/apache/solr/ltr/ranking/Feature.java b/solr/contrib/ltr/src/java/org/apache/solr/ltr/ranking/Feature.java index dfd5e9d61abb..1d01e94bd528 100644 --- a/solr/contrib/ltr/src/java/org/apache/solr/ltr/ranking/Feature.java +++ b/solr/contrib/ltr/src/java/org/apache/solr/ltr/ranking/Feature.java @@ -31,6 +31,7 @@ import org.apache.lucene.search.Weight; import org.apache.solr.ltr.feature.norm.Normalizer; import org.apache.solr.ltr.feature.norm.impl.IdentityNormalizer; +import org.apache.solr.ltr.util.CommonLTRParams; import org.apache.solr.ltr.util.FeatureException; import org.apache.solr.ltr.util.MacroExpander; import org.apache.solr.ltr.util.NamedParams; @@ -145,10 +146,10 @@ public int getId() { public LinkedHashMap toMap(String storeName) { final LinkedHashMap o = new LinkedHashMap<>(4, 1.0f); - o.put("name", name); - o.put("type", getClass().getCanonicalName()); - o.put("store", storeName); - o.put("params", paramsToMap()); + o.put((String)CommonLTRParams.FEATURE_NAME, name); + o.put((String)CommonLTRParams.FEATURE_CLASS, getClass().getCanonicalName()); + o.put((String)CommonLTRParams.FEATURE_STORE, storeName); + o.put((String)CommonLTRParams.FEATURE_PARAMS, paramsToMap()); return o; } diff --git a/solr/contrib/ltr/src/java/org/apache/solr/ltr/rest/ManagedFeatureStore.java b/solr/contrib/ltr/src/java/org/apache/solr/ltr/rest/ManagedFeatureStore.java index c84104299086..7e2e19883b64 100644 --- a/solr/contrib/ltr/src/java/org/apache/solr/ltr/rest/ManagedFeatureStore.java +++ b/solr/contrib/ltr/src/java/org/apache/solr/ltr/rest/ManagedFeatureStore.java @@ -82,7 +82,7 @@ protected void onManagedDataLoadedFromStorage(NamedList managedInitArgs, public void update(Map map) { final String name = (String) map.get(CommonLTRParams.MODEL_NAME); - final String type = (String) map.get(CommonLTRParams.MODEL_TYPE); + final String type = (String) map.get(CommonLTRParams.MODEL_CLASS); final String store = (String) map.get(CommonLTRParams.MODEL_FEATURE_STORE); NamedParams params = null; diff --git a/solr/contrib/ltr/src/java/org/apache/solr/ltr/rest/ManagedModelStore.java b/solr/contrib/ltr/src/java/org/apache/solr/ltr/rest/ManagedModelStore.java index cb402c7c3fe5..f9d9ee61bae5 100644 --- a/solr/contrib/ltr/src/java/org/apache/solr/ltr/rest/ManagedModelStore.java +++ b/solr/contrib/ltr/src/java/org/apache/solr/ltr/rest/ManagedModelStore.java @@ -180,7 +180,7 @@ public LTRScoringAlgorithm makeLTRScoringAlgorithm(Map map) params = new NamedParams(paramsMap); } - final String type = (String) map.get(CommonLTRParams.MODEL_TYPE); + final String type = (String) map.get(CommonLTRParams.MODEL_CLASS); LTRScoringAlgorithm meta = null; try { // create an instance of the model diff --git a/solr/contrib/ltr/src/java/org/apache/solr/ltr/util/CommonLTRParams.java b/solr/contrib/ltr/src/java/org/apache/solr/ltr/util/CommonLTRParams.java index 3e38b99cc157..b8c6bdf1d242 100644 --- a/solr/contrib/ltr/src/java/org/apache/solr/ltr/util/CommonLTRParams.java +++ b/solr/contrib/ltr/src/java/org/apache/solr/ltr/util/CommonLTRParams.java @@ -22,6 +22,12 @@ public class CommonLTRParams { /** name of the attribute containing the feature name **/ public static final String FEATURE_NAME = "name"; + /** name of the attribute containing the feature type **/ + public static final Object FEATURE_CLASS = "class"; + /** name of the attribute containing the feature store used **/ + public static final Object FEATURE_STORE = "store"; + /** name of the attribute containing the feature params **/ + public static final Object FEATURE_PARAMS = "params"; /** name of the attribute containing the normalizer **/ public static final String FEATURE_NORM = "norm"; /** name of the attribute containing the a field in a document **/ @@ -29,7 +35,7 @@ public class CommonLTRParams { /** name of the attribute containing the model name **/ public static final Object MODEL_NAME = "name"; /** name of the attribute containing the model type **/ - public static final Object MODEL_TYPE = "type"; + public static final Object MODEL_CLASS = "class"; /** name of the attribute containing the feature store used **/ public static final Object MODEL_FEATURE_STORE = "store"; /** name of the attribute containing the model params **/ diff --git a/solr/contrib/ltr/src/test-files/featureExamples/external_features.json b/solr/contrib/ltr/src/test-files/featureExamples/external_features.json index 4a9540b4a63c..f66b6aafe3ee 100644 --- a/solr/contrib/ltr/src/test-files/featureExamples/external_features.json +++ b/solr/contrib/ltr/src/test-files/featureExamples/external_features.json @@ -1,24 +1,24 @@ [ { "name" : "matchedTitle", - "type" : "org.apache.solr.ltr.feature.impl.SolrFeature", + "class" : "org.apache.solr.ltr.feature.impl.SolrFeature", "params" : { "q" : "{!terms f=title}${user_query}" } }, { "name" : "confidence", - "type" : "org.apache.solr.ltr.feature.impl.ValueFeature", + "class" : "org.apache.solr.ltr.feature.impl.ValueFeature", "store": "fstore2", "params" : { "value" : "${myconf}" } }, { "name":"originalScore", - "type":"org.apache.solr.ltr.feature.impl.OriginalScoreFeature", + "class":"org.apache.solr.ltr.feature.impl.OriginalScoreFeature", "store": "fstore2", "params":{} }, { "name" : "occurrences", - "type" : "org.apache.solr.ltr.feature.impl.ValueFeature", + "class" : "org.apache.solr.ltr.feature.impl.ValueFeature", "store": "fstore3", "params" : { "value" : "${myOcc}", @@ -26,12 +26,12 @@ } }, { "name":"originalScore", - "type":"org.apache.solr.ltr.feature.impl.OriginalScoreFeature", + "class":"org.apache.solr.ltr.feature.impl.OriginalScoreFeature", "store": "fstore3", "params":{} }, { "name" : "popularity", - "type" : "org.apache.solr.ltr.feature.impl.ValueFeature", + "class" : "org.apache.solr.ltr.feature.impl.ValueFeature", "store": "fstore4", "params" : { "value" : "${myPop}", @@ -39,13 +39,13 @@ } }, { "name":"originalScore", - "type":"org.apache.solr.ltr.feature.impl.OriginalScoreFeature", + "class":"org.apache.solr.ltr.feature.impl.OriginalScoreFeature", "store": "fstore4", "params":{} }, { "name" : "titlePhraseMatch", - "type" : "org.apache.solr.ltr.feature.impl.SolrFeature", + "class" : "org.apache.solr.ltr.feature.impl.SolrFeature", "params" : { "q" : "{!field f=title}${user_query}" } -} ] \ No newline at end of file +} ] diff --git a/solr/contrib/ltr/src/test-files/featureExamples/external_features_for_sparse_processing.json b/solr/contrib/ltr/src/test-files/featureExamples/external_features_for_sparse_processing.json index 074080fa07bc..a6c0e7b0f706 100644 --- a/solr/contrib/ltr/src/test-files/featureExamples/external_features_for_sparse_processing.json +++ b/solr/contrib/ltr/src/test-files/featureExamples/external_features_for_sparse_processing.json @@ -1,13 +1,13 @@ [{ "name" : "user_device_smartphone", - "type":"org.apache.solr.ltr.feature.impl.ValueFeature", + "class":"org.apache.solr.ltr.feature.impl.ValueFeature", "params" : { "value": "${user_device_smartphone}" } }, { "name" : "user_device_tablet", - "type":"org.apache.solr.ltr.feature.impl.ValueFeature", + "class":"org.apache.solr.ltr.feature.impl.ValueFeature", "params" : { "value": "${user_device_tablet}" } @@ -15,4 +15,4 @@ -] \ No newline at end of file +] diff --git a/solr/contrib/ltr/src/test-files/featureExamples/features-file-simple-params.json b/solr/contrib/ltr/src/test-files/featureExamples/features-file-simple-params.json index 023f25e452f1..007dcee7a1c7 100644 --- a/solr/contrib/ltr/src/test-files/featureExamples/features-file-simple-params.json +++ b/solr/contrib/ltr/src/test-files/featureExamples/features-file-simple-params.json @@ -1,7 +1,7 @@ [ { "name": "constant", - "type": "org.apache.solr.ltr.feature.impl.ValueFeature", + "class": "org.apache.solr.ltr.feature.impl.ValueFeature", "params": { "value": 100, "complex":{ @@ -9,4 +9,4 @@ } } } -] \ No newline at end of file +] diff --git a/solr/contrib/ltr/src/test-files/featureExamples/features-file-simple.json b/solr/contrib/ltr/src/test-files/featureExamples/features-file-simple.json index 601d3dd5f3b0..a4326c7d175a 100644 --- a/solr/contrib/ltr/src/test-files/featureExamples/features-file-simple.json +++ b/solr/contrib/ltr/src/test-files/featureExamples/features-file-simple.json @@ -1,6 +1,6 @@ [ { "name":"constant"; - "type":"org.apache.solr.ltr.feature.impl.ValueFeature" + "class":"org.apache.solr.ltr.feature.impl.ValueFeature" } -] \ No newline at end of file +] diff --git a/solr/contrib/ltr/src/test-files/featureExamples/features-ranksvm-efi.json b/solr/contrib/ltr/src/test-files/featureExamples/features-ranksvm-efi.json index 666e464ec773..9f12d2139039 100644 --- a/solr/contrib/ltr/src/test-files/featureExamples/features-ranksvm-efi.json +++ b/solr/contrib/ltr/src/test-files/featureExamples/features-ranksvm-efi.json @@ -1,17 +1,17 @@ [ { "name": "sampleConstant", - "type": "org.apache.solr.ltr.feature.impl.ValueFeature", + "class": "org.apache.solr.ltr.feature.impl.ValueFeature", "params": { "value": 5 } }, { "name" : "search_number_of_nights", - "type":"org.apache.solr.ltr.feature.impl.ValueFeature", + "class":"org.apache.solr.ltr.feature.impl.ValueFeature", "params" : { "value": "${search_number_of_nights}" } } -] \ No newline at end of file +] diff --git a/solr/contrib/ltr/src/test-files/featureExamples/features-ranksvm.json b/solr/contrib/ltr/src/test-files/featureExamples/features-ranksvm.json index b3405fc6f091..012c30c23a83 100644 --- a/solr/contrib/ltr/src/test-files/featureExamples/features-ranksvm.json +++ b/solr/contrib/ltr/src/test-files/featureExamples/features-ranksvm.json @@ -1,51 +1,51 @@ [ { "name": "title", - "type": "org.apache.solr.ltr.feature.impl.ValueFeature", + "class": "org.apache.solr.ltr.feature.impl.ValueFeature", "params": { "value": 1 } }, { "name": "description", - "type": "org.apache.solr.ltr.feature.impl.ValueFeature", + "class": "org.apache.solr.ltr.feature.impl.ValueFeature", "params": { "value": 2 } }, { "name": "keywords", - "type": "org.apache.solr.ltr.feature.impl.ValueFeature", + "class": "org.apache.solr.ltr.feature.impl.ValueFeature", "params": { "value": 2 } }, { "name": "popularity", - "type": "org.apache.solr.ltr.feature.impl.ValueFeature", + "class": "org.apache.solr.ltr.feature.impl.ValueFeature", "params": { "value": 3 } }, { "name": "text", - "type": "org.apache.solr.ltr.feature.impl.ValueFeature", + "class": "org.apache.solr.ltr.feature.impl.ValueFeature", "params": { "value": 4 } }, { "name": "queryIntentPerson", - "type": "org.apache.solr.ltr.feature.impl.ValueFeature", + "class": "org.apache.solr.ltr.feature.impl.ValueFeature", "params": { "value": 5 } }, { "name": "queryIntentCompany", - "type": "org.apache.solr.ltr.feature.impl.ValueFeature", + "class": "org.apache.solr.ltr.feature.impl.ValueFeature", "params": { "value": 5 } } -] \ No newline at end of file +] diff --git a/solr/contrib/ltr/src/test-files/featureExamples/features-store-test-model.json b/solr/contrib/ltr/src/test-files/featureExamples/features-store-test-model.json index 4161c68d997a..a05516456a14 100644 --- a/solr/contrib/ltr/src/test-files/featureExamples/features-store-test-model.json +++ b/solr/contrib/ltr/src/test-files/featureExamples/features-store-test-model.json @@ -1,7 +1,7 @@ [ { "name": "constant1", - "type": "org.apache.solr.ltr.feature.impl.ValueFeature", + "class": "org.apache.solr.ltr.feature.impl.ValueFeature", "store":"test", "params": { "value": 1 @@ -9,7 +9,7 @@ }, { "name": "constant2", - "type": "org.apache.solr.ltr.feature.impl.ValueFeature", + "class": "org.apache.solr.ltr.feature.impl.ValueFeature", "store":"test", "params": { "value": 2 @@ -17,7 +17,7 @@ }, { "name": "constant3", - "type": "org.apache.solr.ltr.feature.impl.ValueFeature", + "class": "org.apache.solr.ltr.feature.impl.ValueFeature", "store":"test", "params": { "value": 3 @@ -25,7 +25,7 @@ }, { "name": "constant4", - "type": "org.apache.solr.ltr.feature.impl.ValueFeature", + "class": "org.apache.solr.ltr.feature.impl.ValueFeature", "store":"test", "params": { "value": 4 @@ -33,7 +33,7 @@ }, { "name": "constant5", - "type": "org.apache.solr.ltr.feature.impl.ValueFeature", + "class": "org.apache.solr.ltr.feature.impl.ValueFeature", "store":"test", "params": { "value": 5 @@ -41,11 +41,11 @@ }, { "name": "pop", - "type": "org.apache.solr.ltr.feature.impl.FieldValueFeature", + "class": "org.apache.solr.ltr.feature.impl.FieldValueFeature", "store":"test", "params": { "field": "popularity" } } -] \ No newline at end of file +] diff --git a/solr/contrib/ltr/src/test-files/featureExamples/features.json b/solr/contrib/ltr/src/test-files/featureExamples/features.json index 624f6100d599..2dd2cecfe349 100644 --- a/solr/contrib/ltr/src/test-files/featureExamples/features.json +++ b/solr/contrib/ltr/src/test-files/featureExamples/features.json @@ -1,6 +1,6 @@ [ -{ "name": "comp_industryTermScorer", "type": "org.apache.solr.ltr.feature.impl.SolrFeature", "params": {"q": "${user_query}","df": "comp_industry"}}, -{ "name": "comp_strongKeywordsTermScorer", "type": "org.apache.solr.ltr.feature.impl.SolrFeature", "params": {"q": "${user_query}","df": "comp_strongKeywords"}} +{ "name": "comp_industryTermScorer", "class": "org.apache.solr.ltr.feature.impl.SolrFeature", "params": {"q": "${user_query}","df": "comp_industry"}}, +{ "name": "comp_strongKeywordsTermScorer", "class": "org.apache.solr.ltr.feature.impl.SolrFeature", "params": {"q": "${user_query}","df": "comp_strongKeywords"}} -] \ No newline at end of file +] diff --git a/solr/contrib/ltr/src/test-files/featureExamples/lambdamart_features.json b/solr/contrib/ltr/src/test-files/featureExamples/lambdamart_features.json index 6f6400a6aa2c..38981de096b7 100644 --- a/solr/contrib/ltr/src/test-files/featureExamples/lambdamart_features.json +++ b/solr/contrib/ltr/src/test-files/featureExamples/lambdamart_features.json @@ -1,14 +1,14 @@ [ { "name": "matchedTitle", - "type": "org.apache.solr.ltr.feature.impl.SolrFeature", + "class": "org.apache.solr.ltr.feature.impl.SolrFeature", "params": { "q": "{!terms f=title}${user_query}" } }, { "name": "constantScoreToForceLambdaMARTScoreAllDocs", - "type": "org.apache.solr.ltr.feature.impl.ValueFeature", + "class": "org.apache.solr.ltr.feature.impl.ValueFeature", "params": { "value": 1 } diff --git a/solr/contrib/ltr/src/test-files/modelExamples/external_model.json b/solr/contrib/ltr/src/test-files/modelExamples/external_model.json index ca3a18666280..ced9761ef360 100644 --- a/solr/contrib/ltr/src/test-files/modelExamples/external_model.json +++ b/solr/contrib/ltr/src/test-files/modelExamples/external_model.json @@ -1,5 +1,5 @@ { - "type":"org.apache.solr.ltr.ranking.RankSVMModel", + "class":"org.apache.solr.ltr.ranking.RankSVMModel", "name":"externalmodel", "features":[ { "name": "matchedTitle"} diff --git a/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model.json b/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model.json index 91b1e047ea14..414624e036ed 100644 --- a/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model.json +++ b/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model.json @@ -1,5 +1,5 @@ { - "type":"org.apache.solr.ltr.ranking.LambdaMARTModel", + "class":"org.apache.solr.ltr.ranking.LambdaMARTModel", "name":"lambdamartmodel", "features":[ { "name": "matchedTitle"}, diff --git a/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_external_binary_features.json b/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_external_binary_features.json index 970f165a1f79..3baff188aaf1 100644 --- a/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_external_binary_features.json +++ b/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_external_binary_features.json @@ -1,5 +1,5 @@ { - "type":"org.apache.solr.ltr.ranking.LambdaMARTModel", + "class":"org.apache.solr.ltr.ranking.LambdaMARTModel", "name":"external_model_binary_feature", "features":[ { "name": "user_device_smartphone"}, @@ -35,4 +35,4 @@ }} ] } -} \ No newline at end of file +} diff --git a/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_feature.json b/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_feature.json index 24499890f58c..e162d40a0b7a 100644 --- a/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_feature.json +++ b/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_feature.json @@ -1,5 +1,5 @@ { - "type":"org.apache.solr.ltr.ranking.LambdaMARTModel", + "class":"org.apache.solr.ltr.ranking.LambdaMARTModel", "name":"lambdamartmodel_no_feature", "features":[ { "name": "matchedTitle"}, diff --git a/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_features.json b/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_features.json index e0164c4bc7f6..02ff419d8b15 100644 --- a/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_features.json +++ b/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_features.json @@ -1,5 +1,5 @@ { - "type":"org.apache.solr.ltr.ranking.LambdaMARTModel", + "class":"org.apache.solr.ltr.ranking.LambdaMARTModel", "name":"lambdamartmodel_no_features", "params":{ "trees": [ diff --git a/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_left.json b/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_left.json index 3c3f89588b0b..d43f8fd948ee 100644 --- a/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_left.json +++ b/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_left.json @@ -1,5 +1,5 @@ { - "type":"org.apache.solr.ltr.ranking.LambdaMARTModel", + "class":"org.apache.solr.ltr.ranking.LambdaMARTModel", "name":"lambdamartmodel_no_left", "features":[ { "name": "matchedTitle"}, diff --git a/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_params.json b/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_params.json index b11e0a8652f5..928f6f81b7eb 100644 --- a/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_params.json +++ b/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_params.json @@ -1,5 +1,5 @@ { - "type":"org.apache.solr.ltr.ranking.LambdaMARTModel", + "class":"org.apache.solr.ltr.ranking.LambdaMARTModel", "name":"lambdamartmodel_no_params", "features":[ { "name": "matchedTitle"}, diff --git a/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_right.json b/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_right.json index 70f78ce8f6ac..4d9f080af276 100644 --- a/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_right.json +++ b/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_right.json @@ -1,5 +1,5 @@ { - "type":"org.apache.solr.ltr.ranking.LambdaMARTModel", + "class":"org.apache.solr.ltr.ranking.LambdaMARTModel", "name":"lambdamartmodel_no_right", "features":[ { "name": "matchedTitle"}, diff --git a/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_threshold.json b/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_threshold.json index 3982e06f5199..27e25331eb66 100644 --- a/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_threshold.json +++ b/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_threshold.json @@ -1,5 +1,5 @@ { - "type":"org.apache.solr.ltr.ranking.LambdaMARTModel", + "class":"org.apache.solr.ltr.ranking.LambdaMARTModel", "name":"lambdamartmodel_no_threshold", "features":[ { "name": "matchedTitle"}, diff --git a/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_tree.json b/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_tree.json index 148e2f056eec..dbe08c0deb75 100644 --- a/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_tree.json +++ b/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_tree.json @@ -1,5 +1,5 @@ { - "type":"org.apache.solr.ltr.ranking.LambdaMARTModel", + "class":"org.apache.solr.ltr.ranking.LambdaMARTModel", "name":"lambdamartmodel_no_tree", "features":[ { "name": "matchedTitle"}, diff --git a/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_trees.json b/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_trees.json index 72d744965b58..d996858e63f2 100644 --- a/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_trees.json +++ b/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_trees.json @@ -1,5 +1,5 @@ { - "type":"org.apache.solr.ltr.ranking.LambdaMARTModel", + "class":"org.apache.solr.ltr.ranking.LambdaMARTModel", "name":"lambdamartmodel_no_trees", "features":[ { "name": "matchedTitle"}, diff --git a/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_weight.json b/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_weight.json index bd5ffefb54f4..24617849d23a 100644 --- a/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_weight.json +++ b/solr/contrib/ltr/src/test-files/modelExamples/lambdamart_model_no_weight.json @@ -1,5 +1,5 @@ { - "type":"org.apache.solr.ltr.ranking.LambdaMARTModel", + "class":"org.apache.solr.ltr.ranking.LambdaMARTModel", "name":"lambdamartmodel_no_weight", "features":[ { "name": "matchedTitle"}, diff --git a/solr/contrib/ltr/src/test-files/modelExamples/ranksvm-model.json b/solr/contrib/ltr/src/test-files/modelExamples/ranksvm-model.json index c6b2baeeab35..341b2ddf2273 100644 --- a/solr/contrib/ltr/src/test-files/modelExamples/ranksvm-model.json +++ b/solr/contrib/ltr/src/test-files/modelExamples/ranksvm-model.json @@ -1,5 +1,5 @@ { - "type":"org.apache.solr.ltr.ranking.RankSVMModel", + "class":"org.apache.solr.ltr.ranking.RankSVMModel", "name":"6029760550880411648", "features":[ {"name":"title"}, @@ -8,7 +8,7 @@ { "name":"popularity", "norm": { - "type":"org.apache.solr.ltr.feature.norm.impl.MinMaxNormalizer", + "class":"org.apache.solr.ltr.feature.norm.impl.MinMaxNormalizer", "params":{ "min":"0.0f", "max":"10.0f" } } }, @@ -27,4 +27,4 @@ "queryIntentCompany":0.12121211 } } -} \ No newline at end of file +} diff --git a/solr/contrib/ltr/src/test-files/modelExamples/svm-model-efi.json b/solr/contrib/ltr/src/test-files/modelExamples/svm-model-efi.json index 651ca38f4e08..4af142ab5c1d 100644 --- a/solr/contrib/ltr/src/test-files/modelExamples/svm-model-efi.json +++ b/solr/contrib/ltr/src/test-files/modelExamples/svm-model-efi.json @@ -1,5 +1,5 @@ { - "type":"org.apache.solr.ltr.ranking.RankSVMModel", + "class":"org.apache.solr.ltr.ranking.RankSVMModel", "name":"svm-efi", "features":[ {"name":"sampleConstant"}, @@ -11,4 +11,4 @@ "search_number_of_nights":2.0 } } -} \ No newline at end of file +} diff --git a/solr/contrib/ltr/src/test-files/modelExamples/svm-model-normalized.json b/solr/contrib/ltr/src/test-files/modelExamples/svm-model-normalized.json index 1aec25098531..bd19586f47dc 100644 --- a/solr/contrib/ltr/src/test-files/modelExamples/svm-model-normalized.json +++ b/solr/contrib/ltr/src/test-files/modelExamples/svm-model-normalized.json @@ -1,11 +1,11 @@ { - "type":"org.apache.solr.ltr.ranking.RankSVMModel", + "class":"org.apache.solr.ltr.ranking.RankSVMModel", "name":"norm2", "features":[ { "name":"feature2normalize", "norm": { - "type":"org.apache.solr.ltr.feature.norm.impl.StandardNormalizer", + "class":"org.apache.solr.ltr.feature.norm.impl.StandardNormalizer", "params":{ "avg":0.0, diff --git a/solr/contrib/ltr/src/test-files/modelExamples/svm-model.json b/solr/contrib/ltr/src/test-files/modelExamples/svm-model.json index f22f87ff0962..e03ed8ded6f2 100644 --- a/solr/contrib/ltr/src/test-files/modelExamples/svm-model.json +++ b/solr/contrib/ltr/src/test-files/modelExamples/svm-model.json @@ -1,5 +1,5 @@ { - "type":"org.apache.solr.ltr.ranking.RankSVMModel", + "class":"org.apache.solr.ltr.ranking.RankSVMModel", "name":"svm", "features":[ {"name":"constant1"}, @@ -17,4 +17,4 @@ "constant5":5 } } -} \ No newline at end of file +} diff --git a/solr/contrib/ltr/src/test-files/modelExamples/svm-model1.json b/solr/contrib/ltr/src/test-files/modelExamples/svm-model1.json index b24d32e8cb54..ea41ad273160 100644 --- a/solr/contrib/ltr/src/test-files/modelExamples/svm-model1.json +++ b/solr/contrib/ltr/src/test-files/modelExamples/svm-model1.json @@ -1,5 +1,5 @@ { - "type":"org.apache.solr.ltr.ranking.RankSVMModel, + "class":"org.apache.solr.ltr.ranking.RankSVMModel, "name":"svm1", "features":[ {"name":"constant2"}, @@ -11,4 +11,4 @@ "constant4":6, } } -} \ No newline at end of file +} diff --git a/solr/contrib/ltr/src/test-files/modelExamples/svm-sum-model.json b/solr/contrib/ltr/src/test-files/modelExamples/svm-sum-model.json index 733e73886cb4..971cc5eeac17 100644 --- a/solr/contrib/ltr/src/test-files/modelExamples/svm-sum-model.json +++ b/solr/contrib/ltr/src/test-files/modelExamples/svm-sum-model.json @@ -1,5 +1,5 @@ { - "type":"org.apache.solr.ltr.ranking.RankSVMModel", + "class":"org.apache.solr.ltr.ranking.RankSVMModel", "name":"sum", "features":[ {"name":"constant1"}, diff --git a/solr/contrib/ltr/src/test/org/apache/solr/ltr/TestRerankBase.java b/solr/contrib/ltr/src/test/org/apache/solr/ltr/TestRerankBase.java index b4a3ce422625..d8d0bf5a52f3 100644 --- a/solr/contrib/ltr/src/test/org/apache/solr/ltr/TestRerankBase.java +++ b/solr/contrib/ltr/src/test/org/apache/solr/ltr/TestRerankBase.java @@ -205,7 +205,7 @@ public static String getModelInJson(String name, String type, sb.append("\"name\":").append('"').append(name).append('"').append(",\n"); sb.append("\"store\":").append('"').append(fstore).append('"') .append(",\n"); - sb.append("\"type\":").append('"').append(type).append('"').append(",\n"); + sb.append("\"class\":").append('"').append(type).append('"').append(",\n"); sb.append("\"features\":").append('['); for (final String feature : features) { sb.append("\n\t{ "); @@ -230,7 +230,7 @@ public static String getFeatureInJson(String name, String type, sb.append("\"name\":").append('"').append(name).append('"').append(",\n"); sb.append("\"store\":").append('"').append(fstore).append('"') .append(",\n"); - sb.append("\"type\":").append('"').append(type).append('"'); + sb.append("\"class\":").append('"').append(type).append('"'); if (params != null) { sb.append(",\n"); sb.append("\"params\":").append(params); diff --git a/solr/contrib/ltr/src/test/org/apache/solr/ltr/rest/TestModelManager.java b/solr/contrib/ltr/src/test/org/apache/solr/ltr/rest/TestModelManager.java index 8a683e408baf..8e725df7eeaf 100644 --- a/solr/contrib/ltr/src/test/org/apache/solr/ltr/rest/TestModelManager.java +++ b/solr/contrib/ltr/src/test/org/apache/solr/ltr/rest/TestModelManager.java @@ -84,48 +84,48 @@ public void testRestManagerEndpoints() throws Exception { System.out.println("after: \n" + restTestHarness.query("/schema/managed")); // Add features - String feature = "{\"name\": \"test1\", \"type\": \"org.apache.solr.ltr.feature.impl.ValueFeature\", \"params\": {\"value\": 1} }"; + String feature = "{\"name\": \"test1\", \"class\": \"org.apache.solr.ltr.feature.impl.ValueFeature\", \"params\": {\"value\": 1} }"; assertJPut(CommonLTRParams.FEATURE_STORE_END_POINT, feature, "/responseHeader/status==0"); - feature = "{\"name\": \"test2\", \"type\": \"org.apache.solr.ltr.feature.impl.ValueFeature\", \"params\": {\"value\": 1} }"; + feature = "{\"name\": \"test2\", \"class\": \"org.apache.solr.ltr.feature.impl.ValueFeature\", \"params\": {\"value\": 1} }"; assertJPut(CommonLTRParams.FEATURE_STORE_END_POINT, feature, "/responseHeader/status==0"); - feature = "{\"name\": \"test3\", \"type\": \"org.apache.solr.ltr.feature.impl.ValueFeature\", \"params\": {\"value\": 1} }"; + feature = "{\"name\": \"test3\", \"class\": \"org.apache.solr.ltr.feature.impl.ValueFeature\", \"params\": {\"value\": 1} }"; assertJPut(CommonLTRParams.FEATURE_STORE_END_POINT, feature, "/responseHeader/status==0"); - feature = "{\"name\": \"test33\", \"store\": \"TEST\", \"type\": \"org.apache.solr.ltr.feature.impl.ValueFeature\", \"params\": {\"value\": 1} }"; + feature = "{\"name\": \"test33\", \"store\": \"TEST\", \"class\": \"org.apache.solr.ltr.feature.impl.ValueFeature\", \"params\": {\"value\": 1} }"; assertJPut(CommonLTRParams.FEATURE_STORE_END_POINT, feature, "/responseHeader/status==0"); - final String multipleFeatures = "[{\"name\": \"test4\", \"type\": \"org.apache.solr.ltr.feature.impl.ValueFeature\", \"params\": {\"value\": 1} }" - + ",{\"name\": \"test5\", \"type\": \"org.apache.solr.ltr.feature.impl.ValueFeature\", \"params\": {\"value\": 1} } ]"; + final String multipleFeatures = "[{\"name\": \"test4\", \"class\": \"org.apache.solr.ltr.feature.impl.ValueFeature\", \"params\": {\"value\": 1} }" + + ",{\"name\": \"test5\", \"class\": \"org.apache.solr.ltr.feature.impl.ValueFeature\", \"params\": {\"value\": 1} } ]"; assertJPut(CommonLTRParams.FEATURE_STORE_END_POINT, multipleFeatures, "/responseHeader/status==0"); // Add bad feature (wrong params)_ - final String badfeature = "{\"name\": \"fvalue\", \"type\": \"org.apache.solr.ltr.feature.impl.FieldValueFeature\", \"params\": {\"value\": 1} }"; + final String badfeature = "{\"name\": \"fvalue\", \"class\": \"org.apache.solr.ltr.feature.impl.FieldValueFeature\", \"params\": {\"value\": 1} }"; assertJPut(CommonLTRParams.FEATURE_STORE_END_POINT, badfeature, "/responseHeader/status==400"); // Add models - String model = "{ \"name\":\"testmodel1\", \"type\":\"org.apache.solr.ltr.ranking.RankSVMModel\", \"features\":[] }"; + String model = "{ \"name\":\"testmodel1\", \"class\":\"org.apache.solr.ltr.ranking.RankSVMModel\", \"features\":[] }"; // fails since it does not have features assertJPut(CommonLTRParams.MODEL_STORE_END_POINT, model, "/responseHeader/status==400"); // fails since it does not have weights - model = "{ \"name\":\"testmodel2\", \"type\":\"org.apache.solr.ltr.ranking.RankSVMModel\", \"features\":[{\"name\":\"test1\"}, {\"name\":\"test2\"}] }"; + model = "{ \"name\":\"testmodel2\", \"class\":\"org.apache.solr.ltr.ranking.RankSVMModel\", \"features\":[{\"name\":\"test1\"}, {\"name\":\"test2\"}] }"; assertJPut(CommonLTRParams.MODEL_STORE_END_POINT, model, "/responseHeader/status==400"); // success - model = "{ \"name\":\"testmodel3\", \"type\":\"org.apache.solr.ltr.ranking.RankSVMModel\", \"features\":[{\"name\":\"test1\"}, {\"name\":\"test2\"}],\"params\":{\"weights\":{\"test1\":1.5,\"test2\":2.0}}}"; + model = "{ \"name\":\"testmodel3\", \"class\":\"org.apache.solr.ltr.ranking.RankSVMModel\", \"features\":[{\"name\":\"test1\"}, {\"name\":\"test2\"}],\"params\":{\"weights\":{\"test1\":1.5,\"test2\":2.0}}}"; assertJPut(CommonLTRParams.MODEL_STORE_END_POINT, model, "/responseHeader/status==0"); // success - final String multipleModels = "[{ \"name\":\"testmodel4\", \"type\":\"org.apache.solr.ltr.ranking.RankSVMModel\", \"features\":[{\"name\":\"test1\"}, {\"name\":\"test2\"}],\"params\":{\"weights\":{\"test1\":1.5,\"test2\":2.0}} }\n" - + ",{ \"name\":\"testmodel5\", \"type\":\"org.apache.solr.ltr.ranking.RankSVMModel\", \"features\":[{\"name\":\"test1\"}, {\"name\":\"test2\"}],\"params\":{\"weights\":{\"test1\":1.5,\"test2\":2.0}} } ]"; + final String multipleModels = "[{ \"name\":\"testmodel4\", \"class\":\"org.apache.solr.ltr.ranking.RankSVMModel\", \"features\":[{\"name\":\"test1\"}, {\"name\":\"test2\"}],\"params\":{\"weights\":{\"test1\":1.5,\"test2\":2.0}} }\n" + + ",{ \"name\":\"testmodel5\", \"class\":\"org.apache.solr.ltr.ranking.RankSVMModel\", \"features\":[{\"name\":\"test1\"}, {\"name\":\"test2\"}],\"params\":{\"weights\":{\"test1\":1.5,\"test2\":2.0}} } ]"; assertJPut(CommonLTRParams.MODEL_STORE_END_POINT, multipleModels, "/responseHeader/status==0"); final String qryResult = JQ(CommonLTRParams.MODEL_STORE_END_POINT);