SOLR-2724 deprecate DefaultSearchField and defaultOperator

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1351931 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
David Wayne Smiley 2012-06-20 04:17:04 +00:00
parent 5cd8d27ba4
commit 96d5d8e481
4 changed files with 24 additions and 7 deletions

View File

@ -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 {
}
@Override
protected Query getWildcardQuery(String field, String termStr) throws ParseException {
checkNullField(field);
// *:* -> MatchAllDocsQuery
if ("*".equals(field) && "*".equals(termStr)) {
return newMatchAllDocsQuery();

View File

@ -205,11 +205,20 @@
-->
<uniqueKey>id</uniqueKey>
<!-- field for the QueryParser to use when an explicit fieldname is absent -->
<defaultSearchField>text</defaultSearchField>
<!-- 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> -->
<!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
<solrQueryParser defaultOperator="OR"/>
<!-- 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,

View File

@ -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>

View File

@ -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 error
Assert.fail("should have a number format exception");
}
catch(SolrException ex) {
@ -1162,7 +1164,7 @@ abstract public class SolrExampleTests extends SolrJettyTestBase
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]");