Search in sources :

Example 11 with Feature

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

the class TestRerankBase method getFeatures.

protected List<Feature> getFeatures(List<String> names) throws FeatureException {
    final List<Feature> features = new ArrayList<>();
    int pos = 0;
    for (final String name : names) {
        final Map<String, Object> params = new HashMap<String, Object>();
        params.put("value", 10);
        final Feature f = Feature.getInstance(solrResourceLoader, ValueFeature.class.getCanonicalName(), name, params);
        f.setIndex(pos);
        features.add(f);
        ++pos;
    }
    return features;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ValueFeature(org.apache.solr.ltr.feature.ValueFeature) ValueFeature(org.apache.solr.ltr.feature.ValueFeature) Feature(org.apache.solr.ltr.feature.Feature)

Example 12 with Feature

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

the class TestManagedFeatureStore method getInstanceTest.

@Test
public void getInstanceTest() throws FeatureException {
    fstore.addFeature(createMap("test", OriginalScoreFeature.class.getCanonicalName(), null), "testFstore");
    final Feature feature = fstore.getFeatureStore("testFstore").get("test");
    assertNotNull(feature);
    assertEquals("test", feature.getName());
    assertEquals(OriginalScoreFeature.class.getCanonicalName(), feature.getClass().getCanonicalName());
}
Also used : OriginalScoreFeature(org.apache.solr.ltr.feature.OriginalScoreFeature) ValueFeature(org.apache.solr.ltr.feature.ValueFeature) Feature(org.apache.solr.ltr.feature.Feature) OriginalScoreFeature(org.apache.solr.ltr.feature.OriginalScoreFeature) Test(org.junit.Test)

Example 13 with Feature

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

the class TestManagedFeatureStore method testFeatureStoreAdd.

@Test
public void testFeatureStoreAdd() throws FeatureException {
    final FeatureStore fs = fstore.getFeatureStore("fstore-testFeature");
    for (int i = 0; i < 5; i++) {
        final String name = "c" + i;
        fstore.addFeature(createMap(name, OriginalScoreFeature.class.getCanonicalName(), null), "fstore-testFeature");
        final Feature f = fs.get(name);
        assertNotNull(f);
    }
    assertEquals(5, fs.getFeatures().size());
}
Also used : ValueFeature(org.apache.solr.ltr.feature.ValueFeature) Feature(org.apache.solr.ltr.feature.Feature) OriginalScoreFeature(org.apache.solr.ltr.feature.OriginalScoreFeature) FeatureStore(org.apache.solr.ltr.store.FeatureStore) ManagedFeatureStore(org.apache.solr.ltr.store.rest.ManagedFeatureStore) Test(org.junit.Test)

Example 14 with Feature

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

the class TestSelectiveWeightCreation method makeFeatureWeights.

private static Map<String, Object> makeFeatureWeights(List<Feature> features) {
    final Map<String, Object> nameParams = new HashMap<String, Object>();
    final HashMap<String, Double> modelWeights = new HashMap<String, Double>();
    for (final Feature feat : features) {
        modelWeights.put(feat.getName(), 0.1);
    }
    nameParams.put("weights", modelWeights);
    return nameParams;
}
Also used : HashMap(java.util.HashMap) ValueFeature(org.apache.solr.ltr.feature.ValueFeature) Feature(org.apache.solr.ltr.feature.Feature)

Example 15 with Feature

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

the class TestSelectiveWeightCreation method makeFeatures.

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

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