1
package org.apache.solr.handler.component;
3
import org.apache.lucene.analysis.Token;
4
import org.apache.lucene.index.IndexReader;
5
import org.apache.solr.core.SolrCore;
6
import org.apache.solr.search.SolrIndexSearcher;
7
import org.apache.solr.spelling.SolrSpellChecker;
8
import org.apache.solr.spelling.SpellingOptions;
9
import org.apache.solr.spelling.SpellingResult;
11
import java.io.IOException;
12
import java.util.Collection;
13
import java.util.Collections;
14
import java.util.Iterator;
16
* Licensed to the Apache Software Foundation (ASF) under one or more
17
* contributor license agreements. See the NOTICE file distributed with
18
* this work for additional information regarding copyright ownership.
19
* The ASF licenses this file to You under the Apache License, Version 2.0
20
* (the "License"); you may not use this file except in compliance with
21
* the License. You may obtain a copy of the License at
23
* http://www.apache.org/licenses/LICENSE-2.0
25
* Unless required by applicable law or agreed to in writing, software
26
* distributed under the License is distributed on an "AS IS" BASIS,
27
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28
* See the License for the specific language governing permissions and
29
* limitations under the License.
34
* A Dummy SpellChecker for testing purposes
37
public class DummyCustomParamSpellChecker extends SolrSpellChecker {
40
public void reload(SolrCore core, SolrIndexSearcher searcher) throws IOException {
45
public void build(SolrCore core, SolrIndexSearcher searcher) {
50
public SpellingResult getSuggestions(Collection<Token> tokens, IndexReader reader, int count, boolean onlyMorePopular, boolean extendedResults) throws IOException {
51
return getSuggestions(new SpellingOptions(tokens, reader, count, onlyMorePopular, extendedResults, 0, null));
55
public SpellingResult getSuggestions(SpellingOptions options) throws IOException {
57
SpellingResult result = new SpellingResult();
58
//just spit back out the results
59
Iterator<String> iterator = options.customParams.getParameterNamesIterator();
61
while (iterator.hasNext()){
62
String name = iterator.next();
63
String value = options.customParams.get(name);
64
result.add(new Token(name, i++, i++), Collections.singletonList(value));