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.storeTermPositions() ) ? FieldFlag.TERM_VECTOR_POSITION.getAbbreviation() : '-' );
|
||||||
flags.append( (f != null && f.omitNorms()) ? FieldFlag.OMIT_NORMS.getAbbreviation() : '-' );
|
flags.append( (f != null && f.omitNorms()) ? FieldFlag.OMIT_NORMS.getAbbreviation() : '-' );
|
||||||
flags.append( (f != null &&
|
flags.append( (f != null &&
|
||||||
f.indexOptions() == IndexOptions.DOCS_ONLY) ? FieldFlag.OMIT_TF.getAbbreviation() : '-' );
|
f.omitTermFreqAndPositions() ) ? FieldFlag.OMIT_TF.getAbbreviation() : '-' );
|
||||||
flags.append( (f != null &&
|
flags.append( (f != null && f.omitPositions() ) ? FieldFlag.OMIT_POSITIONS.getAbbreviation() : '-' );
|
||||||
f.indexOptions() == IndexOptions.DOCS_AND_FREQS) ? FieldFlag.OMIT_POSITIONS.getAbbreviation() : '-' );
|
|
||||||
flags.append( (lazy) ? FieldFlag.LAZY.getAbbreviation() : '-' );
|
flags.append( (lazy) ? FieldFlag.LAZY.getAbbreviation() : '-' );
|
||||||
flags.append( (binary) ? FieldFlag.BINARY.getAbbreviation() : '-' );
|
flags.append( (binary) ? FieldFlag.BINARY.getAbbreviation() : '-' );
|
||||||
flags.append( (f != null && f.sortMissingFirst() ) ? FieldFlag.SORT_MISSING_FIRST.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;
|
if (val==null) return null;
|
||||||
|
|
||||||
return createField(field.getName(), val, getFieldStore(field, val),
|
return createField(field.getName(), val,
|
||||||
getFieldIndex(field, val), getFieldTermVec(field, val), field.omitNorms(),
|
getFieldStore(field, val), getFieldIndex(field, val),
|
||||||
field.indexOptions(), boost);
|
getFieldTermVec(field, val), field.omitNorms(),
|
||||||
|
getIndexOptions(field, val), boost);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -276,9 +277,11 @@ public abstract class FieldType extends FieldProperties {
|
||||||
storage,
|
storage,
|
||||||
index,
|
index,
|
||||||
vec);
|
vec);
|
||||||
|
if (index.isIndexed()) {
|
||||||
f.setOmitNorms(omitNorms);
|
f.setOmitNorms(omitNorms);
|
||||||
f.setIndexOptions(options);
|
f.setIndexOptions(options);
|
||||||
f.setBoost(boost);
|
f.setBoost(boost);
|
||||||
|
}
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,6 +323,16 @@ public abstract class FieldType extends FieldProperties {
|
||||||
return field.indexed() ? (isTokenized() ? Field.Index.ANALYZED :
|
return field.indexed() ? (isTokenized() ? Field.Index.ANALYZED :
|
||||||
Field.Index.NOT_ANALYZED) : Field.Index.NO;
|
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)
|
* 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;
|
||||||
import org.apache.solr.common.SolrException.ErrorCode;
|
import org.apache.solr.common.SolrException.ErrorCode;
|
||||||
import org.apache.lucene.document.Fieldable;
|
import org.apache.lucene.document.Fieldable;
|
||||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
|
||||||
import org.apache.lucene.search.SortField;
|
import org.apache.lucene.search.SortField;
|
||||||
import org.apache.solr.search.QParser;
|
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 storeTermOffsets() { return (properties & STORE_TERMOFFSETS)!=0; }
|
||||||
public boolean omitNorms() { return (properties & OMIT_NORMS)!=0; }
|
public boolean omitNorms() { return (properties & OMIT_NORMS)!=0; }
|
||||||
|
|
||||||
public IndexOptions indexOptions() {
|
/** @deprecated Use {@link #omitTermFreqAndPositions} */
|
||||||
if ((properties & OMIT_TF_POSITIONS) != 0) {
|
@Deprecated
|
||||||
return IndexOptions.DOCS_ONLY;
|
public boolean omitTf() { return omitTermFreqAndPositions(); }
|
||||||
} else if ((properties & OMIT_POSITIONS) != 0) {
|
|
||||||
return IndexOptions.DOCS_AND_FREQS;
|
public boolean omitTermFreqAndPositions() { return (properties & OMIT_TF_POSITIONS)!=0; }
|
||||||
} else {
|
public boolean omitPositions() { return (properties & OMIT_POSITIONS)!=0; }
|
||||||
return IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean multiValued() { return (properties & MULTIVALUED)!=0; }
|
public boolean multiValued() { return (properties & MULTIVALUED)!=0; }
|
||||||
public boolean sortMissingFirst() { return (properties & SORT_MISSING_FIRST)!=0; }
|
public boolean sortMissingFirst() { return (properties & SORT_MISSING_FIRST)!=0; }
|
||||||
|
|
|
@ -522,7 +522,7 @@ public class TrieField extends FieldType {
|
||||||
}
|
}
|
||||||
|
|
||||||
f.setOmitNorms(field.omitNorms());
|
f.setOmitNorms(field.omitNorms());
|
||||||
f.setIndexOptions(field.indexOptions());
|
f.setIndexOptions(getIndexOptions(field, value.toString()));
|
||||||
f.setBoost(boost);
|
f.setBoost(boost);
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue