mirror of https://github.com/apache/lucene.git
SOLR-158: new qs (Query Slop) param for DisMaxRequestHandler
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@510325 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a76bf773c6
commit
0aa2a95ee7
|
@ -115,6 +115,11 @@ New Features
|
|||
using SolrQueryParser syntax as a mechanism for specifying what query
|
||||
the dismax handler should execute if the main user query (q) is blank.
|
||||
(Ryan McKinley via hossman)
|
||||
|
||||
15. SOLR-158: new "qs" (Query Slop) param for DisMaxRequestHandler
|
||||
allows for specifying the amount of default slop to use when parsing
|
||||
explicit phrase queries from the user.
|
||||
(Adam Hiatt via hossman)
|
||||
|
||||
Changes in runtime behavior
|
||||
1. Highlighting using DisMax will only pick up terms from the main
|
||||
|
|
|
@ -85,6 +85,9 @@ import org.apache.solr.util.SolrPluginUtils;
|
|||
* <li> ps - (Phrase Slop) amount of slop on phrase queries built for pf
|
||||
* fields.
|
||||
* </li>
|
||||
* <li> ps - (Query Slop) amount of slop on phrase queries explicitly
|
||||
* specified in the "q" for qf fields.
|
||||
* </li>
|
||||
* <li> bq - (Boost Query) a raw lucene query that will be included in the
|
||||
* users query to influence the score. If this is a BooleanQuery
|
||||
* with a default boost (1.0f), then the individual clauses will be
|
||||
|
@ -176,6 +179,7 @@ public class DisMaxRequestHandler extends RequestHandlerBase {
|
|||
float tiebreaker = params.getFloat(DMP.TIE, 0.0f);
|
||||
|
||||
int pslop = params.getInt(DMP.PS, 0);
|
||||
int qslop = params.getInt(DMP.QS, 0);
|
||||
|
||||
/* a generic parser for parsing regular lucene queries */
|
||||
QueryParser p = new SolrQueryParser(schema, null);
|
||||
|
@ -187,7 +191,8 @@ public class DisMaxRequestHandler extends RequestHandlerBase {
|
|||
new U.DisjunctionMaxQueryParser(schema, IMPOSSIBLE_FIELD_NAME);
|
||||
up.addAlias(IMPOSSIBLE_FIELD_NAME,
|
||||
tiebreaker, queryFields);
|
||||
|
||||
up.setPhraseSlop(qslop);
|
||||
|
||||
/* for parsing slopy phrases using DisjunctionMaxQueries */
|
||||
U.DisjunctionMaxQueryParser pp =
|
||||
new U.DisjunctionMaxQueryParser(schema, IMPOSSIBLE_FIELD_NAME);
|
||||
|
|
|
@ -55,8 +55,16 @@ import java.io.IOException;
|
|||
public static String PF = "pf";
|
||||
/** query and init param for MinShouldMatch specification */
|
||||
public static String MM = "mm";
|
||||
/** query and init param for Phrase Slop value */
|
||||
/**
|
||||
* query and init param for Phrase Slop value in phrase
|
||||
* boost query (in pf fields)
|
||||
*/
|
||||
public static String PS = "ps";
|
||||
/**
|
||||
* query and init param for phrase Slop value in phrases
|
||||
* explicitly included in the user's query string ( in qf fields)
|
||||
*/
|
||||
public static String QS = "qs";
|
||||
/** query and init param for boosting query */
|
||||
public static String BQ = "bq";
|
||||
/** query and init param for boosting functions */
|
||||
|
|
|
@ -121,6 +121,18 @@ public class DisMaxRequestHandlerTest extends AbstractSolrTestCase {
|
|||
"facet", "false" )
|
||||
,"//*[@numFound='0']"
|
||||
);
|
||||
|
||||
assertQ("no query slop == no match",
|
||||
req( "qt", "dismax",
|
||||
"q", "\"cool chick\"" )
|
||||
,"//*[@numFound='0']"
|
||||
);
|
||||
assertQ("query slop == match",
|
||||
req( "qt", "dismax",
|
||||
"qs", "2",
|
||||
"q", "\"cool chick\"" )
|
||||
,"//*[@numFound='1']"
|
||||
);
|
||||
}
|
||||
|
||||
public void testOldStyleDefaults() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue