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

« back to all changes in this revision

Viewing changes to solr/core/src/java/org/apache/solr/spelling/QueryConverter.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
 
package org.apache.solr.spelling;
2
 
/**
3
 
 * Licensed to the Apache Software Foundation (ASF) under one or more
4
 
 * contributor license agreements.  See the NOTICE file distributed with
5
 
 * this work for additional information regarding copyright ownership.
6
 
 * The ASF licenses this file to You under the Apache License, Version 2.0
7
 
 * (the "License"); you may not use this file except in compliance with
8
 
 * the License.  You may obtain a copy of the License at
9
 
 *
10
 
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 
 *
12
 
 * Unless required by applicable law or agreed to in writing, software
13
 
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 
 * See the License for the specific language governing permissions and
16
 
 * limitations under the License.
17
 
 */
18
 
 
19
 
import org.apache.lucene.analysis.Analyzer;
20
 
import org.apache.lucene.analysis.Token;
21
 
import org.apache.solr.common.util.NamedList;
22
 
import org.apache.solr.util.plugin.NamedListInitializedPlugin;
23
 
 
24
 
import java.util.Collection;
25
 
 
26
 
/**
27
 
 * <p>
28
 
 * The QueryConverter is an abstract base class defining a method for converting
29
 
 * input "raw" queries into a set of tokens for spell checking. It is used to
30
 
 * "parse" the CommonParams.Q (the input query) and converts it to tokens.
31
 
 * </p>
32
 
 * 
33
 
 * <p>
34
 
 * It is only invoked for the CommonParams.Q parameter, and <b>not</b> the
35
 
 * "spellcheck.q" parameter. Systems that use their own query parser or those
36
 
 * that find issue with the basic implementation should implement their
37
 
 * own QueryConverter instead of using the provided implementation
38
 
 * (SpellingQueryConverter) by overriding the appropriate methods on the
39
 
 * SpellingQueryConverter and registering it in the solrconfig.xml
40
 
 * </p>
41
 
 * 
42
 
 * <p>
43
 
 * Refer to <a href="http://wiki.apache.org/solr/SpellCheckComponent">SpellCheckComponent</a>
44
 
 * for more details
45
 
 * </p>
46
 
 * 
47
 
 * @since solr 1.3
48
 
 */
49
 
public abstract class QueryConverter implements NamedListInitializedPlugin {
50
 
  private NamedList args;
51
 
 
52
 
  protected Analyzer analyzer;
53
 
 
54
 
  public void init(NamedList args) {
55
 
    this.args = args;
56
 
  }
57
 
 
58
 
  /**
59
 
   * @param original
60
 
   * @return The Collection of {@link org.apache.lucene.analysis.Token}s for
61
 
   *         the query. Offsets on the Token should correspond to the correct
62
 
   *         offset in the origQuery
63
 
   */
64
 
  public abstract Collection<Token> convert(String original);
65
 
 
66
 
  /**
67
 
   * Set the analyzer to use. Must be set before any calls to convert.
68
 
   * 
69
 
   * @param analyzer
70
 
   */
71
 
  public void setAnalyzer(Analyzer analyzer) {
72
 
    this.analyzer = analyzer;
73
 
  }
74
 
 
75
 
  public Analyzer getAnalyzer() {
76
 
    return analyzer;
77
 
  }
78
 
}