mirror of https://github.com/apache/lucene.git
SOLR-6215: TrieDateField should directly extend TrieField instead of forwarding to a wrapped TrieField
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1606794 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2236e22898
commit
b7290e523b
|
@ -87,6 +87,9 @@ Other Changes
|
|||
* SOLR-6169: Finish removal of CoreAdminHandler handleAlias action begun in 4.9
|
||||
(Alan Woodward)
|
||||
|
||||
* SOLR-6215: TrieDateField should directly extend TrieField instead of
|
||||
forwarding to a wrapped TrieField. (Steve Rowe)
|
||||
|
||||
================== 4.10.0 =================
|
||||
|
||||
Versions of Major Components
|
||||
|
|
|
@ -244,11 +244,12 @@ public abstract class RangeEndpointCalculator<T extends Comparable<T>> {
|
|||
case LONG:
|
||||
calc = new LongRangeEndpointCalculator(request);
|
||||
break;
|
||||
case DATE:
|
||||
calc = new DateRangeEndpointCalculator(request, null);
|
||||
break;
|
||||
default:
|
||||
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unable to range facet on tried field of unexpected type:" + sf.getName());
|
||||
}
|
||||
} else if (ft instanceof TrieDateField) {
|
||||
calc = new DateRangeEndpointCalculator(request, null);
|
||||
} else {
|
||||
throw new SolrException (SolrException.ErrorCode.BAD_REQUEST, "Unable to range facet on field:" + sf);
|
||||
}
|
||||
|
|
|
@ -1026,13 +1026,14 @@ public class SimpleFacets {
|
|||
case LONG:
|
||||
calc = new LongRangeEndpointCalculator(sf);
|
||||
break;
|
||||
case DATE:
|
||||
calc = new DateRangeEndpointCalculator(sf, null);
|
||||
break;
|
||||
default:
|
||||
throw new SolrException
|
||||
(SolrException.ErrorCode.BAD_REQUEST,
|
||||
"Unable to range facet on tried field of unexpected type:" + f);
|
||||
}
|
||||
} else if (ft instanceof TrieDateField) {
|
||||
calc = new DateRangeEndpointCalculator(sf, null);
|
||||
} else {
|
||||
throw new SolrException
|
||||
(SolrException.ErrorCode.BAD_REQUEST,
|
||||
|
|
|
@ -21,18 +21,11 @@ import org.apache.solr.common.SolrException;
|
|||
import org.apache.solr.common.util.DateUtil;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.search.QParser;
|
||||
import org.apache.solr.response.TextResponseWriter;
|
||||
import org.apache.solr.update.processor.TimestampUpdateProcessorFactory; //jdoc
|
||||
import org.apache.solr.util.DateMathParser;
|
||||
import org.apache.lucene.document.FieldType.NumericType;
|
||||
import org.apache.lucene.index.StorableField;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.NumericRangeQuery;
|
||||
import org.apache.lucene.uninverting.UninvertingReader.Type;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.CharsRef;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.DecimalFormat;
|
||||
|
@ -42,11 +35,8 @@ import java.text.NumberFormat;
|
|||
import java.text.ParseException;
|
||||
import java.text.ParsePosition;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Date;
|
||||
import java.io.IOException;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
|
@ -109,8 +99,11 @@ import java.util.TimeZone;
|
|||
*
|
||||
* @see TrieField
|
||||
*/
|
||||
public class TrieDateField extends PrimitiveFieldType implements DateValueFieldType {
|
||||
|
||||
public class TrieDateField extends TrieField implements DateValueFieldType {
|
||||
{
|
||||
type = TrieTypes.DATE;
|
||||
}
|
||||
|
||||
public static final TimeZone UTC = TimeZone.getTimeZone("UTC");
|
||||
|
||||
/**
|
||||
|
@ -254,8 +247,6 @@ public class TrieDateField extends PrimitiveFieldType implements DateValueFieldT
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Thread safe DateFormat that can <b>format</b> in the canonical
|
||||
* ISO8601 date format, not including the trailing "Z" (since it is
|
||||
|
@ -341,144 +332,16 @@ public class TrieDateField extends PrimitiveFieldType implements DateValueFieldT
|
|||
}
|
||||
}
|
||||
|
||||
final TrieField wrappedField = new TrieField() {{
|
||||
type = TrieTypes.DATE;
|
||||
}};
|
||||
|
||||
@Override
|
||||
protected void init(IndexSchema schema, Map<String, String> args) {
|
||||
wrappedField.init(schema, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date toObject(StorableField f) {
|
||||
return (Date) wrappedField.toObject(f);
|
||||
return (Date)super.toObject(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toObject(SchemaField sf, BytesRef term) {
|
||||
return wrappedField.toObject(sf, term);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortField getSortField(SchemaField field, boolean top) {
|
||||
return wrappedField.getSortField(field, top);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getUninversionType(SchemaField sf) {
|
||||
return wrappedField.getUninversionType(sf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object marshalSortValue(Object value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object unmarshalSortValue(Object value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueSource getValueSource(SchemaField field, QParser parser) {
|
||||
return wrappedField.getValueSource(field, parser);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the precisionStep used to index values into the field
|
||||
*/
|
||||
public int getPrecisionStep() {
|
||||
return wrappedField.getPrecisionStep();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NumericType getNumericType() {
|
||||
return wrappedField.getNumericType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(TextResponseWriter writer, String name, StorableField f) throws IOException {
|
||||
wrappedField.write(writer, name, f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTokenized() {
|
||||
return wrappedField.isTokenized();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean multiValuedFieldCache() {
|
||||
return wrappedField.multiValuedFieldCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String storedToReadable(StorableField f) {
|
||||
return wrappedField.storedToReadable(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readableToIndexed(String val) {
|
||||
return wrappedField.readableToIndexed(val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toInternal(String val) {
|
||||
return wrappedField.toInternal(val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toExternal(StorableField f) {
|
||||
return wrappedField.toExternal(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String indexedToReadable(String _indexedForm) {
|
||||
return wrappedField.indexedToReadable(_indexedForm);
|
||||
}
|
||||
@Override
|
||||
public CharsRef indexedToReadable(BytesRef input, CharsRef charsRef) {
|
||||
// TODO: this could be more efficient, but the sortable types should be deprecated instead
|
||||
return wrappedField.indexedToReadable(input, charsRef);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String storedToIndexed(StorableField f) {
|
||||
return wrappedField.storedToIndexed(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorableField createField(SchemaField field, Object value, float boost) {
|
||||
return wrappedField.createField(field, value, boost);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StorableField> createFields(SchemaField field, Object value, float boost) {
|
||||
return wrappedField.createFields(field, value, boost);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query getRangeQuery(QParser parser, SchemaField field, String min, String max, boolean minInclusive, boolean maxInclusive) {
|
||||
return wrappedField.getRangeQuery(parser, field, min, max, minInclusive, maxInclusive);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasProperty(int p) {
|
||||
return wrappedField.hasProperty(p);
|
||||
}
|
||||
|
||||
|
||||
/** TrieDateField specific range query */
|
||||
public Query getRangeQuery(QParser parser, SchemaField sf, Date min, Date max, boolean minInclusive, boolean maxInclusive) {
|
||||
return NumericRangeQuery.newLongRange(sf.getName(), wrappedField.precisionStep,
|
||||
return NumericRangeQuery.newLongRange(sf.getName(), precisionStep,
|
||||
min == null ? null : min.getTime(),
|
||||
max == null ? null : max.getTime(),
|
||||
minInclusive, maxInclusive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkSchemaField(SchemaField field) {
|
||||
wrappedField.checkSchemaField(field);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -711,8 +711,6 @@ public class TrieField extends PrimitiveFieldType {
|
|||
* that indexes multiple precisions per value.
|
||||
*/
|
||||
public static String getMainValuePrefix(org.apache.solr.schema.FieldType ft) {
|
||||
if (ft instanceof TrieDateField)
|
||||
ft = ((TrieDateField) ft).wrappedField;
|
||||
if (ft instanceof TrieField) {
|
||||
final TrieField trie = (TrieField)ft;
|
||||
if (trie.precisionStep == Integer.MAX_VALUE)
|
||||
|
|
Loading…
Reference in New Issue