mirror of https://github.com/apache/lucene.git
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:
parent
198ec93b4e
commit
d89cc54c7a
|
@ -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() : '-' );
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue