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:
Chris M. Hostetter 2007-02-22 00:37:51 +00:00
parent a76bf773c6
commit 0aa2a95ee7
4 changed files with 32 additions and 2 deletions

View File

@ -116,6 +116,11 @@ New Features
the dismax handler should execute if the main user query (q) is blank. the dismax handler should execute if the main user query (q) is blank.
(Ryan McKinley via hossman) (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 Changes in runtime behavior
1. Highlighting using DisMax will only pick up terms from the main 1. Highlighting using DisMax will only pick up terms from the main
user query, not boost or filter queries (klaas). user query, not boost or filter queries (klaas).

View File

@ -85,6 +85,9 @@ import org.apache.solr.util.SolrPluginUtils;
* <li> ps - (Phrase Slop) amount of slop on phrase queries built for pf * <li> ps - (Phrase Slop) amount of slop on phrase queries built for pf
* fields. * fields.
* </li> * </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 * <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 * users query to influence the score. If this is a BooleanQuery
* with a default boost (1.0f), then the individual clauses will be * 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); float tiebreaker = params.getFloat(DMP.TIE, 0.0f);
int pslop = params.getInt(DMP.PS, 0); int pslop = params.getInt(DMP.PS, 0);
int qslop = params.getInt(DMP.QS, 0);
/* a generic parser for parsing regular lucene queries */ /* a generic parser for parsing regular lucene queries */
QueryParser p = new SolrQueryParser(schema, null); QueryParser p = new SolrQueryParser(schema, null);
@ -187,6 +191,7 @@ public class DisMaxRequestHandler extends RequestHandlerBase {
new U.DisjunctionMaxQueryParser(schema, IMPOSSIBLE_FIELD_NAME); new U.DisjunctionMaxQueryParser(schema, IMPOSSIBLE_FIELD_NAME);
up.addAlias(IMPOSSIBLE_FIELD_NAME, up.addAlias(IMPOSSIBLE_FIELD_NAME,
tiebreaker, queryFields); tiebreaker, queryFields);
up.setPhraseSlop(qslop);
/* for parsing slopy phrases using DisjunctionMaxQueries */ /* for parsing slopy phrases using DisjunctionMaxQueries */
U.DisjunctionMaxQueryParser pp = U.DisjunctionMaxQueryParser pp =

View File

@ -55,8 +55,16 @@ import java.io.IOException;
public static String PF = "pf"; public static String PF = "pf";
/** query and init param for MinShouldMatch specification */ /** query and init param for MinShouldMatch specification */
public static String MM = "mm"; 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"; 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 */ /** query and init param for boosting query */
public static String BQ = "bq"; public static String BQ = "bq";
/** query and init param for boosting functions */ /** query and init param for boosting functions */

View File

@ -121,6 +121,18 @@ public class DisMaxRequestHandlerTest extends AbstractSolrTestCase {
"facet", "false" ) "facet", "false" )
,"//*[@numFound='0']" ,"//*[@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 { public void testOldStyleDefaults() throws Exception {