[Mulgara-svn] r1314 - trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene

ronald at mulgara.org ronald at mulgara.org
Wed Oct 15 02:15:30 UTC 2008


Author: ronald
Date: 2008-10-14 19:15:29 -0700 (Tue, 14 Oct 2008)
New Revision: 1314

Modified:
   trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndex.java
Log:
Fixed removeAll() to work for large indexes with many documents too. A
lucene wildcard query is expanded into a boolean-query with one term for
each matched term, which quickly leads to a TooManyTerms exception.
Instead we now use the proper MatchAllDocsQuery, which should also be
more efficient.


Modified: trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndex.java
===================================================================
--- trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndex.java	2008-10-15 02:15:26 UTC (rev 1313)
+++ trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndex.java	2008-10-15 02:15:29 UTC (rev 1314)
@@ -53,6 +53,7 @@
 import org.apache.lucene.search.BooleanQuery;
 import org.apache.lucene.search.HitCollector;
 import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MatchAllDocsQuery;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.TermQuery;
@@ -541,7 +542,9 @@
 
   /**
    * Remove all entries in the string pool. Unlike {@link removeAllIndexes}, this may be
-   * called while readers are active. However, this method may be very slow.
+   * called while readers are active. However, this method may be very slow. Also note
+   * that this will <strong>not</strong> remove entries that have been added as part of
+   * the current transaction!
    *
    * @throws FullTextStringIndexException Exception occurs when attempting to remove the documents
    */
@@ -552,12 +555,7 @@
     }
 
     try {
-      QueryParser parser = new QueryParser(ID_KEY, analyzer);
-      parser.setAllowLeadingWildcard(true);
-      indexer.deleteDocuments(parser.parse("*"));
-    } catch (ParseException ex) {
-      logger.error("Unexpected internal error", ex);
-      throw new FullTextStringIndexException("Unexpected internal error", ex);
+      indexer.deleteDocuments(new MatchAllDocsQuery());
     } catch (IOException ex) {
       logger.error("Unable to delete all documents", ex);
       throw new FullTextStringIndexException("Unable to delete all documents", ex);




More information about the Mulgara-svn mailing list