本文整理汇总了Java中org.apache.solr.search.QParser.parse方法的典型用法代码示例。如果您正苦于以下问题:Java QParser.parse方法的具体用法?Java QParser.parse怎么用?Java QParser.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.search.QParser
的用法示例。
在下文中一共展示了QParser.parse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_singleTerm
import org.apache.solr.search.QParser; //导入方法依赖的package包/类
@Test
public void test_singleTerm() throws SyntaxError {
// arrange
QParser parser = new SimilarityParser("first",new ModifiableSolrParams(),mockCorrectParams,req("first"));
// act
Query luceneQuery = parser.parse();
// assert
AugmentedTermQuery expected = new AugmentedTermQuery(
AugmentedTermQuery.ModelMethod.Generalized, new Term("text", "first"),
new TermWeightTuple[]{SimilarityApiMock.similarTerm("text")}
);
Assert.assertEquals(expected, luceneQuery);
}
开发者ID:sebastian-hofstaetter,项目名称:ir-generalized-translation-models,代码行数:18,代码来源:SimilarityParserTest.java
示例2: test_twoTerm
import org.apache.solr.search.QParser; //导入方法依赖的package包/类
@Test
public void test_twoTerm() throws SyntaxError {
// arrange
QParser parser = new SimilarityParser("first second",new ModifiableSolrParams(),mockCorrectParams,req("first second"));
// act
Query luceneQuery = parser.parse();
// assert
Assert.assertEquals(BooleanQuery.class, luceneQuery.getClass());
BooleanQuery realQuery = (BooleanQuery)luceneQuery;
Assert.assertEquals(2,realQuery.clauses().size());
// first
AugmentedTermQuery expected1 = new AugmentedTermQuery(
AugmentedTermQuery.ModelMethod.Generalized, new Term("text", "first"),
new TermWeightTuple[]{SimilarityApiMock.similarTerm("text")}
);
Assert.assertEquals(expected1,realQuery.clauses().get(0).getQuery());
//second
AugmentedTermQuery expected2 = new AugmentedTermQuery(
AugmentedTermQuery.ModelMethod.Generalized, new Term("text", "second"),
new TermWeightTuple[]{SimilarityApiMock.similarTerm("text")}
);
Assert.assertEquals(expected2,realQuery.clauses().get(1).getQuery());
}
开发者ID:sebastian-hofstaetter,项目名称:ir-generalized-translation-models,代码行数:30,代码来源:SimilarityParserTest.java
示例3: parse
import org.apache.solr.search.QParser; //导入方法依赖的package包/类
private static Query parse(String v) throws SyntaxError {
ModifiableSolrParams localParams = new ModifiableSolrParams();
localParams.add(QueryParsing.V, v);
QParserPlugin qpp = core.getQueryPlugin(PARSER_NAME);
QParser qp = qpp.createParser(null, localParams, null, req);
return qp.parse();
}