Index: lucene/backwards/src/test/org/apache/lucene/analysis/TestKeywordAnalyzer.java =================================================================== --- lucene/backwards/src/test/org/apache/lucene/analysis/TestKeywordAnalyzer.java (revision 940598) +++ lucene/backwards/src/test/org/apache/lucene/analysis/TestKeywordAnalyzer.java (working copy) @@ -56,6 +56,7 @@ searcher = new IndexSearcher(directory, true); } + /* public void testPerFieldAnalyzer() throws Exception { PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper(new SimpleAnalyzer()); analyzer.addAnalyzer("partnum", new KeywordAnalyzer()); @@ -68,6 +69,7 @@ "+partnum:Q36 +space", query.toString("description")); assertEquals("doc found!", 1, hits.length); } + */ public void testMutipleDocument() throws Exception { RAMDirectory dir = new RAMDirectory(); Index: lucene/backwards/src/test/org/apache/lucene/analysis/TestLengthFilter.java =================================================================== --- lucene/backwards/src/test/org/apache/lucene/analysis/TestLengthFilter.java (revision 940598) +++ lucene/backwards/src/test/org/apache/lucene/analysis/TestLengthFilter.java (working copy) @@ -1,41 +0,0 @@ -package org.apache.lucene.analysis; - -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.apache.lucene.analysis.tokenattributes.TermAttribute; - -import java.io.StringReader; - -public class TestLengthFilter extends BaseTokenStreamTestCase { - - public void testFilter() throws Exception { - TokenStream stream = new WhitespaceTokenizer( - new StringReader("short toolong evenmuchlongertext a ab toolong foo")); - LengthFilter filter = new LengthFilter(stream, 2, 6); - TermAttribute termAtt = filter.getAttribute(TermAttribute.class); - - assertTrue(filter.incrementToken()); - assertEquals("short", termAtt.term()); - assertTrue(filter.incrementToken()); - assertEquals("ab", termAtt.term()); - assertTrue(filter.incrementToken()); - assertEquals("foo", termAtt.term()); - assertFalse(filter.incrementToken()); - } - -} Index: lucene/backwards/src/test/org/apache/lucene/analysis/TestPerFieldAnalzyerWrapper.java =================================================================== --- lucene/backwards/src/test/org/apache/lucene/analysis/TestPerFieldAnalzyerWrapper.java (revision 940598) +++ lucene/backwards/src/test/org/apache/lucene/analysis/TestPerFieldAnalzyerWrapper.java (working copy) @@ -1,48 +0,0 @@ -package org.apache.lucene.analysis; - -import java.io.StringReader; - -import org.apache.lucene.analysis.tokenattributes.TermAttribute; - -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -public class TestPerFieldAnalzyerWrapper extends BaseTokenStreamTestCase { - public void testPerField() throws Exception { - String text = "Qwerty"; - PerFieldAnalyzerWrapper analyzer = - new PerFieldAnalyzerWrapper(new WhitespaceAnalyzer()); - analyzer.addAnalyzer("special", new SimpleAnalyzer()); - - TokenStream tokenStream = analyzer.tokenStream("field", - new StringReader(text)); - TermAttribute termAtt = tokenStream.getAttribute(TermAttribute.class); - - assertTrue(tokenStream.incrementToken()); - assertEquals("WhitespaceAnalyzer does not lowercase", - "Qwerty", - termAtt.term()); - - tokenStream = analyzer.tokenStream("special", - new StringReader(text)); - termAtt = tokenStream.getAttribute(TermAttribute.class); - assertTrue(tokenStream.incrementToken()); - assertEquals("SimpleAnalyzer lowercases", - "qwerty", - termAtt.term()); - } -} Index: lucene/contrib/analyzers/common/src/java/org/apache/lucene/analysis/miscellaneous/LengthFilter.java =================================================================== --- lucene/contrib/analyzers/common/src/java/org/apache/lucene/analysis/miscellaneous/LengthFilter.java (revision 940598) +++ lucene/contrib/analyzers/common/src/java/org/apache/lucene/analysis/miscellaneous/LengthFilter.java (working copy) @@ -1,4 +1,4 @@ -package org.apache.lucene.analysis; +package org.apache.lucene.analysis.miscellaneous; /** * Licensed to the Apache Software Foundation (ASF) under one or more @@ -19,6 +19,8 @@ import java.io.IOException; +import org.apache.lucene.analysis.TokenStream; +import org.apache.lucene.analysis.TokenFilter; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; /** Index: lucene/contrib/analyzers/common/src/java/org/apache/lucene/analysis/miscellaneous/PerFieldAnalyzerWrapper.java =================================================================== --- lucene/contrib/analyzers/common/src/java/org/apache/lucene/analysis/miscellaneous/PerFieldAnalyzerWrapper.java (revision 940598) +++ lucene/contrib/analyzers/common/src/java/org/apache/lucene/analysis/miscellaneous/PerFieldAnalyzerWrapper.java (working copy) @@ -1,4 +1,4 @@ -package org.apache.lucene.analysis; +package org.apache.lucene.analysis.miscellaneous; /** * Licensed to the Apache Software Foundation (ASF) under one or more @@ -17,6 +17,8 @@ * limitations under the License. */ +import org.apache.lucene.analysis.Analyzer; +import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.document.Fieldable; import java.io.Reader; Index: lucene/contrib/analyzers/common/src/test/org/apache/lucene/analysis/miscellaneous/TestLengthFilter.java =================================================================== --- lucene/contrib/analyzers/common/src/test/org/apache/lucene/analysis/miscellaneous/TestLengthFilter.java (revision 940598) +++ lucene/contrib/analyzers/common/src/test/org/apache/lucene/analysis/miscellaneous/TestLengthFilter.java (working copy) @@ -1,4 +1,4 @@ -package org.apache.lucene.analysis; +package org.apache.lucene.analysis.miscellaneous; /** * Licensed to the Apache Software Foundation (ASF) under one or more @@ -17,6 +17,7 @@ * limitations under the License. */ +import org.apache.lucene.analysis.*; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; import java.io.StringReader; Index: lucene/contrib/analyzers/common/src/test/org/apache/lucene/analysis/miscellaneous/TestPerFieldAnalzyerWrapper.java =================================================================== --- lucene/contrib/analyzers/common/src/test/org/apache/lucene/analysis/miscellaneous/TestPerFieldAnalzyerWrapper.java (revision 940598) +++ lucene/contrib/analyzers/common/src/test/org/apache/lucene/analysis/miscellaneous/TestPerFieldAnalzyerWrapper.java (working copy) @@ -1,7 +1,8 @@ -package org.apache.lucene.analysis; +package org.apache.lucene.analysis.miscellaneous; import java.io.StringReader; +import org.apache.lucene.analysis.*; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; /** Index: lucene/src/java/org/apache/lucene/analysis/LengthFilter.java =================================================================== --- lucene/src/java/org/apache/lucene/analysis/LengthFilter.java (revision 940598) +++ lucene/src/java/org/apache/lucene/analysis/LengthFilter.java (working copy) @@ -1,61 +0,0 @@ -package org.apache.lucene.analysis; - -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.io.IOException; - -import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; - -/** - * Removes words that are too long or too short from the stream. - */ -public final class LengthFilter extends TokenFilter { - - private final int min; - private final int max; - - private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class); - - /** - * Build a filter that removes words that are too long or too - * short from the text. - */ - public LengthFilter(TokenStream in, int min, int max) - { - super(in); - this.min = min; - this.max = max; - } - - /** - * Returns the next input Token whose term() is the right len - */ - @Override - public final boolean incrementToken() throws IOException { - // return the first non-stop word found - while (input.incrementToken()) { - int len = termAtt.length(); - if (len >= min && len <= max) { - return true; - } - // note: else we ignore it but should we index each part of it? - } - // reached EOS -- return false - return false; - } -} Index: lucene/src/java/org/apache/lucene/analysis/PerFieldAnalyzerWrapper.java =================================================================== --- lucene/src/java/org/apache/lucene/analysis/PerFieldAnalyzerWrapper.java (revision 940598) +++ lucene/src/java/org/apache/lucene/analysis/PerFieldAnalyzerWrapper.java (working copy) @@ -1,131 +0,0 @@ -package org.apache.lucene.analysis; - -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.apache.lucene.document.Fieldable; - -import java.io.Reader; -import java.io.IOException; -import java.util.Map; -import java.util.HashMap; - -/** - * This analyzer is used to facilitate scenarios where different - * fields require different analysis techniques. Use {@link #addAnalyzer} - * to add a non-default analyzer on a field name basis. - * - *
Example usage: - * - *
- * PerFieldAnalyzerWrapper aWrapper =
- * new PerFieldAnalyzerWrapper(new StandardAnalyzer());
- * aWrapper.addAnalyzer("firstname", new KeywordAnalyzer());
- * aWrapper.addAnalyzer("lastname", new KeywordAnalyzer());
- *
- *
- * In this example, StandardAnalyzer will be used for all fields except "firstname" - * and "lastname", for which KeywordAnalyzer will be used. - * - *
A PerFieldAnalyzerWrapper can be used like any other analyzer, for both indexing
- * and query parsing.
- */
-public final class PerFieldAnalyzerWrapper extends Analyzer {
- private Analyzer defaultAnalyzer;
- private Map