Search in sources :

Example 21 with Feature

use of org.apache.solr.ltr.feature.Feature 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));
}
Also used : Normalizer(org.apache.solr.ltr.norm.Normalizer) IdentityNormalizer(org.apache.solr.ltr.norm.IdentityNormalizer) ArrayList(java.util.ArrayList) NamedList(org.apache.solr.common.util.NamedList) ArrayList(java.util.ArrayList) List(java.util.List) Feature(org.apache.solr.ltr.feature.Feature) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) FeatureStore(org.apache.solr.ltr.store.FeatureStore)

Example 22 with Feature

use of org.apache.solr.ltr.feature.Feature in project lucene-solr by apache.

the class TestLTRReRankingPipeline method makeFieldValueFeatures.

private static List<Feature> makeFieldValueFeatures(int[] featureIds, String field) {
    final List<Feature> features = new ArrayList<>();
    for (final int i : featureIds) {
        final Map<String, Object> params = new HashMap<String, Object>();
        params.put("field", field);
        final Feature f = Feature.getInstance(solrResourceLoader, FieldValueFeature.class.getCanonicalName(), "f" + i, params);
        f.setIndex(i);
        features.add(f);
    }
    return features;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FieldValueFeature(org.apache.solr.ltr.feature.FieldValueFeature) Feature(org.apache.solr.ltr.feature.Feature) FieldValueFeature(org.apache.solr.ltr.feature.FieldValueFeature)

Aggregations

Feature (org.apache.solr.ltr.feature.Feature)22 ArrayList (java.util.ArrayList)15 ValueFeature (org.apache.solr.ltr.feature.ValueFeature)12 HashMap (java.util.HashMap)10 Test (org.junit.Test)9 IdentityNormalizer (org.apache.solr.ltr.norm.IdentityNormalizer)7 Normalizer (org.apache.solr.ltr.norm.Normalizer)7 LinkedHashMap (java.util.LinkedHashMap)5 LTRScoringModel (org.apache.solr.ltr.model.LTRScoringModel)5 Document (org.apache.lucene.document.Document)4 FloatDocValuesField (org.apache.lucene.document.FloatDocValuesField)4 IndexReader (org.apache.lucene.index.IndexReader)4 RandomIndexWriter (org.apache.lucene.index.RandomIndexWriter)4 Term (org.apache.lucene.index.Term)4 BooleanQuery (org.apache.lucene.search.BooleanQuery)4 IndexSearcher (org.apache.lucene.search.IndexSearcher)4 TermQuery (org.apache.lucene.search.TermQuery)4 TopDocs (org.apache.lucene.search.TopDocs)4 Directory (org.apache.lucene.store.Directory)4 FeatureStore (org.apache.solr.ltr.store.FeatureStore)4