From 7ef048e01c4fcafb94b1ced5eeed710c0ae02638 Mon Sep 17 00:00:00 2001 From: Uwe Schindler Date: Fri, 23 Jan 2009 16:44:17 +0000 Subject: [PATCH] Optimize the test index as preparation for LUCENE-1483, because the statistics on visited terms in TrieRangeQuery/-Filter only work correctly for optimized indexes (as the count is reset on each query execution. So the new multisegment-search must have a one-segment index to only execute the query one time) git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@737079 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/java/org/apache/lucene/search/trie/TrieRangeQuery.java | 1 + .../test/org/apache/lucene/search/trie/TestTrieRangeQuery.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/contrib/queries/src/java/org/apache/lucene/search/trie/TrieRangeQuery.java b/contrib/queries/src/java/org/apache/lucene/search/trie/TrieRangeQuery.java index 3ff1f26b8a1..ce486f8bf31 100644 --- a/contrib/queries/src/java/org/apache/lucene/search/trie/TrieRangeQuery.java +++ b/contrib/queries/src/java/org/apache/lucene/search/trie/TrieRangeQuery.java @@ -102,6 +102,7 @@ public final class TrieRangeQuery extends ConstantScoreQuery { /** * EXPERT: Return the number of terms visited during the last execution of the query. * This may be used for performance comparisons of different trie variants and their effectiveness. + * When using this method be sure to query an one-segment index (optimized one) to get correct results. * This method is not thread safe, be sure to only call it when no query is running! * @throws IllegalStateException if query was not yet executed. */ diff --git a/contrib/queries/src/test/org/apache/lucene/search/trie/TestTrieRangeQuery.java b/contrib/queries/src/test/org/apache/lucene/search/trie/TestTrieRangeQuery.java index e686e6e6ddb..0bdcb3237a3 100644 --- a/contrib/queries/src/test/org/apache/lucene/search/trie/TestTrieRangeQuery.java +++ b/contrib/queries/src/test/org/apache/lucene/search/trie/TestTrieRangeQuery.java @@ -71,8 +71,9 @@ public class TestTrieRangeQuery extends LuceneTestCase writer.addDocument(doc); } + writer.optimize(); writer.close(); - searcher=new IndexSearcher(directory); + searcher=new IndexSearcher(directory); } catch (Exception e) { throw new Error(e); }