2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
18
package org.apache.solr.schema;
20
import org.apache.solr.search.function.ValueSource;
21
import org.apache.solr.search.QParser;
22
import org.apache.solr.response.TextResponseWriter;
23
import org.apache.solr.response.XMLWriter;
24
import org.apache.lucene.document.Fieldable;
25
import org.apache.lucene.search.SortField;
26
import org.apache.lucene.search.Query;
27
import org.apache.lucene.search.NumericRangeQuery;
30
import java.util.Date;
31
import java.io.IOException;
33
public class TrieDateField extends DateField {
35
final TrieField wrappedField = new TrieField() {{
36
type = TrieTypes.DATE;
40
protected void init(IndexSchema schema, Map<String, String> args) {
41
wrappedField.init(schema, args);
42
analyzer = wrappedField.analyzer;
43
queryAnalyzer = wrappedField.queryAnalyzer;
47
public Date toObject(Fieldable f) {
48
return (Date) wrappedField.toObject(f);
52
public SortField getSortField(SchemaField field, boolean top) {
53
return wrappedField.getSortField(field, top);
57
public ValueSource getValueSource(SchemaField field, QParser parser) {
58
return wrappedField.getValueSource(field, parser);
62
* @return the precisionStep used to index values into the field
64
public int getPrecisionStep() {
65
return wrappedField.getPrecisionStep();
69
public void write(XMLWriter xmlWriter, String name, Fieldable f) throws IOException {
70
wrappedField.write(xmlWriter, name, f);
74
public void write(TextResponseWriter writer, String name, Fieldable f) throws IOException {
75
wrappedField.write(writer, name, f);
79
public boolean isTokenized() {
80
return wrappedField.isTokenized();
84
public boolean multiValuedFieldCache() {
85
return wrappedField.multiValuedFieldCache();
89
public String storedToReadable(Fieldable f) {
90
return wrappedField.storedToReadable(f);
94
public String readableToIndexed(String val) {
95
return wrappedField.readableToIndexed(val);
99
public String toInternal(String val) {
100
return wrappedField.toInternal(val);
104
public String toExternal(Fieldable f) {
105
return wrappedField.toExternal(f);
109
public String indexedToReadable(String indexedForm) {
110
return wrappedField.indexedToReadable(indexedForm);
114
public String storedToIndexed(Fieldable f) {
115
return wrappedField.storedToIndexed(f);
119
public Fieldable createField(SchemaField field, String externalVal, float boost) {
120
return wrappedField.createField(field, externalVal, boost);
124
public Query getRangeQuery(QParser parser, SchemaField field, String min, String max, boolean minInclusive, boolean maxInclusive) {
125
return wrappedField.getRangeQuery(parser, field, min, max, minInclusive, maxInclusive);
129
public Query getRangeQuery(QParser parser, SchemaField sf, Date min, Date max, boolean minInclusive, boolean maxInclusive) {
130
return NumericRangeQuery.newLongRange(sf.getName(), wrappedField.precisionStep,
131
min == null ? null : min.getTime(),
132
max == null ? null : max.getTime(),
133
minInclusive, maxInclusive);