SOLR-2671: push SchemaField.indexOptions() logic down into FieldType to reduce exposure

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1150840 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris M. Hostetter 2011-07-25 18:45:09 +00:00
parent 198ec93b4e
commit d89cc54c7a
4 changed files with 28 additions and 20 deletions

View File

@ -204,9 +204,8 @@ public class LukeRequestHandler extends RequestHandlerBase
flags.append( (f != null && f.storeTermPositions() ) ? FieldFlag.TERM_VECTOR_POSITION.getAbbreviation() : '-' );
flags.append( (f != null && f.omitNorms()) ? FieldFlag.OMIT_NORMS.getAbbreviation() : '-' );
flags.append( (f != null &&
f.indexOptions() == IndexOptions.DOCS_ONLY) ? FieldFlag.OMIT_TF.getAbbreviation() : '-' );
flags.append( (f != null &&
f.indexOptions() == IndexOptions.DOCS_AND_FREQS) ? FieldFlag.OMIT_POSITIONS.getAbbreviation() : '-' );
f.omitTermFreqAndPositions() ) ? FieldFlag.OMIT_TF.getAbbreviation() : '-' );
flags.append( (f != null && f.omitPositions() ) ? FieldFlag.OMIT_POSITIONS.getAbbreviation() : '-' );
flags.append( (lazy) ? FieldFlag.LAZY.getAbbreviation() : '-' );
flags.append( (binary) ? FieldFlag.BINARY.getAbbreviation() : '-' );
flags.append( (f != null && f.sortMissingFirst() ) ? FieldFlag.SORT_MISSING_FIRST.getAbbreviation() : '-' );

View File

@ -250,9 +250,10 @@ public abstract class FieldType extends FieldProperties {
}
if (val==null) return null;
return createField(field.getName(), val, getFieldStore(field, val),
getFieldIndex(field, val), getFieldTermVec(field, val), field.omitNorms(),
field.indexOptions(), boost);
return createField(field.getName(), val,
getFieldStore(field, val), getFieldIndex(field, val),
getFieldTermVec(field, val), field.omitNorms(),
getIndexOptions(field, val), boost);
}
@ -276,9 +277,11 @@ public abstract class FieldType extends FieldProperties {
storage,
index,
vec);
f.setOmitNorms(omitNorms);
f.setIndexOptions(options);
f.setBoost(boost);
if (index.isIndexed()) {
f.setOmitNorms(omitNorms);
f.setIndexOptions(options);
f.setBoost(boost);
}
return f;
}
@ -320,6 +323,16 @@ public abstract class FieldType extends FieldProperties {
return field.indexed() ? (isTokenized() ? Field.Index.ANALYZED :
Field.Index.NOT_ANALYZED) : Field.Index.NO;
}
protected IndexOptions getIndexOptions(SchemaField field,
String internalVal) {
IndexOptions options = IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
if (field.omitTermFreqAndPositions()) {
options = IndexOptions.DOCS_ONLY;
} else if (field.omitPositions()) {
options = IndexOptions.DOCS_AND_FREQS;
}
return options;
}
/**
* Convert an external value (from XML update command or from query string)

View File

@ -20,7 +20,6 @@ package org.apache.solr.schema;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.lucene.document.Fieldable;
import org.apache.lucene.index.FieldInfo.IndexOptions;
import org.apache.lucene.search.SortField;
import org.apache.solr.search.QParser;
@ -83,15 +82,12 @@ public final class SchemaField extends FieldProperties {
public boolean storeTermOffsets() { return (properties & STORE_TERMOFFSETS)!=0; }
public boolean omitNorms() { return (properties & OMIT_NORMS)!=0; }
public IndexOptions indexOptions() {
if ((properties & OMIT_TF_POSITIONS) != 0) {
return IndexOptions.DOCS_ONLY;
} else if ((properties & OMIT_POSITIONS) != 0) {
return IndexOptions.DOCS_AND_FREQS;
} else {
return IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
}
}
/** @deprecated Use {@link #omitTermFreqAndPositions} */
@Deprecated
public boolean omitTf() { return omitTermFreqAndPositions(); }
public boolean omitTermFreqAndPositions() { return (properties & OMIT_TF_POSITIONS)!=0; }
public boolean omitPositions() { return (properties & OMIT_POSITIONS)!=0; }
public boolean multiValued() { return (properties & MULTIVALUED)!=0; }
public boolean sortMissingFirst() { return (properties & SORT_MISSING_FIRST)!=0; }

View File

@ -522,7 +522,7 @@ public class TrieField extends FieldType {
}
f.setOmitNorms(field.omitNorms());
f.setIndexOptions(field.indexOptions());
f.setIndexOptions(getIndexOptions(field, value.toString()));
f.setBoost(boost);
return f;
}