SOLR-1067: further progress on the problem with null qparser

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@802424 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2009-08-08 17:20:43 +00:00
parent af828c575d
commit b4acfc32df
9 changed files with 14 additions and 10 deletions

View File

@ -143,7 +143,7 @@ public class FieldAnalysisRequestHandler extends AnalysisRequestHandlerBase {
useDefaultSearchField = false;
}
if (useDefaultSearchField) {
analysisRequest.addFieldName(req.getSchema().getSolrQueryParser(null).getField());
analysisRequest.addFieldName(req.getSchema().getDefaultSearchFieldName());
}
analysisRequest.setQuery(solrParams.get(AnalysisParams.QUERY, solrParams.get(CommonParams.Q)));
analysisRequest.setFieldValue(solrParams.get(AnalysisParams.FIELD_VALUE));

View File

@ -371,7 +371,7 @@ public class LukeRequestHandler extends RequestHandlerBase
finfo.add("fields", fields);
finfo.add("dynamicFields", dynamicFields);
finfo.add("uniqueKeyField", uniqueField.getName());
finfo.add("defaultSearchField", schema.getSolrQueryParser(null).getField());
finfo.add("defaultSearchField", schema.getDefaultSearchFieldName());
finfo.add("types", types);
return finfo;
}

View File

@ -73,7 +73,7 @@ public abstract class SolrHighlighter
if(emptyArray(fields)) {
// use default search field if highlight fieldlist not specified.
if (emptyArray(defaultFields)) {
String defaultSearchField = request.getSchema().getSolrQueryParser(null).getField();
String defaultSearchField = request.getSchema().getDefaultSearchFieldName();
fields = null == defaultSearchField ? new String[]{} : new String[]{defaultSearchField};
}
else {

View File

@ -251,6 +251,7 @@ public final class IndexSchema {
* <solrQueryParser> configuration for this IndexSchema.
*
* @param defaultField if non-null overrides the schema default
* @deprecated
*/
public SolrQueryParser getSolrQueryParser(String defaultField) {
SolrQueryParser qp = new SolrQueryParser(this,defaultField);
@ -262,9 +263,7 @@ public final class IndexSchema {
/**
* Name of the default search field specified in the schema file
* @deprecated use getSolrQueryParser().getField()
*/
@Deprecated
public String getDefaultSearchFieldName() {
return defaultSearchFieldName;
}

View File

@ -207,7 +207,7 @@ public class DisMaxQParser extends QParser {
protected SolrPluginUtils.DisjunctionMaxQueryParser getParser(Map<String, Float> fields, String paramName,
SolrParams solrParams, float tiebreaker) {
int slop = solrParams.getInt(paramName, 0);
SolrPluginUtils.DisjunctionMaxQueryParser parser = new SolrPluginUtils.DisjunctionMaxQueryParser(req.getSchema(),
SolrPluginUtils.DisjunctionMaxQueryParser parser = new SolrPluginUtils.DisjunctionMaxQueryParser(this,
IMPOSSIBLE_FIELD_NAME);
parser.addAlias(IMPOSSIBLE_FIELD_NAME, tiebreaker, fields);
parser.setPhraseSlop(slop);

View File

@ -61,7 +61,7 @@ class LuceneQParser extends QParser {
String defaultField = getParam(CommonParams.DF);
if (defaultField==null) {
defaultField = getReq().getSchema().getSolrQueryParser(null).getField();
defaultField = getReq().getSchema().getDefaultSearchFieldName();
}
lparser = new SolrQueryParser(this, defaultField);

View File

@ -64,7 +64,7 @@ public class SolrQueryParser extends QueryParser {
*
* @param schema Used for default search field name if defaultField is null and field information is used for analysis
* @param defaultField default field used for unspecified search terms. if null, the schema default field is used
* @see IndexSchema#getSolrQueryParser(String defaultField)
* @see IndexSchema#getDefaultSearchFieldName()
*/
public SolrQueryParser(IndexSchema schema, String defaultField) {
super(defaultField == null ? schema.getDefaultSearchFieldName() : defaultField, schema.getQueryAnalyzer());

View File

@ -523,6 +523,7 @@ public class SolrPluginUtils {
* NOTE: intra-function whitespace is not allowed.
* </p>
* @see #parseFieldBoosts
* @deprecated
*/
public static List<Query> parseFuncs(IndexSchema s, String in)
throws ParseException {
@ -731,7 +732,11 @@ public class SolrPluginUtils {
* DisjunctionMaxQuery and the tiebreaker to use.
*/
protected Map<String,Alias> aliases = new HashMap<String,Alias>(3);
public DisjunctionMaxQueryParser(QParser qp, String defaultField) {
super(qp,defaultField);
// don't trust that our parent class won't ever change it's default
setDefaultOperator(QueryParser.Operator.OR);
}
public DisjunctionMaxQueryParser(IndexSchema s, String defaultField) {
super(s,defaultField);
// don't trust that our parent class won't ever change it's default

View File

@ -133,7 +133,7 @@ public class SolrPluginUtilsTest extends AbstractSolrTestCase {
assertTrue(t+" sanity test isn't TermQuery: " + out.getClass(),
out instanceof TermQuery);
assertEquals(t+" sanity test is wrong field",
h.getCore().getSchema().getSolrQueryParser(null).getField(),
h.getCore().getSchema().getDefaultSearchFieldName(),
((TermQuery)out).getTerm().field());
t = "subject:XXXXXXXX";