01: /*
02: * Copyright 2004-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.compass.core.lucene.engine.spellcheck.queryparser;
18:
19: import org.apache.lucene.analysis.Analyzer;
20: import org.apache.lucene.queryParser.CompassMultiFieldQueryParser;
21: import org.apache.lucene.queryParser.CompassQueryParser;
22: import org.compass.core.lucene.engine.queryparser.DefaultLuceneQueryParser;
23:
24: /**
25: * @author kimchy
26: */
27: public class SpellCheckLuceneQueryParser extends
28: DefaultLuceneQueryParser {
29:
30: protected CompassQueryParser createQueryParser(String property,
31: Analyzer analyzer, boolean forceAnalyzer) {
32: if (getSearchEngineFactory().getSpellCheckManager() != null) {
33: return new SpellCheckQueryParser(property, analyzer,
34: getMapping(), getSearchEngineFactory(),
35: forceAnalyzer);
36: }
37: return super .createQueryParser(property, analyzer,
38: forceAnalyzer);
39: }
40:
41: protected CompassMultiFieldQueryParser createMultiQueryParser(
42: String[] properties, Analyzer analyzer,
43: boolean forceAnalyzer) {
44: if (getSearchEngineFactory().getSpellCheckManager() != null) {
45: return new SpellCheckMultiFieldQueryParser(properties,
46: analyzer, getMapping(), getSearchEngineFactory(),
47: forceAnalyzer);
48: }
49: return super.createMultiQueryParser(properties, analyzer,
50: forceAnalyzer);
51: }
52: }
|