Search in sources :

Example 96 with NamedList

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

the class PingRequestHandlerTest method before.

@Before
public void before() throws IOException {
    File tmpDir = initCoreDataDir;
    // by default, use relative file in dataDir
    healthcheckFile = new File(tmpDir, fileName);
    String fileNameParam = fileName;
    // sometimes randomly use an absolute File path instead 
    if (random().nextBoolean()) {
        healthcheckFile = new File(tmpDir, fileName);
        fileNameParam = healthcheckFile.getAbsolutePath();
    }
    if (healthcheckFile.exists())
        FileUtils.forceDelete(healthcheckFile);
    handler = new PingRequestHandler();
    NamedList initParams = new NamedList();
    initParams.add(PingRequestHandler.HEALTHCHECK_FILE_PARAM, fileNameParam);
    handler.init(initParams);
    handler.inform(h.getCore());
}
Also used : NamedList(org.apache.solr.common.util.NamedList) File(java.io.File) Before(org.junit.Before)

Example 97 with NamedList

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

the class AnalyticsMergeStrategyTest method assertCountOnly.

private void assertCountOnly(QueryResponse rsp, int count) throws Exception {
    NamedList response = rsp.getResponse();
    NamedList analytics = (NamedList) response.get("analytics");
    Integer c = (Integer) analytics.get("mycount");
    if (c.intValue() != count) {
        throw new Exception("Count is not correct:" + count + ":" + c.intValue());
    }
}
Also used : NamedList(org.apache.solr.common.util.NamedList)

Example 98 with NamedList

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

the class AnalyticsMergeStrategyTest method assertCount.

private void assertCount(QueryResponse rsp, int count) throws Exception {
    NamedList response = rsp.getResponse();
    NamedList analytics = (NamedList) response.get("analytics");
    Integer c = (Integer) analytics.get("mycount");
    if (c.intValue() != count) {
        throw new Exception("Count is not correct:" + count + ":" + c.intValue());
    }
    long numFound = rsp.getResults().getNumFound();
    if (c.intValue() != numFound) {
        throw new Exception("Count does not equal numFound:" + c.intValue() + ":" + numFound);
    }
}
Also used : NamedList(org.apache.solr.common.util.NamedList)

Example 99 with NamedList

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

the class DirectSolrSpellCheckerTest method test.

@Test
public void test() throws Exception {
    DirectSolrSpellChecker checker = new DirectSolrSpellChecker();
    NamedList spellchecker = new NamedList();
    spellchecker.add("classname", DirectSolrSpellChecker.class.getName());
    spellchecker.add(SolrSpellChecker.FIELD, "teststop");
    // we will try "fob"
    spellchecker.add(DirectSolrSpellChecker.MINQUERYLENGTH, 2);
    SolrCore core = h.getCore();
    checker.init(spellchecker, core);
    RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
    Collection<Token> tokens = queryConverter.convert("fob");
    SpellingOptions spellOpts = new SpellingOptions(tokens, searcher.get().getIndexReader());
    SpellingResult result = checker.getSuggestions(spellOpts);
    assertTrue("result is null and it shouldn't be", result != null);
    Map<String, Integer> suggestions = result.get(tokens.iterator().next());
    Map.Entry<String, Integer> entry = suggestions.entrySet().iterator().next();
    assertTrue(entry.getKey() + " is not equal to " + "foo", entry.getKey().equals("foo") == true);
    assertFalse(entry.getValue() + " equals: " + SpellingResult.NO_FREQUENCY_INFO, entry.getValue() == SpellingResult.NO_FREQUENCY_INFO);
    spellOpts.tokens = queryConverter.convert("super");
    result = checker.getSuggestions(spellOpts);
    assertTrue("result is null and it shouldn't be", result != null);
    suggestions = result.get(tokens.iterator().next());
    assertTrue("suggestions is not null and it should be", suggestions == null);
    searcher.decref();
}
Also used : NamedList(org.apache.solr.common.util.NamedList) SolrCore(org.apache.solr.core.SolrCore) Token(org.apache.lucene.analysis.Token) SolrIndexSearcher(org.apache.solr.search.SolrIndexSearcher) Map(java.util.Map) Test(org.junit.Test)

Example 100 with NamedList

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

the class FileBasedSpellCheckerTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    initCore("solrconfig.xml", "schema.xml");
    //Index something with a title
    assertNull(h.validateUpdate(adoc("id", "0", "teststop", "This is a title")));
    assertNull(h.validateUpdate(adoc("id", "1", "teststop", "The quick reb fox jumped over the lazy brown dogs.")));
    assertNull(h.validateUpdate(adoc("id", "2", "teststop", "This is a Solr")));
    assertNull(h.validateUpdate(adoc("id", "3", "teststop", "solr foo")));
    assertNull(h.validateUpdate(commit()));
    queryConverter = new SimpleQueryConverter();
    queryConverter.init(new NamedList());
}
Also used : NamedList(org.apache.solr.common.util.NamedList) BeforeClass(org.junit.BeforeClass)

Aggregations

NamedList (org.apache.solr.common.util.NamedList)438 Test (org.junit.Test)125 ArrayList (java.util.ArrayList)110 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)83 Map (java.util.Map)82 SolrException (org.apache.solr.common.SolrException)80 SimpleOrderedMap (org.apache.solr.common.util.SimpleOrderedMap)78 List (java.util.List)75 HashMap (java.util.HashMap)64 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