You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2012/06/20 06:56:07 UTC

svn commit: r1351935 - in /lucene/dev/branches/branch_4x: ./ solr/ solr/core/ solr/core/src/java/org/apache/solr/search/ solr/example/ solr/example/solr/conf/ solr/solrj/ solr/solrj/src/test/org/apache/solr/client/solrj/

Author: dsmiley
Date: Wed Jun 20 04:56:06 2012
New Revision: 1351935

URL: http://svn.apache.org/viewvc?rev=1351935&view=rev
Log:
SOLR-2724 deprecate DefaultSearchField and defaultOperator

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/solr/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/SolrQueryParser.java
    lucene/dev/branches/branch_4x/solr/example/   (props changed)
    lucene/dev/branches/branch_4x/solr/example/solr/conf/schema.xml
    lucene/dev/branches/branch_4x/solr/example/solr/conf/solrconfig.xml
    lucene/dev/branches/branch_4x/solr/solrj/   (props changed)
    lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/SolrQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/SolrQueryParser.java?rev=1351935&r1=1351934&r2=1351935&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/SolrQueryParser.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/SolrQueryParser.java Wed Jun 20 04:56:06 2012
@@ -135,7 +135,7 @@ public class SolrQueryParser extends Que
     if (field == null && defaultField == null) {
       throw new SolrException
         (SolrException.ErrorCode.BAD_REQUEST,
-         "no field name specified in query and no defaultSearchField defined in schema.xml");
+         "no field name specified in query and no default specified via 'df' param");
     }
   }
 
@@ -194,6 +194,7 @@ public class SolrQueryParser extends Que
   }
   @Override
   protected Query getWildcardQuery(String field, String termStr) throws ParseException {
+    checkNullField(field);
     // *:* -> MatchAllDocsQuery
     if ("*".equals(field) && "*".equals(termStr)) {
       return newMatchAllDocsQuery();

Modified: lucene/dev/branches/branch_4x/solr/example/solr/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/example/solr/conf/schema.xml?rev=1351935&r1=1351934&r2=1351935&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/example/solr/conf/schema.xml (original)
+++ lucene/dev/branches/branch_4x/solr/example/solr/conf/schema.xml Wed Jun 20 04:56:06 2012
@@ -205,11 +205,20 @@
    -->
  <uniqueKey>id</uniqueKey>
 
- <!-- field for the QueryParser to use when an explicit fieldname is absent -->
- <defaultSearchField>text</defaultSearchField>
-
- <!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
- <solrQueryParser defaultOperator="OR"/>
+ <!-- DEPRECATED: The defaultSearchField is consulted by various query parsers when
+  parsing a query string that isn't explicit about the field.  Machine (non-user)
+  generated queries are best made explicit, or they can use the "df" request parameter
+  which takes precedence over this.
+  Note: Un-commenting defaultSearchField will be insufficient if your request handler
+  in solrconfig.xml defines "df", which takes precedence. That would need to be removed.
+ <defaultSearchField>text</defaultSearchField> -->
+
+ <!-- DEPRECATED: The defaultOperator (AND|OR) is consulted by various query parsers
+  when parsing a query string to determine if a clause of the query should be marked as
+  required or optional, assuming the clause isn't already marked by some operator.
+  The default is OR, which is generally assumed so it is not a good idea to change it
+  globally here.  The "q.op" request parameter takes precedence over this.
+ <solrQueryParser defaultOperator="OR"/> -->
 
   <!-- copyField commands copy one field to another at the time a document
         is added to the index.  It's used either to index the same field differently,

Modified: lucene/dev/branches/branch_4x/solr/example/solr/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/example/solr/conf/solrconfig.xml?rev=1351935&r1=1351934&r2=1351935&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/example/solr/conf/solrconfig.xml (original)
+++ lucene/dev/branches/branch_4x/solr/example/solr/conf/solrconfig.xml Wed Jun 20 04:56:06 2012
@@ -743,6 +743,7 @@
      <lst name="defaults">
        <str name="echoParams">explicit</str>
        <int name="rows">10</int>
+       <str name="df">text</str>
      </lst>
     <!-- In addition to defaults, "appends" params can be specified
          to identify values which should be appended to the list of
@@ -804,6 +805,7 @@
        <str name="echoParams">explicit</str>
        <str name="wt">json</str>
        <str name="indent">true</str>
+       <str name="df">text</str>
      </lst>
   </requestHandler>
 
@@ -1244,6 +1246,7 @@
     -->
   <requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
     <lst name="defaults">
+      <str name="df">text</str>
       <!-- Solr will use suggestions from both the 'default' spellchecker
            and from the 'wordbreak' spellchecker and combine them.
            collations (re-written queries) can include a combination of
@@ -1280,6 +1283,7 @@
     -->
   <requestHandler name="/tvrh" class="solr.SearchHandler" startup="lazy">
     <lst name="defaults">
+      <str name="df">text</str>
       <bool name="tv">true</bool>
     </lst>
     <arr name="last-components">
@@ -1433,6 +1437,7 @@
   <requestHandler name="/elevate" class="solr.SearchHandler" startup="lazy">
     <lst name="defaults">
       <str name="echoParams">explicit</str>
+      <str name="df">text</str>
     </lst>
     <arr name="last-components">
       <str>elevator</str>

Modified: lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java?rev=1351935&r1=1351934&r2=1351935&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java (original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java Wed Jun 20 04:56:06 2012
@@ -495,7 +495,9 @@ abstract public class SolrExampleTests e
     }
     
     try {
-      server.deleteByQuery( "??::?? ignore_exception" ); // query syntax error
+      //the df=text here is a kluge for the test to supply a default field in case there is none in schema.xml
+      // alternatively, the resulting assertion could be modified to assert that no default field is specified.
+      server.deleteByQuery( "{!df=text} ??::?? ignore_exception" ); // query syntax error
       Assert.fail("should have a number format exception");
     }
     catch(SolrException ex) {
@@ -1162,7 +1164,7 @@ abstract public class SolrExampleTests e
     server.commit();  // Since the transaction log is disabled in the example, we need to commit
     
     SolrQuery q = new SolrQuery();
-    q.setQueryType("/get");
+    q.setRequestHandler("/get");
     q.set("id", "DOCID");
     q.set("fl", "id,name,aaa:[value v=aaa]");