1
package org.apache.solr.spelling;
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
10
* http://www.apache.org/licenses/LICENSE-2.0
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.
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;
24
import java.util.Collection;
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.
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
43
* Refer to <a href="http://wiki.apache.org/solr/SpellCheckComponent">SpellCheckComponent</a>
49
public abstract class QueryConverter implements NamedListInitializedPlugin {
50
private NamedList args;
52
protected Analyzer analyzer;
54
public void init(NamedList args) {
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
64
public abstract Collection<Token> convert(String original);
67
* Set the analyzer to use. Must be set before any calls to convert.
71
public void setAnalyzer(Analyzer analyzer) {
72
this.analyzer = analyzer;
75
public Analyzer getAnalyzer() {