mirror of https://github.com/apache/lucene.git
avoid using deprecated QueryParser method
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@347995 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dea69e3360
commit
c78c2c8936
|
@ -27,7 +27,8 @@ import org.apache.lucene.search.Hits;
|
||||||
import org.apache.lucene.queryParser.QueryParser;
|
import org.apache.lucene.queryParser.QueryParser;
|
||||||
|
|
||||||
public class TestKeywordAnalyzer extends TestCase {
|
public class TestKeywordAnalyzer extends TestCase {
|
||||||
RAMDirectory directory;
|
|
||||||
|
private RAMDirectory directory;
|
||||||
private IndexSearcher searcher;
|
private IndexSearcher searcher;
|
||||||
|
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
@ -47,13 +48,11 @@ public class TestKeywordAnalyzer extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPerFieldAnalyzer() throws Exception {
|
public void testPerFieldAnalyzer() throws Exception {
|
||||||
PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper(
|
PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper(new SimpleAnalyzer());
|
||||||
new SimpleAnalyzer());
|
|
||||||
analyzer.addAnalyzer("partnum", new KeywordAnalyzer());
|
analyzer.addAnalyzer("partnum", new KeywordAnalyzer());
|
||||||
|
|
||||||
Query query = QueryParser.parse("partnum:Q36 AND SPACE",
|
QueryParser queryParser = new QueryParser("description", analyzer);
|
||||||
"description",
|
Query query = queryParser.parse("partnum:Q36 AND SPACE");
|
||||||
analyzer);
|
|
||||||
|
|
||||||
Hits hits = searcher.search(query);
|
Hits hits = searcher.search(query);
|
||||||
assertEquals("Q36 kept as-is",
|
assertEquals("Q36 kept as-is",
|
||||||
|
|
Loading…
Reference in New Issue