mirror of https://github.com/apache/lucene.git
LUCENE-3001 fix solr trie date field from #1086651
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1086681 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b95ca2b453
commit
9027875384
|
@ -27,6 +27,7 @@ import org.apache.solr.search.function.*;
|
||||||
import org.apache.solr.search.QParser;
|
import org.apache.solr.search.QParser;
|
||||||
import org.apache.solr.response.TextResponseWriter;
|
import org.apache.solr.response.TextResponseWriter;
|
||||||
import org.apache.lucene.document.Fieldable;
|
import org.apache.lucene.document.Fieldable;
|
||||||
|
import org.apache.lucene.document.Field;
|
||||||
import org.apache.lucene.search.SortField;
|
import org.apache.lucene.search.SortField;
|
||||||
import org.apache.lucene.search.FieldCache;
|
import org.apache.lucene.search.FieldCache;
|
||||||
import org.apache.lucene.search.Query;
|
import org.apache.lucene.search.Query;
|
||||||
|
@ -36,6 +37,8 @@ import org.apache.lucene.search.cache.LongValuesCreator;
|
||||||
import org.apache.lucene.util.BytesRef;
|
import org.apache.lucene.util.BytesRef;
|
||||||
import org.apache.lucene.util.NumericUtils;
|
import org.apache.lucene.util.NumericUtils;
|
||||||
import org.apache.lucene.util.TrieFieldHelper;
|
import org.apache.lucene.util.TrieFieldHelper;
|
||||||
|
import org.apache.lucene.analysis.TokenStream;
|
||||||
|
import org.apache.lucene.analysis.NumericTokenStream;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -165,6 +168,44 @@ public class TrieDateField extends DateField {
|
||||||
return readableToIndexed(storedToReadable(f));
|
return readableToIndexed(storedToReadable(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Fieldable createField(SchemaField field, Object value, float boost) {
|
||||||
|
boolean indexed = field.indexed();
|
||||||
|
boolean stored = field.stored();
|
||||||
|
|
||||||
|
if (!indexed && !stored) {
|
||||||
|
if (log.isTraceEnabled())
|
||||||
|
log.trace("Ignoring unindexed/unstored field: " + field);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ps = precisionStep;
|
||||||
|
|
||||||
|
byte[] arr=null;
|
||||||
|
TokenStream ts=null;
|
||||||
|
|
||||||
|
long time = (value instanceof Date)
|
||||||
|
? ((Date)value).getTime()
|
||||||
|
: super.parseMath(null, value.toString()).getTime();
|
||||||
|
|
||||||
|
if (stored) arr = TrieFieldHelper.toArr(time);
|
||||||
|
if (indexed) ts = new NumericTokenStream(ps).setLongValue(time);
|
||||||
|
|
||||||
|
Field f;
|
||||||
|
if (stored) {
|
||||||
|
f = new Field(field.getName(), arr);
|
||||||
|
if (indexed) f.setTokenStream(ts);
|
||||||
|
} else {
|
||||||
|
f = new Field(field.getName(), ts);
|
||||||
|
}
|
||||||
|
|
||||||
|
// term vectors aren't supported
|
||||||
|
|
||||||
|
f.setOmitNorms(field.omitNorms());
|
||||||
|
f.setOmitTermFreqAndPositions(field.omitTf());
|
||||||
|
f.setBoost(boost);
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Query getRangeQuery(QParser parser, SchemaField field, String min, String max, boolean minInclusive, boolean maxInclusive) {
|
public Query getRangeQuery(QParser parser, SchemaField field, String min, String max, boolean minInclusive, boolean maxInclusive) {
|
||||||
|
|
Loading…
Reference in New Issue