mirror of https://github.com/apache/lucene.git
close up searchers in spellchecker tests
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1023579 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7f9f0bdf84
commit
a61e395774
|
@ -21,10 +21,11 @@ import java.util.Collection;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.lucene.analysis.Token;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.search.SolrIndexSearcher;
|
||||
import org.apache.solr.util.RefCounted;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -59,9 +60,9 @@ public class DirectSolrSpellCheckerTest extends SolrTestCaseJ4 {
|
|||
SolrCore core = h.getCore();
|
||||
checker.init(spellchecker, core);
|
||||
|
||||
IndexReader reader = core.getSearcher().get().getReader();
|
||||
RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
|
||||
Collection<Token> tokens = queryConverter.convert("fob");
|
||||
SpellingOptions spellOpts = new SpellingOptions(tokens, reader);
|
||||
SpellingOptions spellOpts = new SpellingOptions(tokens, searcher.get().getReader());
|
||||
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());
|
||||
|
@ -74,5 +75,6 @@ public class DirectSolrSpellCheckerTest extends SolrTestCaseJ4 {
|
|||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,8 @@ package org.apache.solr.spelling;
|
|||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.solr.search.SolrIndexSearcher;
|
||||
import org.apache.solr.util.RefCounted;
|
||||
import org.apache.lucene.analysis.Token;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -78,9 +79,9 @@ public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {
|
|||
assertTrue(dictName + " is not equal to " + "external", dictName.equals("external") == true);
|
||||
checker.build(core, null);
|
||||
|
||||
IndexReader reader = core.getSearcher().get().getReader();
|
||||
RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
|
||||
Collection<Token> tokens = queryConverter.convert("fob");
|
||||
SpellingOptions spellOpts = new SpellingOptions(tokens, reader);
|
||||
SpellingOptions spellOpts = new SpellingOptions(tokens, searcher.get().getReader());
|
||||
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());
|
||||
|
@ -93,7 +94,7 @@ public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {
|
|||
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();
|
||||
|
||||
}
|
||||
|
||||
|
@ -117,10 +118,10 @@ public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {
|
|||
assertTrue(dictName + " is not equal to " + "external", dictName.equals("external") == true);
|
||||
checker.build(core, null);
|
||||
|
||||
IndexReader reader = core.getSearcher().get().getReader();
|
||||
RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
|
||||
Collection<Token> tokens = queryConverter.convert("Solar");
|
||||
|
||||
SpellingOptions spellOpts = new SpellingOptions(tokens, reader);
|
||||
SpellingOptions spellOpts = new SpellingOptions(tokens, searcher.get().getReader());
|
||||
SpellingResult result = checker.getSuggestions(spellOpts);
|
||||
assertTrue("result is null and it shouldn't be", result != null);
|
||||
//should be lowercased, b/c we are using a lowercasing analyzer
|
||||
|
@ -136,6 +137,7 @@ public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {
|
|||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -161,9 +163,9 @@ public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {
|
|||
assertTrue(dictName + " is not equal to " + "external", dictName.equals("external") == true);
|
||||
checker.build(core, null);
|
||||
|
||||
IndexReader reader = core.getSearcher().get().getReader();
|
||||
RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
|
||||
Collection<Token> tokens = queryConverter.convert("solar");
|
||||
SpellingOptions spellOpts = new SpellingOptions(tokens, reader);
|
||||
SpellingOptions spellOpts = new SpellingOptions(tokens, searcher.get().getReader());
|
||||
SpellingResult result = checker.getSuggestions(spellOpts);
|
||||
assertTrue("result is null and it shouldn't be", result != null);
|
||||
//should be lowercased, b/c we are using a lowercasing analyzer
|
||||
|
@ -179,5 +181,6 @@ public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {
|
|||
assertTrue("result is null and it shouldn't be", result != null);
|
||||
suggestions = result.get(spellOpts.tokens.iterator().next());
|
||||
assertTrue("suggestions is not null and it should be", suggestions == null);
|
||||
searcher.decref();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.solr.core.SolrCore;
|
|||
import org.apache.solr.handler.component.SearchComponent;
|
||||
import org.apache.solr.handler.component.SpellCheckComponent;
|
||||
import org.apache.solr.request.LocalSolrQueryRequest;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.request.SolrRequestHandler;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -73,7 +74,9 @@ public class SpellCheckCollatorTest extends SolrTestCaseJ4 {
|
|||
SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
|
||||
SolrQueryResponse rsp = new SolrQueryResponse();
|
||||
rsp.add("responseHeader", new SimpleOrderedMap());
|
||||
handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
|
||||
SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
|
||||
handler.handleRequest(req, rsp);
|
||||
req.close();
|
||||
NamedList values = rsp.getValues();
|
||||
NamedList spellCheck = (NamedList) values.get("spellcheck");
|
||||
NamedList suggestions = (NamedList) spellCheck.get("suggestions");
|
||||
|
|
Loading…
Reference in New Issue