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());
}
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());
}
}
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);
}
}
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();
}
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());
}
Aggregations