lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hoss...@apache.org
Subject svn commit: r915646 - in /lucene/solr/trunk: ./ src/java/org/apache/solr/search/ src/test/org/apache/solr/ src/test/org/apache/solr/search/ src/test/test-files/solr/conf/
Date Wed, 24 Feb 2010 03:00:45 GMT
Author: hossman
Date: Wed Feb 24 03:00:45 2010
New Revision: 915646

URL: http://svn.apache.org/viewvc?rev=915646&view=rev
Log:
SOLR-1776: DismaxQParser and ExtendedDismaxQParser now use the schema.xml defaultSearchField
as the default value for the qf param

Modified:
    lucene/solr/trunk/CHANGES.txt
    lucene/solr/trunk/src/java/org/apache/solr/search/DisMaxQParser.java
    lucene/solr/trunk/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java
    lucene/solr/trunk/src/test/org/apache/solr/DisMaxRequestHandlerTest.java
    lucene/solr/trunk/src/test/org/apache/solr/search/TestExtendedDismaxParser.java
    lucene/solr/trunk/src/test/test-files/solr/conf/solrconfig.xml

Modified: lucene/solr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/CHANGES.txt?rev=915646&r1=915645&r2=915646&view=diff
==============================================================================
--- lucene/solr/trunk/CHANGES.txt (original)
+++ lucene/solr/trunk/CHANGES.txt Wed Feb 24 03:00:45 2010
@@ -249,6 +249,10 @@
 * SOLR-1695: Improved error messages when adding a document that does not
   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
 ----------------------
 

Modified: lucene/solr/trunk/src/java/org/apache/solr/search/DisMaxQParser.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/search/DisMaxQParser.java?rev=915646&r1=915645&r2=915646&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/search/DisMaxQParser.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/search/DisMaxQParser.java Wed Feb 24 03:00:45
2010
@@ -65,7 +65,10 @@
   public Query parse() throws ParseException {
     SolrParams solrParams = localParams == null ? params : new DefaultSolrParams(localParams,
params);
     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
      * this query is an artificial construct
      */

Modified: lucene/solr/trunk/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java?rev=915646&r1=915645&r2=915646&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java Wed
Feb 24 03:00:45 2010
@@ -104,6 +104,10 @@
     SolrParams solrParams = localParams == null ? params : new DefaultSolrParams(localParams,
params);
 
     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
     Map<String,Float> phraseFields = 
       U.parseFieldBoosts(solrParams.getParams(DMP.PF));

Modified: lucene/solr/trunk/src/test/org/apache/solr/DisMaxRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/DisMaxRequestHandlerTest.java?rev=915646&r1=915645&r2=915646&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/DisMaxRequestHandlerTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/DisMaxRequestHandlerTest.java Wed Feb 24 03:00:45
2010
@@ -206,6 +206,15 @@
     doTestSomeStuff("dismaxOldStyleDefaults");
   }
 
+  public void testSimplestParams() throws Exception {
+    populate();
 
+    assertQ("match w/o only q param",
+            req("qt", "dismaxNoDefaults",
+                "q","guide")
+            ,"//*[@numFound='2']"
+            );
+    
+  }
   
 }

Modified: lucene/solr/trunk/src/test/org/apache/solr/search/TestExtendedDismaxParser.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/search/TestExtendedDismaxParser.java?rev=915646&r1=915645&r2=915646&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/search/TestExtendedDismaxParser.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/search/TestExtendedDismaxParser.java Wed Feb
24 03:00:45 2010
@@ -97,6 +97,12 @@
                "q","100"), oner
     );
 
+   assertQ("qf defaults to defaultSearchField"
+           , req( "defType", "edismax"
+                 ,"q","op")
+           , twor
+           );
+   
    assertQ(req("defType", "edismax", "qf", "name title subject text",
                "q","op"), twor
     );
@@ -167,4 +173,4 @@
 
   }
 
-}
\ No newline at end of file
+}

Modified: lucene/solr/trunk/src/test/test-files/solr/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/test-files/solr/conf/solrconfig.xml?rev=915646&r1=915645&r2=915646&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/test-files/solr/conf/solrconfig.xml (original)
+++ lucene/solr/trunk/src/test/test-files/solr/conf/solrconfig.xml Wed Feb 24 03:00:45 2010
@@ -293,6 +293,8 @@
      <int name="ps">100</int>
     </lst>
   </requestHandler>
+  <requestHandler name="dismaxNoDefaults" class="solr.DisMaxRequestHandler" >
+  </requestHandler>
   <requestHandler name="old" class="solr.tst.OldRequestHandler" >
     <int name="myparam">1000</int>
     <float name="ratio">1.4142135</float>



Mime
View raw message