You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by is...@apache.org on 2017/07/29 21:14:41 UTC
lucene-solr:branch_7x: SOLR-11154: Child documents' return fields now
include useDocValuesAsStored fields
Repository: lucene-solr
Updated Branches:
refs/heads/branch_7x 55b010d73 -> afe524948
SOLR-11154: Child documents' return fields now include useDocValuesAsStored fields
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/afe52494
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/afe52494
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/afe52494
Branch: refs/heads/branch_7x
Commit: afe5249483814f879e0d9cd82a6c080f0dc38065
Parents: 55b010d
Author: Ishan Chattopadhyaya <is...@apache.org>
Authored: Sun Jul 30 02:43:36 2017 +0530
Committer: Ishan Chattopadhyaya <is...@apache.org>
Committed: Sun Jul 30 02:44:30 2017 +0530
----------------------------------------------------------------------
solr/CHANGES.txt | 3 ++
.../transform/ChildDocTransformerFactory.java | 11 +++++++
.../transform/TestChildDocTransformer.java | 33 ++++++++++++++++++++
3 files changed, 47 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/afe52494/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 9f3ded5b..c387a97 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -380,6 +380,9 @@ Bug Fixes
* SOLR-11151: SolrInfoMBeanHandler.getDiff() ADD case non-functional: NPE when a bean value goes from null -> non-null.
(Steve Rowe)
+* SOLR-11154: Child documents' return fields now include useDocValuesAsStored fields (Mohammed Sheeri Shaketi Nauage via
+ Ishan Chattopadhyaya)
+
Optimizations
----------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/afe52494/solr/core/src/java/org/apache/solr/response/transform/ChildDocTransformerFactory.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/response/transform/ChildDocTransformerFactory.java b/solr/core/src/java/org/apache/solr/response/transform/ChildDocTransformerFactory.java
index 45b0efc..ff7c061 100644
--- a/solr/core/src/java/org/apache/solr/response/transform/ChildDocTransformerFactory.java
+++ b/solr/core/src/java/org/apache/solr/response/transform/ChildDocTransformerFactory.java
@@ -17,6 +17,7 @@
package org.apache.solr.response.transform;
import java.io.IOException;
+import java.util.Set;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexableField;
@@ -39,6 +40,7 @@ import org.apache.solr.search.DocList;
import org.apache.solr.search.QParser;
import org.apache.solr.search.QueryWrapperFilter;
import org.apache.solr.search.SyntaxError;
+import org.apache.solr.search.SolrDocumentFetcher;
/**
*
@@ -135,12 +137,21 @@ class ChildDocTransformer extends DocTransformer {
Query query = new ToChildBlockJoinQuery(parentQuery, parentsFilter);
DocList children = context.getSearcher().getDocList(query, childFilterQuery, new Sort(), 0, limit);
if(children.matches() > 0) {
+ SolrDocumentFetcher docFetcher = context.getSearcher().getDocFetcher();
+
+ Set<String> dvFieldsToReturn = docFetcher.getNonStoredDVs(true);
+ boolean shouldDecorateWithDVs = dvFieldsToReturn.size() > 0;
DocIterator i = children.iterator();
+
while(i.hasNext()) {
Integer childDocNum = i.next();
Document childDoc = context.getSearcher().doc(childDocNum);
SolrDocument solrChildDoc = DocsStreamer.convertLuceneDocToSolrDoc(childDoc, schema);
+ if (shouldDecorateWithDVs) {
+ docFetcher.decorateDocValueFields(solrChildDoc, childDocNum, dvFieldsToReturn);
+ }
+
// TODO: future enhancement...
// support an fl local param in the transformer, which is used to build
// a private ReturnFields instance that we use to prune unwanted field
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/afe52494/solr/core/src/test/org/apache/solr/response/transform/TestChildDocTransformer.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/response/transform/TestChildDocTransformer.java b/solr/core/src/test/org/apache/solr/response/transform/TestChildDocTransformer.java
index 2e68d78..71b77f4 100644
--- a/solr/core/src/test/org/apache/solr/response/transform/TestChildDocTransformer.java
+++ b/solr/core/src/test/org/apache/solr/response/transform/TestChildDocTransformer.java
@@ -59,6 +59,8 @@ public class TestChildDocTransformer extends SolrTestCaseJ4 {
testSubQueryXML();
testSubQueryJSON();
+
+ testChildDocNonStoredDVFields();
}
private void testChildDoctransformerXML() {
@@ -205,6 +207,36 @@ public class TestChildDocTransformer extends SolrTestCaseJ4 {
"/response/docs/[0]/_childDocuments_/[1]/id=='5'"
};
+ assertJQ(req("q", "*:*", "fq", "subject:\"parentDocument\" ",
+ "fl", "*,[child parentFilter=\"subject:parentDocument\"]"), test1);
+
+ assertJQ(req("q", "*:*", "fq", "subject:\"parentDocument\" ",
+ "fl", "subject,[child parentFilter=\"subject:parentDocument\" childFilter=\"title:foo\"]"), test2);
+
+ assertJQ(req("q", "*:*", "fq", "subject:\"parentDocument\" ",
+ "fl", "subject,[child parentFilter=\"subject:parentDocument\" childFilter=\"title:bar\" limit=2]"), test3);
+ }
+
+ private void testChildDocNonStoredDVFields() throws Exception {
+ String[] test1 = new String[] {
+ "/response/docs/[0]/_childDocuments_/[0]/intDvoDefault==42",
+ "/response/docs/[0]/_childDocuments_/[1]/intDvoDefault==42",
+ "/response/docs/[0]/_childDocuments_/[2]/intDvoDefault==42",
+ "/response/docs/[0]/_childDocuments_/[3]/intDvoDefault==42",
+ "/response/docs/[0]/_childDocuments_/[4]/intDvoDefault==42",
+ "/response/docs/[0]/_childDocuments_/[5]/intDvoDefault==42"
+ };
+
+ String[] test2 = new String[] {
+ "/response/docs/[0]/_childDocuments_/[0]/intDvoDefault==42",
+ "/response/docs/[0]/_childDocuments_/[1]/intDvoDefault==42",
+ "/response/docs/[0]/_childDocuments_/[2]/intDvoDefault==42"
+ };
+
+ String[] test3 = new String[] {
+ "/response/docs/[0]/_childDocuments_/[0]/intDvoDefault==42",
+ "/response/docs/[0]/_childDocuments_/[1]/intDvoDefault==42"
+ };
assertJQ(req("q", "*:*", "fq", "subject:\"parentDocument\" ",
"fl", "*,[child parentFilter=\"subject:parentDocument\"]"), test1);
@@ -214,6 +246,7 @@ public class TestChildDocTransformer extends SolrTestCaseJ4 {
assertJQ(req("q", "*:*", "fq", "subject:\"parentDocument\" ",
"fl", "subject,[child parentFilter=\"subject:parentDocument\" childFilter=\"title:bar\" limit=2]"), test3);
+
}
private void createSimpleIndex() {