mirror of https://github.com/apache/lucene.git
SOLR-1776: DismaxQParser and ExtendedDismaxQParser now use the schema.xml defaultSearchField as the default value for the qf param
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@915646 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d16fe2ecca
commit
bbd02d1cf1
|
@ -249,6 +249,10 @@ Other Changes
|
||||||
* SOLR-1695: Improved error messages when adding a document that does not
|
* SOLR-1695: Improved error messages when adding a document that does not
|
||||||
contain exactly one value for the uniqueKey field (hossman)
|
contain exactly one value for the uniqueKey field (hossman)
|
||||||
|
|
||||||
|
* SOLR-1776: DismaxQParser and ExtendedDismaxQParser now use the schema.xml
|
||||||
|
"defaultSearchField" as the default value for the "qf" param instead of failing
|
||||||
|
with an error when "qf" is not specified. (hossman)
|
||||||
|
|
||||||
Build
|
Build
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,10 @@ public class DisMaxQParser extends QParser {
|
||||||
public Query parse() throws ParseException {
|
public Query parse() throws ParseException {
|
||||||
SolrParams solrParams = localParams == null ? params : new DefaultSolrParams(localParams, params);
|
SolrParams solrParams = localParams == null ? params : new DefaultSolrParams(localParams, params);
|
||||||
queryFields = SolrPluginUtils.parseFieldBoosts(solrParams.getParams(DisMaxParams.QF));
|
queryFields = SolrPluginUtils.parseFieldBoosts(solrParams.getParams(DisMaxParams.QF));
|
||||||
|
if (0 == queryFields.size()) {
|
||||||
|
queryFields.put(req.getSchema().getDefaultSearchFieldName(), 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
/* the main query we will execute. we disable the coord because
|
/* the main query we will execute. we disable the coord because
|
||||||
* this query is an artificial construct
|
* this query is an artificial construct
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -104,6 +104,10 @@ class ExtendedDismaxQParser extends QParser {
|
||||||
SolrParams solrParams = localParams == null ? params : new DefaultSolrParams(localParams, params);
|
SolrParams solrParams = localParams == null ? params : new DefaultSolrParams(localParams, params);
|
||||||
|
|
||||||
queryFields = U.parseFieldBoosts(solrParams.getParams(DMP.QF));
|
queryFields = U.parseFieldBoosts(solrParams.getParams(DMP.QF));
|
||||||
|
if (0 == queryFields.size()) {
|
||||||
|
queryFields.put(req.getSchema().getDefaultSearchFieldName(), 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
// Boosted phrase of the full query string
|
// Boosted phrase of the full query string
|
||||||
Map<String,Float> phraseFields =
|
Map<String,Float> phraseFields =
|
||||||
U.parseFieldBoosts(solrParams.getParams(DMP.PF));
|
U.parseFieldBoosts(solrParams.getParams(DMP.PF));
|
||||||
|
|
|
@ -206,6 +206,15 @@ public class DisMaxRequestHandlerTest extends AbstractSolrTestCase {
|
||||||
doTestSomeStuff("dismaxOldStyleDefaults");
|
doTestSomeStuff("dismaxOldStyleDefaults");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testSimplestParams() throws Exception {
|
||||||
|
populate();
|
||||||
|
|
||||||
|
assertQ("match w/o only q param",
|
||||||
|
req("qt", "dismaxNoDefaults",
|
||||||
|
"q","guide")
|
||||||
|
,"//*[@numFound='2']"
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,6 +97,12 @@ public class TestExtendedDismaxParser extends AbstractSolrTestCase {
|
||||||
"q","100"), oner
|
"q","100"), oner
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assertQ("qf defaults to defaultSearchField"
|
||||||
|
, req( "defType", "edismax"
|
||||||
|
,"q","op")
|
||||||
|
, twor
|
||||||
|
);
|
||||||
|
|
||||||
assertQ(req("defType", "edismax", "qf", "name title subject text",
|
assertQ(req("defType", "edismax", "qf", "name title subject text",
|
||||||
"q","op"), twor
|
"q","op"), twor
|
||||||
);
|
);
|
||||||
|
@ -167,4 +173,4 @@ public class TestExtendedDismaxParser extends AbstractSolrTestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,6 +293,8 @@
|
||||||
<int name="ps">100</int>
|
<int name="ps">100</int>
|
||||||
</lst>
|
</lst>
|
||||||
</requestHandler>
|
</requestHandler>
|
||||||
|
<requestHandler name="dismaxNoDefaults" class="solr.DisMaxRequestHandler" >
|
||||||
|
</requestHandler>
|
||||||
<requestHandler name="old" class="solr.tst.OldRequestHandler" >
|
<requestHandler name="old" class="solr.tst.OldRequestHandler" >
|
||||||
<int name="myparam">1000</int>
|
<int name="myparam">1000</int>
|
||||||
<float name="ratio">1.4142135</float>
|
<float name="ratio">1.4142135</float>
|
||||||
|
|
Loading…
Reference in New Issue