commit 8607e3690f08b94ed974bb338e96428da40babde
parent 0a2064846a3ae9d75f46882a0b37801c3bebba88
Author: Dan Callaghan <djc@djc.id.au>
Date: Wed, 31 Dec 2008 17:56:02 +1000
custom query parser
--HG--
extra : convert_revision : f0112f68f75bb4a0bb6f04d9943d181b08586581
Diffstat:
1 file changed, 12 insertions(+), 0 deletions(-)
diff --git a/src/main/java/au/com/miskinhill/search/analysis/PerLanguageAnalyzerWrapper.java b/src/main/java/au/com/miskinhill/search/analysis/PerLanguageAnalyzerWrapper.java
@@ -1,6 +1,8 @@
package au.com.miskinhill.search.analysis;
import java.io.Reader;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
@@ -22,13 +24,23 @@ import org.apache.lucene.analysis.TokenStream;
public class PerLanguageAnalyzerWrapper extends Analyzer {
protected Trie<Analyzer> analyzers;
+ private List<Analyzer> analyzersList = new ArrayList<Analyzer>(); // easier than traversing the trie
public PerLanguageAnalyzerWrapper(Analyzer defaultAnalyzer) {
analyzers = new Trie<Analyzer>(defaultAnalyzer);
+ analyzersList.add(defaultAnalyzer);
}
public void addAnalyzer(String language, Analyzer analyzer) {
analyzers.put(language, analyzer);
+ analyzersList.add(analyzer);
+ }
+
+ /**
+ * Returns a list of all sub-analyzers in this analyzer (including the default one).
+ */
+ public List<Analyzer> getAnalyzers() {
+ return analyzersList;
}
public TokenStream tokenStream(String fieldName, Reader reader) {