From commits-return-106969-apmail-lucene-commits-archive=www.apache.org@lucene.apache.org Thu Mar 7 19:04:50 2019 Return-Path: X-Original-To: apmail-lucene-commits-archive@www.apache.org Delivered-To: apmail-lucene-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2B96018C37 for ; Thu, 7 Mar 2019 19:04:50 +0000 (UTC) Received: (qmail 66739 invoked by uid 500); 7 Mar 2019 19:04:50 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 66728 invoked by uid 99); 7 Mar 2019 19:04:49 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Mar 2019 19:04:49 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 5717287964; Thu, 7 Mar 2019 19:04:49 +0000 (UTC) Date: Thu, 07 Mar 2019 19:04:49 +0000 To: "commits@lucene.apache.org" Subject: [lucene-solr] branch branch_8x updated: SOLR-13261: Make SortableTextField work with export/streaming, now requires useDocValuesAsStored='true' MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <155198548918.27079.2517262781473268212@gitbox.apache.org> From: erick@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: lucene-solr X-Git-Refname: refs/heads/branch_8x X-Git-Reftype: branch X-Git-Oldrev: dac4169b01d66cf4560a008cd1538e775fa3028a X-Git-Newrev: fc76b70bd5555a9391e4a048de89db49a5921643 X-Git-Rev: fc76b70bd5555a9391e4a048de89db49a5921643 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. erick pushed a commit to branch branch_8x in repository https://gitbox.apache.org/repos/asf/lucene-solr.git The following commit(s) were added to refs/heads/branch_8x by this push: new fc76b70 SOLR-13261: Make SortableTextField work with export/streaming, now requires useDocValuesAsStored='true' fc76b70 is described below commit fc76b70bd5555a9391e4a048de89db49a5921643 Author: Erick Erickson AuthorDate: Thu Mar 7 10:59:20 2019 -0800 SOLR-13261: Make SortableTextField work with export/streaming, now requires useDocValuesAsStored='true' (cherry picked from commit 1e09268e781039b62e856cc696aba0e519079bbc) --- solr/CHANGES.txt | 3 +- .../apache/solr/handler/export/ExportWriter.java | 10 ++++++- .../collection1/conf/schema-sortingresponse.xml | 3 ++ .../solr/handler/export/TestExportWriter.java | 34 +++++++++++++++++----- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 37bc10c..692b27f 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -40,7 +40,8 @@ New Features * SOLR-13171 : A true streaming parser for javabin payload/stream without creating any objects (noble) -* SOLR-13261: Make SortableTextField work with export/streaming +* SOLR-13261: Make SortableTextField work with export/streaming. NOTE: requires that the field have + useDocValuesAsStored=true (either explicit or as the default). * SOLR-10436: Add hashRollup Streaming Expression (Joel Bernstein) diff --git a/solr/core/src/java/org/apache/solr/handler/export/ExportWriter.java b/solr/core/src/java/org/apache/solr/handler/export/ExportWriter.java index c80cae3..e4d6da0 100644 --- a/solr/core/src/java/org/apache/solr/handler/export/ExportWriter.java +++ b/solr/core/src/java/org/apache/solr/handler/export/ExportWriter.java @@ -332,9 +332,13 @@ public class ExportWriter implements SolrCore.RawWriter, Closeable { if (!schemaField.hasDocValues()) { throw new IOException(schemaField + " must have DocValues to use this feature."); } - boolean multiValued = schemaField.multiValued(); FieldType fieldType = schemaField.getType(); + + if (fieldType instanceof SortableTextField && schemaField.useDocValuesAsStored() == false) { + throw new IOException(schemaField + " Must have useDocValuesAsStored='true' to be used with export writer"); + } + if (fieldType instanceof IntValueFieldType) { if (multiValued) { writers[i] = new MultiFieldWriter(field, fieldType, schemaField, true); @@ -398,6 +402,10 @@ public class ExportWriter implements SolrCore.RawWriter, Closeable { throw new IOException(field + " must have DocValues to use this feature."); } + if (ft instanceof SortableTextField && schemaField.useDocValuesAsStored() == false) { + throw new IOException(schemaField + " Must have useDocValuesAsStored='true' to be used with export writer"); + } + if (ft instanceof IntValueFieldType) { if (reverse) { sortValues[i] = new IntValue(field, new IntDesc()); diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-sortingresponse.xml b/solr/core/src/test-files/solr/collection1/conf/schema-sortingresponse.xml index 281e698..9fb224b 100644 --- a/solr/core/src/test-files/solr/collection1/conf/schema-sortingresponse.xml +++ b/solr/core/src/test-files/solr/collection1/conf/schema-sortingresponse.xml @@ -69,6 +69,8 @@ + + @@ -78,6 +80,7 @@ + diff --git a/solr/core/src/test/org/apache/solr/handler/export/TestExportWriter.java b/solr/core/src/test/org/apache/solr/handler/export/TestExportWriter.java index 4cebb12..b37ece9 100644 --- a/solr/core/src/test/org/apache/solr/handler/export/TestExportWriter.java +++ b/solr/core/src/test/org/apache/solr/handler/export/TestExportWriter.java @@ -132,7 +132,10 @@ public class TestExportWriter extends SolrTestCaseJ4 { "datedv_m", "2017-06-16T04:00:00Z", "sortabledv_m", "this is some text one_1", "sortabledv_m", "this is some text two_1", - "sortabledv_m", "this is some text three_1")); + "sortabledv_m", "this is some text three_1", + "sortabledv_m_udvas", "this is some text one_1", + "sortabledv_m_udvas", "this is some text two_1", + "sortabledv_m_udvas", "this is some text three_1")); assertU(adoc("id","7", "floatdv","2.1", @@ -170,7 +173,8 @@ public class TestExportWriter extends SolrTestCaseJ4 { "int_is_t", "1", "int_is_t", "1", "int_is_t", "1", - "sortabledv", "this is some text_1")); + "sortabledv", "this is some text_1", + "sortabledv_udvas", "this is some text_1")); assertU(commit()); assertU(adoc("id","8", "floatdv","2.1", @@ -197,9 +201,14 @@ public class TestExportWriter extends SolrTestCaseJ4 { "int_is_p", "1", "int_is_p", "1", "sortabledv", "this is some text_2", + "sortabledv_udvas", "this is some text_2", "sortabledv_m", "this is some text one_2", "sortabledv_m", "this is some text two_2", - "sortabledv_m", "this is some text three_2")); + "sortabledv_m", "this is some text three_2", + "sortabledv_m_udvas", "this is some text one_2", + "sortabledv_m_udvas", "this is some text two_2", + "sortabledv_m_udvas", "this is some text three_2" + )); assertU(commit()); @@ -501,22 +510,31 @@ public class TestExportWriter extends SolrTestCaseJ4 { assertJsonEquals(s, "{\"responseHeader\": {\"status\": 0}, \"response\":{\"numFound\":1, \"docs\":[{\"stringdv\":\"chello \\\"world\\\"\"}]}}"); // Test sortable text fields: - s = h.query(req("q", "id:(1 OR 3 OR 8)", "qt", "/export", "fl", "sortabledv_m,sortabledv", "sort", "sortabledv asc")); + s = h.query(req("q", "id:(1 OR 3 OR 8)", "qt", "/export", "fl", "sortabledv_m_udvas,sortabledv_udvas", "sort", "sortabledv_udvas asc")); assertJsonEquals(s, "{\n" + " \"responseHeader\":{\"status\":0},\n" + " \"response\":{\n" + " \"numFound\":3,\n" + " \"docs\":[{\n" + - " \"sortabledv_m\":[\"this is some text one_1\"\n" + + " \"sortabledv_m_udvas\":[\"this is some text one_1\"\n" + " ,\"this is some text three_1\"\n" + " ,\"this is some text two_1\"]}\n" + " ,{\n" + - " \"sortabledv\":\"this is some text_1\"}\n" + + " \"sortabledv_udvas\":\"this is some text_1\"}\n" + " ,{\n" + - " \"sortabledv_m\":[\"this is some text one_2\"\n" + + " \"sortabledv_m_udvas\":[\"this is some text one_2\"\n" + " ,\"this is some text three_2\"\n" + " ,\"this is some text two_2\"],\n" + - " \"sortabledv\":\"this is some text_2\"}]}}"); + " \"sortabledv_udvas\":\"this is some text_2\"}]}}"); + + s = h.query(req("q", "id:(1 OR 3 OR 8)", "qt", "/export", "fl", "sortabledv_m", "sort", "sortabledv_udvas asc")); + assertTrue("Should have 400 status when exporting sortabledv_m, it does not have useDocValuesAsStored='true'", s.contains("\"status\":400}")); + assertTrue("Should have a cause when exporting sortabledv_m, it does not have useDocValuesAsStored='true'", s.contains("Must have useDocValuesAsStored='true' to be used with export writer")); + + s = h.query(req("q", "id:(1 OR 3 OR 8)", "qt", "/export", "fl", "sortabledv", "sort", "sortabledv_udvas asc")); + assertTrue("Should have 400 status when exporting sortabledv, it does not have useDocValuesAsStored='true'", s.contains("\"status\":400}")); + assertTrue("Should have a cause when exporting sortabledv, it does not have useDocValuesAsStored='true'", s.contains("Must have useDocValuesAsStored='true' to be used with export writer")); + } private void assertJsonEquals(String actual, String expected) {