本文整理汇总了Java中org.apache.solr.common.params.DisMaxParams类的典型用法代码示例。如果您正苦于以下问题:Java DisMaxParams类的具体用法?Java DisMaxParams怎么用?Java DisMaxParams使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DisMaxParams类属于org.apache.solr.common.params包,在下文中一共展示了DisMaxParams类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addBoostFunctions
import org.apache.solr.common.params.DisMaxParams; //导入依赖的package包/类
protected void addBoostFunctions(BooleanQuery query, SolrParams solrParams) throws SyntaxError {
String[] boostFuncs = solrParams.getParams(DisMaxParams.BF);
if (null != boostFuncs && 0 != boostFuncs.length) {
for (String boostFunc : boostFuncs) {
if (null == boostFunc || "".equals(boostFunc)) continue;
Map<String, Float> ff = SolrPluginUtils.parseFieldBoosts(boostFunc);
for (String f : ff.keySet()) {
Query fq = subQuery(f, FunctionQParserPlugin.NAME).getQuery();
Float b = ff.get(f);
if (null != b) {
fq.setBoost(b);
}
query.add(fq, BooleanClause.Occur.SHOULD);
}
}
}
}
示例2: testThatTheDefaultBoostMethodIsOpt
import org.apache.solr.common.params.DisMaxParams; //导入依赖的package包/类
@Test
public void testThatTheDefaultBoostMethodIsOpt() throws Exception {
String q = "qup";
SolrQueryRequest req = req("q", q,
DisMaxParams.QF, "f1 f2",
QueryParsing.OP, "OR",
"defType", "querqy",
"debugQuery", "true"
);
assertQ("Default boost method is not 'opt'",
req,
"//result[@name='response'][@numFound='2']",
// the parsed query must contain the boost terms:
"//str[@name='parsedquery'][contains(.,'f1:u100')]",
"//str[@name='parsedquery'][contains(.,'f2:u100')]");
req.close();
}
示例3: testThatOptCanBePassedAsBoostMethodParam
import org.apache.solr.common.params.DisMaxParams; //导入依赖的package包/类
@Test
public void testThatOptCanBePassedAsBoostMethodParam() throws Exception {
String q = "qup";
SolrQueryRequest req = req("q", q,
DisMaxParams.QF, "f1 f2",
QueryParsing.OP, "OR",
QuerqyDismaxQParser.QBOOST_METHOD, QuerqyDismaxQParser.QBOOST_METHOD_OPT,
"defType", "querqy",
"debugQuery", "true"
);
assertQ("Default boost method is not 'opt'",
req,
"//result[@name='response'][@numFound='2']",
// the parsed query must contain the boost terms:
"//str[@name='parsedquery'][contains(.,'f1:u100')]",
"//str[@name='parsedquery'][contains(.,'f2:u100')]");
req.close();
}
示例4: testThatReRankMethodCanBeActivated
import org.apache.solr.common.params.DisMaxParams; //导入依赖的package包/类
@Test
public void testThatReRankMethodCanBeActivated() throws Exception {
String q = "qup";
SolrQueryRequest req = req("q", q,
DisMaxParams.QF, "f1 f2",
QueryParsing.OP, "OR",
QuerqyDismaxQParser.QBOOST_METHOD, QuerqyDismaxQParser.QBOOST_METHOD_RERANK,
"defType", "querqy",
"debugQuery", "true"
);
assertQ("Method is not 'rerank'",
req,
"//result[@name='response'][@numFound='2']",
// the parsed query must contain not the boost terms:
"//str[@name='parsedquery'][not(contains(.,'f1:u100'))]",
"//str[@name='parsedquery'][not(contains(.,'f2:u100'))]",
// debug output must contain 'QuerqyReRankQuery'
"//lst[@name='explain']/str[contains(.,'QuerqyReRankQuery')]"
);
req.close();
}
示例5: testThatMMIsNotAppliedWhileQueryContainsMUSTNOTBooleanOperator
import org.apache.solr.common.params.DisMaxParams; //导入依赖的package包/类
@Test
public void testThatMMIsNotAppliedWhileQueryContainsMUSTNOTBooleanOperator() throws Exception {
String q = "a +b c -d e f";
SolrQueryRequest req = req("q", q,
DisMaxParams.QF, "f1 f2",
DisMaxParams.MM, "3",
QueryParsing.OP, "OR"
);
QuerqyDismaxQParser parser = new QuerqyDismaxQParser(q, null, req.getParams(), req, new RewriteChain(),
new WhiteSpaceQuerqyParser(), null);
Query query = parser.parse();
req.close();
BooleanQuery bq = assertBQ(query);
assertEquals(0, bq.getMinimumNumberShouldMatch());
}
示例6: testThatPfIsAppliedOnlyToExistingField
import org.apache.solr.common.params.DisMaxParams; //导入依赖的package包/类
@Test
public void testThatPfIsAppliedOnlyToExistingField() throws Exception {
String q = "a b c d";
SolrQueryRequest req = req("q", q,
DisMaxParams.QF, "f1 f2",
DisMaxParams.MM, "3",
QueryParsing.OP, "OR",
DisMaxParams.PF, "f3^2 f40^0.5",
"defType", "querqy",
"debugQuery", "true"
);
// f4 doesn't exist
assertQ("wrong ps",
req,
"//str[@name='parsedquery'][contains(.,'PhraseQuery(f3:\"a b c d\")^2.0')]",
"//str[@name='parsedquery'][not(contains(.,'PhraseQuery(f40:\"a b c d\")^0.5'))]");
req.close();
}
示例7: testThatMatchAllDoesNotThrowException
import org.apache.solr.common.params.DisMaxParams; //导入依赖的package包/类
@Test
public void testThatMatchAllDoesNotThrowException() throws Exception {
String q = "*:*";
SolrQueryRequest req = req("q", q,
DisMaxParams.QF, "f1 f2",
DisMaxParams.MM, "3",
QueryParsing.OP, "OR",
DisMaxParams.PF, "f3^2 f4^0.5",
"defType", "querqy",
"debugQuery", "true"
);
assertQ("Matchall fails",
req,
"//str[@name='parsedquery'][contains(.,'*:*')]",
"//result[@name='response' and @numFound='9']"
);
req.close();
}
示例8: testThatPfIsAppliedOnlyToFieldsWithTermPositions
import org.apache.solr.common.params.DisMaxParams; //导入依赖的package包/类
@Test
public void testThatPfIsAppliedOnlyToFieldsWithTermPositions() throws Exception {
String q = "a b c d";
SolrQueryRequest req = req("q", q,
DisMaxParams.QF, "f1 f2",
DisMaxParams.MM, "3",
QueryParsing.OP, "OR",
"defType", "querqy",
"debugQuery", "true",
DisMaxParams.PF, "f1^1.2 str^2 f_no_tfp^0.5");
// str is a string field
// f_no_tfp / f_no_tp don't have term positions
assertQ("wrong ps2",
req,
"//str[@name='parsedquery'][contains(.,'PhraseQuery(f1:\"a b c d\")^1.2')]",
"//str[@name='parsedquery'][not(contains(.,'PhraseQuery(str:\"a b c d\")^2.0'))]",
"//str[@name='parsedquery'][not(contains(.,'PhraseQuery(f_no_tfp:\"a b c d\")^0.5'))]",
"//str[@name='parsedquery'][not(contains(.,'PhraseQuery(f_no_tp:\"a b c d\")^0.5'))]");
req.close();
}
示例9: testThatAnalysisIsRunForPf
import org.apache.solr.common.params.DisMaxParams; //导入依赖的package包/类
@Test
public void testThatAnalysisIsRunForPf() throws Exception {
String q = "K L M";
SolrQueryRequest req = req("q", q,
DisMaxParams.QF, "f1",
DisMaxParams.MM, "3",
QueryParsing.OP, "OR",
"defType", "querqy",
"debugQuery", "true",
DisMaxParams.PF, "f1_lc f2_lc");
assertQ("Analysis not applied for pf",
req,
// Query terms should be lower-cased in analysis for pf fields
"//str[@name='parsedquery'][contains(.,'DisjunctionMaxQuery((f1_lc:\"k l m\" | f2_lc:\"k l m\"))')]",
// but not for query fields
"//str[@name='parsedquery'][contains(.,'(f1:K f1:L f1:M)')]");
req.close();
}
示例10: testThatAnalysisIsRunForPf2
import org.apache.solr.common.params.DisMaxParams; //导入依赖的package包/类
@Test
public void testThatAnalysisIsRunForPf2() throws Exception {
String q = "K L M";
SolrQueryRequest req = req("q", q,
DisMaxParams.QF, "f1",
DisMaxParams.MM, "3",
QueryParsing.OP, "OR",
"defType", "querqy",
"debugQuery", "true",
DisMaxParams.PF2, "f1_lc f2_lc");
assertQ("Analysis not applied for pf2",
req,
// Query terms should be lower-cased in analysis for pf2 fields
"//str[@name='parsedquery'][contains(.,'DisjunctionMaxQuery(((f1_lc:\"k l\" f1_lc:\"l m\") | (f2_lc:\"k l\" f2_lc:\"l m\")))')]",
// but not for query fields
"//str[@name='parsedquery'][contains(.,'(f1:K f1:L f1:M)')]");
req.close();
}
示例11: testThatAnalysisIsRunForPf3
import org.apache.solr.common.params.DisMaxParams; //导入依赖的package包/类
@Test
public void testThatAnalysisIsRunForPf3() throws Exception {
String q = "K L M";
SolrQueryRequest req = req("q", q,
DisMaxParams.QF, "f1",
DisMaxParams.MM, "3",
QueryParsing.OP, "OR",
"defType", "querqy",
"debugQuery", "true",
DisMaxParams.PF3, "f1_lc f2_lc");
assertQ("Analysis not applied for pf",
req,
// Query terms should be lower-cased in analysis for pf fields
"//str[@name='parsedquery'][contains(.,'DisjunctionMaxQuery((f1_lc:\"k l m\" | f2_lc:\"k l m\"))')]",
// but not for query fields
"//str[@name='parsedquery'][contains(.,'(f1:K f1:L f1:M)')]");
req.close();
}
示例12: testThatPf2IsAppliedOnlyToExistingField
import org.apache.solr.common.params.DisMaxParams; //导入依赖的package包/类
@Test
public void testThatPf2IsAppliedOnlyToExistingField() throws Exception {
String q = "a b c d";
SolrQueryRequest req = req("q", q,
DisMaxParams.QF, "f1 f2",
DisMaxParams.MM, "3",
QueryParsing.OP, "OR",
"defType", "querqy",
"debugQuery", "true",
DisMaxParams.PF2, "f1^2 f40^0.5");
// f40 does not exists
assertQ("wrong ps2",
req,
"//str[@name='parsedquery_toString'][contains(.,'(f1:\"a b\" f1:\"b c\" f1:\"c d\")^2.0')]",
"//str[@name='parsedquery_toString'][not(contains(.,'(f40:\"a b\" f1:\"b c\" f1:\"c d\")^0.5'))]");
req.close();
}
示例13: testThatPf3IsApplied
import org.apache.solr.common.params.DisMaxParams; //导入依赖的package包/类
@Test
public void testThatPf3IsApplied() throws Exception {
String q = "a b c d";
SolrQueryRequest req = req("q", q,
DisMaxParams.QF, "f1 f2",
DisMaxParams.MM, "3",
QueryParsing.OP, "OR",
DisMaxParams.PF3, "f2^2.5 f3^1.5"
);
verifyQueryString(req, q,
"(f2:\"a b c\" f2:\"b c d\")^2.5",
"(f3:\"a b c\" f3:\"b c d\")^1.5"
);
}
示例14: testThatPFSkipsMustNotClauses
import org.apache.solr.common.params.DisMaxParams; //导入依赖的package包/类
@Test
public void testThatPFSkipsMustNotClauses() throws Exception {
String q = "a b -c d e f";
SolrQueryRequest req = req("q", q,
DisMaxParams.QF, "f1 f2",
DisMaxParams.MM, "3",
QueryParsing.OP, "OR",
DisMaxParams.PF, "f2^1.5 f3^1.5",
DisMaxParams.PF2, "f1^2.1 f2^2.1",
DisMaxParams.PF3, "f3^3.9 f1^3.9"
);
verifyQueryString(req, q,
"(f2:\"a b d e f\")^1.5", "(f3:\"a b d e f\")^1.5",
"(f1:\"a b\" f1:\"b d\" f1:\"d e\" f1:\"e f\")^2.1",
"(f2:\"a b\" f2:\"b d\" f2:\"d e\" f2:\"e f\")^2.1",
"(f3:\"a b d\" f3:\"b d e\" f3:\"d e f\")^3.9",
"(f1:\"a b d\" f1:\"b d e\" f1:\"d e f\")^3.9"
);
}
示例15: testThatPFWorksWithSynonymRewriting
import org.apache.solr.common.params.DisMaxParams; //导入依赖的package包/类
@Test
public void testThatPFWorksWithSynonymRewriting() throws Exception {
SolrQueryRequest req = req("q", "a b",
DisMaxParams.QF, "f1 f2^0.9",
DisMaxParams.PF, "f1^0.5",
"defType", "querqy",
"debugQuery", "true");
assertQ("ps with synonyms not working",
req,
"//str[@name='parsedquery'][contains(.,'PhraseQuery(f1:\"a b\")^0.5')]");
req.close();
}