Search in sources :

Example 31 with NamedList

use of org.apache.solr.common.util.NamedList in project lucene-solr by apache.

the class CarrotClusteringEngineTest method testOtherTopics.

@Test
public void testOtherTopics() throws Exception {
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.set(AttributeUtils.getKey(MockClusteringAlgorithm.class, "depth"), 1);
    params.set(AttributeUtils.getKey(MockClusteringAlgorithm.class, "otherTopicsModulo"), 2);
    List<NamedList<Object>> clusters = checkEngine(getClusteringEngine("mock"), AbstractClusteringTestCase.numberOfDocs, params);
    int i = 1;
    for (NamedList<Object> cluster : clusters) {
        assertEquals(i++ % 2 == 0 ? true : null, isOtherTopics(cluster));
    }
}
Also used : NamedList(org.apache.solr.common.util.NamedList) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) Test(org.junit.Test)

Example 32 with NamedList

use of org.apache.solr.common.util.NamedList in project lucene-solr by apache.

the class CarrotClusteringEngineTest method testClusterScores.

@Test
public void testClusterScores() throws Exception {
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.set(AttributeUtils.getKey(MockClusteringAlgorithm.class, "depth"), 1);
    List<NamedList<Object>> clusters = checkEngine(getClusteringEngine("mock"), AbstractClusteringTestCase.numberOfDocs, params);
    int i = 1;
    for (NamedList<Object> cluster : clusters) {
        final Double score = getScore(cluster);
        assertNotNull(score);
        assertEquals(0.25 * i++, score, 0);
    }
}
Also used : NamedList(org.apache.solr.common.util.NamedList) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) Test(org.junit.Test)

Example 33 with NamedList

use of org.apache.solr.common.util.NamedList in project lucene-solr by apache.

the class CarrotClusteringEngineTest method checkLexicalResourcesFromSolrConfig.

private void checkLexicalResourcesFromSolrConfig(String engineName, String wordsToCheck) throws IOException {
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.set("merge-resources", false);
    params.set(AttributeUtils.getKey(LexicalResourcesCheckClusteringAlgorithm.class, "wordsToCheck"), wordsToCheck);
    // "customsolrstopword" is in stopwords.en, "customsolrstoplabel" is in
    // stoplabels.mt, so we're expecting only one cluster with label "online".
    final List<NamedList<Object>> clusters = checkEngine(getClusteringEngine(engineName), 1, params);
    assertEquals(getLabels(clusters.get(0)), Collections.singletonList("online"));
}
Also used : NamedList(org.apache.solr.common.util.NamedList) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams)

Example 34 with NamedList

use of org.apache.solr.common.util.NamedList in project lucene-solr by apache.

the class CarrotClusteringEngineTest method testSolrStopWordsUsedInCarrot2Clustering.

@Test
public void testSolrStopWordsUsedInCarrot2Clustering() throws Exception {
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.set("merge-resources", false);
    params.set(AttributeUtils.getKey(LexicalResourcesCheckClusteringAlgorithm.class, "wordsToCheck"), "online,solrownstopword");
    // "solrownstopword" is in stopwords.txt, so we're expecting
    // only one cluster with label "online".
    final List<NamedList<Object>> clusters = checkEngine(getClusteringEngine("lexical-resource-check"), 1, params);
    assertEquals(getLabels(clusters.get(0)), Collections.singletonList("online"));
}
Also used : NamedList(org.apache.solr.common.util.NamedList) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) Test(org.junit.Test)

Example 35 with NamedList

use of org.apache.solr.common.util.NamedList in project lucene-solr by apache.

the class LTRThreadModule method extractThreadModuleParams.

private static NamedList extractThreadModuleParams(NamedList args) {
    // gather the thread module args from amongst the general args
    final NamedList extractedArgs = new NamedList();
    for (Iterator<Map.Entry<String, Object>> it = args.iterator(); it.hasNext(); ) {
        final Map.Entry<String, Object> entry = it.next();
        final String key = entry.getKey();
        if (key.startsWith(CONFIG_PREFIX)) {
            extractedArgs.add(key.substring(CONFIG_PREFIX.length()), entry.getValue());
        }
    }
    // since NamedList iterator does not support 'remove'
    for (Object key : extractedArgs.asShallowMap().keySet()) {
        args.remove(CONFIG_PREFIX + key);
    }
    return extractedArgs;
}
Also used : NamedList(org.apache.solr.common.util.NamedList) Map(java.util.Map)

Aggregations

NamedList (org.apache.solr.common.util.NamedList)440 Test (org.junit.Test)125 ArrayList (java.util.ArrayList)111 Map (java.util.Map)83 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)83 SolrException (org.apache.solr.common.SolrException)80 SimpleOrderedMap (org.apache.solr.common.util.SimpleOrderedMap)79 List (java.util.List)76 HashMap (java.util.HashMap)65 SolrQueryResponse (org.apache.solr.response.SolrQueryResponse)55 IOException (java.io.IOException)53 SolrDocumentList (org.apache.solr.common.SolrDocumentList)45 QueryRequest (org.apache.solr.client.solrj.request.QueryRequest)35 SolrQueryRequest (org.apache.solr.request.SolrQueryRequest)35 SolrParams (org.apache.solr.common.params.SolrParams)31 LocalSolrQueryRequest (org.apache.solr.request.LocalSolrQueryRequest)31 QueryResponse (org.apache.solr.client.solrj.response.QueryResponse)30 SolrCore (org.apache.solr.core.SolrCore)30 HttpSolrClient (org.apache.solr.client.solrj.impl.HttpSolrClient)27 SolrIndexSearcher (org.apache.solr.search.SolrIndexSearcher)27