use of org.apache.solr.ltr.store.FeatureStore in project lucene-solr by apache.
the class ManagedModelStore method fromLTRScoringModelMap.
@SuppressWarnings("unchecked")
public static LTRScoringModel fromLTRScoringModelMap(SolrResourceLoader solrResourceLoader, Map<String, Object> modelMap, ManagedFeatureStore managedFeatureStore) {
final FeatureStore featureStore = managedFeatureStore.getFeatureStore((String) modelMap.get(STORE_KEY));
final List<Feature> features = new ArrayList<>();
final List<Normalizer> norms = new ArrayList<>();
final List<Object> featureList = (List<Object>) modelMap.get(FEATURES_KEY);
if (featureList != null) {
for (final Object feature : featureList) {
final Map<String, Object> featureMap = (Map<String, Object>) feature;
features.add(lookupFeatureFromFeatureMap(featureMap, featureStore));
norms.add(createNormalizerFromFeatureMap(solrResourceLoader, featureMap));
}
}
return LTRScoringModel.getInstance(solrResourceLoader, // modelClassName
(String) modelMap.get(CLASS_KEY), // modelName
(String) modelMap.get(NAME_KEY), features, norms, featureStore.getName(), featureStore.getFeatures(), (Map<String, Object>) modelMap.get(PARAMS_KEY));
}
use of org.apache.solr.ltr.store.FeatureStore in project lucene-solr by apache.
the class TestManagedFeatureStore method testFeatureStoreGet.
@Test
public void testFeatureStoreGet() throws FeatureException {
final FeatureStore fs = fstore.getFeatureStore("fstore-testFeature2");
for (int i = 0; i < 5; i++) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("value", i);
final String name = "c" + i;
fstore.addFeature(createMap(name, ValueFeature.class.getCanonicalName(), params), "fstore-testFeature2");
}
for (int i = 0; i < 5; i++) {
final Feature f = fs.get("c" + i);
assertEquals("c" + i, f.getName());
assertTrue(f instanceof ValueFeature);
final ValueFeature vf = (ValueFeature) f;
assertEquals(i, vf.getValue());
}
}
use of org.apache.solr.ltr.store.FeatureStore in project lucene-solr by apache.
the class TestManagedFeatureStore method testDefaultFeatureStoreName.
@Test
public void testDefaultFeatureStoreName() {
assertEquals("_DEFAULT_", FeatureStore.DEFAULT_FEATURE_STORE_NAME);
final FeatureStore expectedFeatureStore = fstore.getFeatureStore(FeatureStore.DEFAULT_FEATURE_STORE_NAME);
final FeatureStore actualFeatureStore = fstore.getFeatureStore(null);
assertEquals("getFeatureStore(null) should return the default feature store", expectedFeatureStore, actualFeatureStore);
}
Aggregations