mirror of https://github.com/apache/lucene.git
Add default field capability via df query string parameter
git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@392732 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e76cc52516
commit
4e0b46dd4e
|
@ -64,6 +64,7 @@ public class StandardRequestHandler implements SolrRequestHandler, SolrInfoMBean
|
|||
try {
|
||||
String sreq = req.getQueryString();
|
||||
String debug = req.getParam("debugQuery");
|
||||
String defaultField = req.getParam("df");
|
||||
|
||||
// find fieldnames to return (fieldlist)
|
||||
String fl = req.getParam("fl");
|
||||
|
@ -86,7 +87,7 @@ public class StandardRequestHandler implements SolrRequestHandler, SolrInfoMBean
|
|||
List<String> commands = StrUtils.splitSmart(sreq,';');
|
||||
|
||||
String qs = commands.size() >= 1 ? commands.get(0) : "";
|
||||
Query query = QueryParsing.parseQuery(qs, req.getSchema());
|
||||
Query query = QueryParsing.parseQuery(qs, defaultField, req.getSchema());
|
||||
|
||||
// If the first non-query, non-filter command is a simple sort on an indexed field, then
|
||||
// we can use the Lucene sort ability.
|
||||
|
|
|
@ -39,8 +39,12 @@ import java.io.IOException;
|
|||
public class QueryParsing {
|
||||
|
||||
public static Query parseQuery(String qs, IndexSchema schema) {
|
||||
return parseQuery(qs, null, schema);
|
||||
}
|
||||
|
||||
public static Query parseQuery(String qs, String defaultField, IndexSchema schema) {
|
||||
try {
|
||||
Query query = new SolrQueryParser(schema).parse(qs);
|
||||
Query query = new SolrQueryParser(schema, defaultField).parse(qs);
|
||||
|
||||
if (SolrCore.log.isLoggable(Level.FINEST)) {
|
||||
SolrCore.log.finest("After QueryParser:" + query);
|
||||
|
|
|
@ -33,8 +33,8 @@ import org.apache.solr.schema.FieldType;
|
|||
public class SolrQueryParser extends QueryParser {
|
||||
protected final IndexSchema schema;
|
||||
|
||||
public SolrQueryParser(IndexSchema schema) {
|
||||
super(schema.getDefaultSearchFieldName(), schema.getQueryAnalyzer());
|
||||
public SolrQueryParser(IndexSchema schema, String defaultField) {
|
||||
super(defaultField == null ? schema.getDefaultSearchFieldName() : defaultField, schema.getQueryAnalyzer());
|
||||
this.schema = schema;
|
||||
setLowercaseExpandedTerms(false);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue