Index: lucene/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynLookup.java =================================================================== --- lucene/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynLookup.java (revision 1140383) +++ lucene/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynLookup.java (working copy) @@ -41,6 +41,7 @@ import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.Scorer; import org.apache.lucene.search.TermQuery; +import org.apache.lucene.search.TotalHitCountCollector; import org.apache.lucene.store.FSDirectory; @@ -48,24 +49,6 @@ * Test program to look up synonyms. */ public class SynLookup { - - final static class CountingCollector extends Collector { - public int numHits = 0; - - @Override - public void setScorer(Scorer scorer) throws IOException {} - @Override - public void collect(int doc) throws IOException { - numHits++; - } - - @Override - public void setNextReader(AtomicReaderContext context) {} - @Override - public boolean acceptsDocsOutOfOrder() { - return true; - } - } public static void main(String[] args) throws IOException { if (args.length != 2) { @@ -78,16 +61,16 @@ String word = args[1]; Query query = new TermQuery(new Term(Syns2Index.F_WORD, word)); - CountingCollector countingCollector = new CountingCollector(); + TotalHitCountCollector countingCollector = new TotalHitCountCollector(); searcher.search(query, countingCollector); - if (countingCollector.numHits == 0) { + if (countingCollector.getTotalHits() == 0) { System.out.println("No synonyms found for " + word); } else { System.out.println("Synonyms found for \"" + word + "\":"); } - ScoreDoc[] hits = searcher.search(query, countingCollector.numHits).scoreDocs; + ScoreDoc[] hits = searcher.search(query, countingCollector.getTotalHits()).scoreDocs; for (int i = 0; i < hits.length; i++) { Document doc = searcher.doc(hits[i].doc); Index: lucene/contrib/wordnet/src/java/org/apache/lucene/wordnet/Syns2Index.java =================================================================== --- lucene/contrib/wordnet/src/java/org/apache/lucene/wordnet/Syns2Index.java (revision 1140383) +++ lucene/contrib/wordnet/src/java/org/apache/lucene/wordnet/Syns2Index.java (working copy) @@ -22,6 +22,7 @@ import java.io.FileInputStream; import java.io.InputStreamReader; import java.io.PrintStream; +import java.io.Reader; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -31,7 +32,7 @@ import java.util.TreeSet; import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.standard.StandardAnalyzer; +import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexWriter; @@ -90,9 +91,15 @@ public static final String F_WORD = "word"; /** - * + * we don't actually analyze any text (only a NOT_ANALYZED field), + * but analyzer can't be null, docinverter wants the offset gap! */ - private static final Analyzer ana = new StandardAnalyzer(Version.LUCENE_CURRENT); + private static final Analyzer ana = new Analyzer() { + @Override + public TokenStream tokenStream(String fieldName, Reader reader) { + return null; + } + }; /** * Takes arg of prolog file name and index directory. Index: lucene/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynExpand.java =================================================================== --- lucene/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynExpand.java (revision 1140383) +++ lucene/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynExpand.java (working copy) @@ -17,7 +17,6 @@ * limitations under the License. */ -import java.io.File; import java.io.IOException; import java.io.StringReader; import java.util.HashSet; @@ -28,7 +27,6 @@ import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.TokenStream; -import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; import org.apache.lucene.document.Document; import org.apache.lucene.index.IndexReader; @@ -41,8 +39,6 @@ import org.apache.lucene.search.Query; import org.apache.lucene.search.Scorer; import org.apache.lucene.search.TermQuery; -import org.apache.lucene.store.FSDirectory; -import org.apache.lucene.util.Version; /** @@ -54,48 +50,13 @@ public final class SynExpand { /** - * Test driver for synonym expansion. - * Uses boost factor of 0.9 for illustrative purposes. - * - * If you pass in the query "big dog" then it prints out: - * - *
-	 * Query: big adult^0.9 bad^0.9 bighearted^0.9 boastful^0.9 boastfully^0.9 bounteous^0.9 bountiful^0.9 braggy^0.9 crowing^0.9 freehanded^0.9 giving^0.9 grown^0.9 grownup^0.9 handsome^0.9 large^0.9 liberal^0.9 magnanimous^0.9 momentous^0.9 openhanded^0.9 prominent^0.9 swelled^0.9 vainglorious^0.9 vauntingly^0.9
-	 * dog andiron^0.9 blackguard^0.9 bounder^0.9 cad^0.9 chase^0.9 click^0.9 detent^0.9 dogtooth^0.9 firedog^0.9 frank^0.9 frankfurter^0.9 frump^0.9 heel^0.9 hotdog^0.9 hound^0.9 pawl^0.9 tag^0.9 tail^0.9 track^0.9 trail^0.9 weenie^0.9 wiener^0.9 wienerwurst^0.9
-	 * 
- */ - public static void main(String[] args) throws IOException - { - if (args.length != 2) - { - System.out.println( - "java org.apache.lucene.wordnet.SynExpand "); - } - - FSDirectory directory = FSDirectory.open(new File(args[0])); - IndexSearcher searcher = new IndexSearcher(directory, true); - - String query = args[1]; - String field = "contents"; - - Query q = expand( query, searcher, new StandardAnalyzer(Version.LUCENE_CURRENT), field, 0.9f); - System.out.println( "Query: " + q.toString( field)); - - - - searcher.close(); - directory.close(); - } - - - /** * Perform synonym expansion on a query. * * @param query users query that is assumed to not have any "special" query syntax, thus it should be just normal words, so "big dog" makes sense, but a query like "title:foo^1.2" doesn't as this should presumably be passed directly to the default query parser. * * @param syns a opened to the Lucene index you previously created with {@link Syns2Index}. The searcher is not closed or otherwise altered. * - * @param a optional analyzer used to parse the users query else {@link StandardAnalyzer} is used + * @param a analyzer used to parse the users query. * * @param f optional field name to search in or null if you want the default of "contents" * @@ -113,7 +74,6 @@ final Set already = new HashSet(); // avoid dups List top = new LinkedList(); // needs to be separately listed.. final String field = ( f == null) ? "contents" : f; - if ( a == null) a = new StandardAnalyzer(Version.LUCENE_CURRENT); // [1] Parse query into separate words so that when we expand we can avoid dups TokenStream ts = a.reusableTokenStream( field, new StringReader( query)); Index: lucene/contrib/wordnet/build.xml =================================================================== --- lucene/contrib/wordnet/build.xml (revision 1140383) +++ lucene/contrib/wordnet/build.xml (working copy) @@ -30,22 +30,6 @@ - - - - - - - - - - - - - - - Index already exists - must remove first. @@ -83,24 +67,4 @@ - - - Index does not exist. - - - - Must specify 'query' property. - - - - - - - - - - - - - Index: lucene/contrib/misc/src/java/org/apache/lucene/index/MultiPassIndexSplitter.java =================================================================== --- lucene/contrib/misc/src/java/org/apache/lucene/index/MultiPassIndexSplitter.java (revision 1140383) +++ lucene/contrib/misc/src/java/org/apache/lucene/index/MultiPassIndexSplitter.java (working copy) @@ -21,7 +21,6 @@ import java.io.IOException; import java.util.ArrayList; -import org.apache.lucene.analysis.core.WhitespaceAnalyzer; import org.apache.lucene.index.IndexWriter; // javadoc import org.apache.lucene.index.IndexWriterConfig.OpenMode; import org.apache.lucene.store.Directory; @@ -98,7 +97,7 @@ } IndexWriter w = new IndexWriter(outputs[i], new IndexWriterConfig( Version.LUCENE_CURRENT, - new WhitespaceAnalyzer(Version.LUCENE_CURRENT)) + null) .setOpenMode(OpenMode.CREATE)); System.err.println("Writing part " + (i + 1) + " ..."); w.addIndexes(input); Index: lucene/contrib/misc/src/java/org/apache/lucene/misc/IndexMergeTool.java =================================================================== --- lucene/contrib/misc/src/java/org/apache/lucene/misc/IndexMergeTool.java (revision 1140383) +++ lucene/contrib/misc/src/java/org/apache/lucene/misc/IndexMergeTool.java (working copy) @@ -16,7 +16,6 @@ * limitations under the License. */ -import org.apache.lucene.analysis.core.WhitespaceAnalyzer; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.IndexWriterConfig.OpenMode; @@ -40,7 +39,7 @@ FSDirectory mergedIndex = FSDirectory.open(new File(args[0])); IndexWriter writer = new IndexWriter(mergedIndex, new IndexWriterConfig( - Version.LUCENE_CURRENT, new WhitespaceAnalyzer(Version.LUCENE_CURRENT)) + Version.LUCENE_CURRENT, null) .setOpenMode(OpenMode.CREATE)); Directory[] indexes = new Directory[args.length - 1]; Index: lucene/contrib/misc/build.xml =================================================================== --- lucene/contrib/misc/build.xml (revision 1140383) +++ lucene/contrib/misc/build.xml (working copy) @@ -27,22 +27,6 @@ - - - - - - - - - - - - - - -