Apache Lucene open-source search software
SOLR-2724 deprecate DefaultSearchField and defaultOperator
David Wayne Smiley96d5d8e481d4
diff --git a/solr/core/src/java/org/apache/solr/search/SolrQueryParser.java b/solr/core/src/java/org/apache/solr/search/SolrQueryParser.javaindex bc81eaeb4fb..eb32a3a840d 100644--- a/solr/core/src/java/org/apache/solr/search/SolrQueryParser.java+++ b/solr/core/src/java/org/apache/solr/search/SolrQueryParser.java@@ -135,7 +135,7 @@ public class SolrQueryParser extends QueryParser {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 QueryParser {}@Overrideprotected Query getWildcardQuery(String field, String termStr) throws ParseException {+ checkNullField(field);// *:* -> MatchAllDocsQueryif ("*".equals(field) && "*".equals(termStr)) {return newMatchAllDocsQuery();diff --git a/solr/example/solr/conf/schema.xml b/solr/example/solr/conf/schema.xmlindex 59908446724..bb4b2672741 100755--- a/solr/example/solr/conf/schema.xml+++ b/solr/example/solr/conf/schema.xml@@ -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 documentis added to the index. It's used either to index the same field differently,diff --git a/solr/example/solr/conf/solrconfig.xml b/solr/example/solr/conf/solrconfig.xmlindex 5e586157cc7..7d4755ed74d 100755--- a/solr/example/solr/conf/solrconfig.xml+++ b/solr/example/solr/conf/solrconfig.xml@@ -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 specifiedto 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' spellcheckerand 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>diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.javaindex 1c9975bc7f6..fc84e3ad3dc 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java@@ -495,7 +495,9 @@ abstract public class SolrExampleTests extends SolrJettyTestBase}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 errorAssert.fail("should have a number format exception");}catch(SolrException ex) {@@ -1162,7 +1164,7 @@ abstract public class SolrExampleTests extends SolrJettyTestBaseserver.commit(); // Since the transaction log is disabled in the example, we need to commitSolrQuery q = new SolrQuery();- q.setQueryType("/get");+ q.setRequestHandler("/get");q.set("id", "DOCID");q.set("fl", "id,name,aaa:[value v=aaa]");