~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to solr/core/src/java/org/apache/solr/schema/TrieDateField.java

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
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
8
 
 *
9
 
 *     http://www.apache.org/licenses/LICENSE-2.0
10
 
 *
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.
16
 
 */
17
 
 
18
 
package org.apache.solr.schema;
19
 
 
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;
28
 
 
29
 
import java.util.Map;
30
 
import java.util.Date;
31
 
import java.io.IOException;
32
 
 
33
 
public class TrieDateField extends DateField {
34
 
 
35
 
  final TrieField wrappedField = new TrieField() {{
36
 
    type = TrieTypes.DATE;
37
 
  }};
38
 
 
39
 
  @Override
40
 
  protected void init(IndexSchema schema, Map<String, String> args) {
41
 
    wrappedField.init(schema, args);
42
 
    analyzer = wrappedField.analyzer;
43
 
    queryAnalyzer = wrappedField.queryAnalyzer;
44
 
  }
45
 
 
46
 
  @Override
47
 
  public Date toObject(Fieldable f) {
48
 
    return (Date) wrappedField.toObject(f);
49
 
  }
50
 
 
51
 
  @Override
52
 
  public SortField getSortField(SchemaField field, boolean top) {
53
 
    return wrappedField.getSortField(field, top);
54
 
  }
55
 
 
56
 
  @Override
57
 
  public ValueSource getValueSource(SchemaField field, QParser parser) {
58
 
    return wrappedField.getValueSource(field, parser);
59
 
  }
60
 
 
61
 
  /**
62
 
   * @return the precisionStep used to index values into the field
63
 
   */
64
 
  public int getPrecisionStep() {
65
 
    return wrappedField.getPrecisionStep();
66
 
  }
67
 
 
68
 
  @Override
69
 
  public void write(XMLWriter xmlWriter, String name, Fieldable f) throws IOException {
70
 
    wrappedField.write(xmlWriter, name, f);
71
 
  }
72
 
 
73
 
  @Override
74
 
  public void write(TextResponseWriter writer, String name, Fieldable f) throws IOException {
75
 
    wrappedField.write(writer, name, f);
76
 
  }
77
 
 
78
 
  @Override
79
 
  public boolean isTokenized() {
80
 
    return wrappedField.isTokenized();
81
 
  }
82
 
 
83
 
  @Override
84
 
  public boolean multiValuedFieldCache() {
85
 
    return wrappedField.multiValuedFieldCache();
86
 
  }
87
 
 
88
 
  @Override
89
 
  public String storedToReadable(Fieldable f) {
90
 
    return wrappedField.storedToReadable(f);
91
 
  }
92
 
 
93
 
  @Override
94
 
  public String readableToIndexed(String val) {  
95
 
    return wrappedField.readableToIndexed(val);
96
 
  }
97
 
 
98
 
  @Override
99
 
  public String toInternal(String val) {
100
 
    return wrappedField.toInternal(val);
101
 
  }
102
 
 
103
 
  @Override
104
 
  public String toExternal(Fieldable f) {
105
 
    return wrappedField.toExternal(f);
106
 
  }
107
 
 
108
 
  @Override
109
 
  public String indexedToReadable(String indexedForm) {
110
 
    return wrappedField.indexedToReadable(indexedForm);
111
 
  }
112
 
 
113
 
  @Override
114
 
  public String storedToIndexed(Fieldable f) {
115
 
    return wrappedField.storedToIndexed(f);
116
 
  }
117
 
 
118
 
  @Override
119
 
  public Fieldable createField(SchemaField field, String externalVal, float boost) {
120
 
    return wrappedField.createField(field, externalVal, boost);
121
 
  }
122
 
 
123
 
  @Override
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);
126
 
  }
127
 
  
128
 
  @Override
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);
134
 
  }
135
 
}