Skip to content
Browse files

add whitespace analyzer.

  • Loading branch information...
1 parent dda9276 commit fe43cf0e9a134c0dd5c1d19f75e48da549bdc4e3 Robert Newson committed Oct 13, 2010
View
1 README.md
@@ -176,6 +176,7 @@ Lucene has numerous ways of converting free-form text into tokens, these classes
<li>simple</li>
<li>standard</li>
<li>thai</li>
+<li>whitespace</li>
</ul>
The "perfield" option lets you use a different analyzer for different fields and is configured as follows;
View
6 src/main/java/com/github/rnewson/couchdb/lucene/util/Analyzers.java
@@ -27,6 +27,7 @@
import org.apache.lucene.analysis.PorterStemFilter;
import org.apache.lucene.analysis.SimpleAnalyzer;
import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.WhitespaceAnalyzer;
import org.apache.lucene.analysis.br.BrazilianAnalyzer;
import org.apache.lucene.analysis.cjk.CJKAnalyzer;
import org.apache.lucene.analysis.cn.ChineseAnalyzer;
@@ -138,6 +139,11 @@ public Analyzer newAnalyzer(final String args) {
public Analyzer newAnalyzer(final String args) {
return new ThaiAnalyzer(Constants.VERSION);
}
+ },
+ WHITESPACE {
+ public Analyzer newAnalyzer(final String args) {
+ return new WhitespaceAnalyzer();
+ }
};
private static final class PorterStemAnalyzer extends Analyzer {
View
6 src/test/java/com/github/rnewson/couchdb/lucene/util/AnalyzersTest.java
@@ -6,6 +6,7 @@
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.PerFieldAnalyzerWrapper;
+import org.apache.lucene.analysis.WhitespaceAnalyzer;
import org.apache.lucene.analysis.fr.FrenchAnalyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.junit.Test;
@@ -23,6 +24,11 @@ public void testFrench() {
}
@Test
+ public void testWhitespace() {
+ assertThat(Analyzers.getAnalyzer("whitespace"), is(WhitespaceAnalyzer.class));
+ }
+
+ @Test
public void testPerField() {
final Analyzer analyzer = Analyzers.getAnalyzer("perfield:{name:\"standard\",age:\"keyword\"}");
assertThat(analyzer, is(PerFieldAnalyzerWrapper.class));

0 comments on commit fe43cf0

Please sign in to comment.
Something went wrong with that request. Please try again.