SOLR-11598: Fix bug while setting and resetting string doc-values while exporting documents

This commit is contained in:
Varun Thacker 2018-08-23 23:57:48 -07:00
parent aa10cb7802
commit 9e78be40c3
2 changed files with 25 additions and 2 deletions

View File

@ -96,10 +96,10 @@ class StringValue implements SortValue {
}
public void setNextReader(LeafReaderContext context) throws IOException {
if (globalDocValues instanceof MultiDocValues.MultiSortedDocValues) {
if (ordinalMap != null) {
toGlobal = ordinalMap.getGlobalOrds(context.ord);
docValues = DocValues.getSorted(context.reader(), field);
}
docValues = DocValues.getSorted(context.reader(), field);
lastDocID = 0;
}

View File

@ -84,6 +84,29 @@ public class TestExportWriter extends SolrTestCaseJ4 {
}
@Test
public void testSortingOnFieldWithNoValues() throws Exception {
assertU(delQ("*:*"));
assertU(commit());
assertU(adoc("id","1"));
assertU(commit());
// 10 fields
List<String> fieldNames = new ArrayList<>(Arrays.asList("floatdv", "intdv", "stringdv", "longdv", "doubledv",
"datedv", "booleandv", "field1_s_dv", "field2_i_p", "field3_l_p"));
for (String sortField : fieldNames) {
String resp = h.query(req("q", "*:*", "qt", "/export", "fl", "id," + sortField, "sort", sortField + " desc"));
assertJsonEquals(resp, "{\n" +
" \"responseHeader\":{\"status\":0},\n" +
" \"response\":{\n" +
" \"numFound\":1,\n" +
" \"docs\":[{\n" +
" \"id\":\"1\"}]}}");
}
}
public static void createIndex() {
assertU(adoc("id","1",
"floatdv","2.1",