From 0a225a1cc2eda74b476d9440544736cd7dc361d1 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Mon, 14 Nov 2011 13:46:07 +0000 Subject: [PATCH] can't sort by DocValues string field if reader is SlowMultiReaderWrapper git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1201701 13f79535-47bb-0310-9956-ffa450edef68 --- .../test/org/apache/lucene/search/TestSort.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lucene/src/test/org/apache/lucene/search/TestSort.java b/lucene/src/test/org/apache/lucene/search/TestSort.java index 7ddb2d9c402..fa4a544226b 100644 --- a/lucene/src/test/org/apache/lucene/search/TestSort.java +++ b/lucene/src/test/org/apache/lucene/search/TestSort.java @@ -25,20 +25,21 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import org.apache.lucene.analysis.MockAnalyzer; -import org.apache.lucene.document.IndexDocValuesField; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.FieldType; +import org.apache.lucene.document.IndexDocValuesField; import org.apache.lucene.document.StringField; import org.apache.lucene.document.TextField; import org.apache.lucene.index.CorruptIndexException; -import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexReader.AtomicReaderContext; +import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.MultiReader; import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.index.SlowMultiReaderWrapper; import org.apache.lucene.index.Term; import org.apache.lucene.index.codecs.Codec; import org.apache.lucene.index.values.ValueType; @@ -1218,6 +1219,16 @@ public class TestSort extends LuceneTestCase { // make sure the documents returned by the search match the expected list private void assertMatches(String msg, IndexSearcher searcher, Query query, Sort sort, String expectedResult) throws IOException { + + for(SortField sortField : sort.getSort()) { + if (sortField.getUseIndexValues() && sortField.getType() == SortField.Type.STRING) { + if (searcher.getIndexReader() instanceof SlowMultiReaderWrapper) { + // Cannot use STRING DocValues sort with SlowMultiReaderWrapper + return; + } + } + } + //ScoreDoc[] result = searcher.search (query, null, 1000, sort).scoreDocs; TopDocs hits = searcher.search(query, null, Math.max(1, expectedResult.length()), sort); ScoreDoc[] result = hits.scoreDocs;