Allow the query parser default operator to be configurable via schema.xml

git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@425033 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erik Hatcher 2006-07-24 13:00:46 +00:00
parent 91270b567e
commit 769edb8e78
3 changed files with 18 additions and 0 deletions

View File

@ -35,6 +35,9 @@ New Features
(yonik, SOLR-31)
19. Make web admin pages return UTF-8, change Content-type declaration to include a
space between the mime-type and charset (Philip Jacob, SOLR-35)
20. Made query parser default operator configurable via schema.xml:
<solrQueryParser defaultOperator="AND|OR"/>
The default operator remains "OR".
Changes in runtime behavior
1. classes reorganized into different packages, package names changed to Apache

View File

@ -140,12 +140,18 @@ public final class IndexSchema {
public Analyzer getQueryAnalyzer() { return queryAnalyzer; }
private String defaultSearchFieldName=null;
private String queryParserDefaultOperator = "OR";
/** Name of the default search field specified in the schema file */
public String getDefaultSearchFieldName() {
return defaultSearchFieldName;
}
/** default operator ("AND" or "OR") for QueryParser */
public String getQueryParserDefaultOperator() {
return queryParserDefaultOperator;
}
private SchemaField uniqueKeyField;
/**
@ -366,6 +372,14 @@ public final class IndexSchema {
log.info("default search field is "+defaultSearchFieldName);
}
node = (Node) xpath.evaluate("/schema/solrQueryParser/@defaultOperator", document, XPathConstants.NODE);
if (node==null) {
log.fine("using default query parser operator (OR)");
} else {
queryParserDefaultOperator=node.getNodeValue().trim();
log.info("query parser default operator is "+queryParserDefaultOperator);
}
node = (Node) xpath.evaluate("/schema/uniqueKey/text()", document, XPathConstants.NODE);
if (node==null) {
log.warning("no uniqueKey specified in schema.");

View File

@ -37,6 +37,7 @@ public class SolrQueryParser extends QueryParser {
super(defaultField == null ? schema.getDefaultSearchFieldName() : defaultField, schema.getQueryAnalyzer());
this.schema = schema;
setLowercaseExpandedTerms(false);
setDefaultOperator("AND".equals(schema.getQueryParserDefaultOperator()) ? QueryParser.Operator.AND : QueryParser.Operator.OR);
}
protected Query getFieldQuery(String field, String queryText) throws ParseException {