You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by yo...@apache.org on 2013/08/13 18:15:14 UTC
svn commit: r1513577 - in /lucene/dev/branches/branch_4x: ./ dev-tools/
dev-tools/idea/solr/core/src/java/ dev-tools/idea/solr/core/src/test/
dev-tools/maven/solr/core/src/java/ dev-tools/maven/solr/core/src/test/
lucene/ lucene/analysis/ lucene/analys...
Author: yonik
Date: Tue Aug 13 16:15:12 2013
New Revision: 1513577
URL: http://svn.apache.org/r1513577
Log:
SOLR-3076: block join parent and child queries
Added:
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/join/
- copied from r1513290, lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/join/
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/join/BitSetSlice.java
- copied unchanged from r1513290, lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/join/BitSetSlice.java
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/join/BlockJoinChildQParser.java
- copied unchanged from r1513290, lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/join/BlockJoinChildQParser.java
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/join/BlockJoinChildQParserPlugin.java
- copied unchanged from r1513290, lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/join/BlockJoinChildQParserPlugin.java
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/join/BlockJoinParentQParser.java
- copied unchanged from r1513290, lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/join/BlockJoinParentQParser.java
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/join/BlockJoinParentQParserPlugin.java
- copied unchanged from r1513290, lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/join/BlockJoinParentQParserPlugin.java
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/join/IgnoreAcceptDocsQuery.java
- copied unchanged from r1513290, lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/join/IgnoreAcceptDocsQuery.java
lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/join/
- copied from r1513290, lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/join/
lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/join/BJQParserTest.java
- copied unchanged from r1513290, lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/join/BJQParserTest.java
lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/update/AddBlockUpdateTest.java
- copied unchanged from r1513290, lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/AddBlockUpdateTest.java
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/dev-tools/ (props changed)
lucene/dev/branches/branch_4x/dev-tools/idea/solr/core/src/java/solr-core.iml
lucene/dev/branches/branch_4x/dev-tools/idea/solr/core/src/test/solr-core-tests.iml
lucene/dev/branches/branch_4x/dev-tools/maven/solr/core/src/java/pom.xml.template
lucene/dev/branches/branch_4x/dev-tools/maven/solr/core/src/test/pom.xml.template
lucene/dev/branches/branch_4x/lucene/ (props changed)
lucene/dev/branches/branch_4x/lucene/BUILD.txt (props changed)
lucene/dev/branches/branch_4x/lucene/CHANGES.txt (props changed)
lucene/dev/branches/branch_4x/lucene/JRE_VERSION_MIGRATION.txt (props changed)
lucene/dev/branches/branch_4x/lucene/LICENSE.txt (props changed)
lucene/dev/branches/branch_4x/lucene/MIGRATE.txt (props changed)
lucene/dev/branches/branch_4x/lucene/NOTICE.txt (props changed)
lucene/dev/branches/branch_4x/lucene/README.txt (props changed)
lucene/dev/branches/branch_4x/lucene/SYSTEM_REQUIREMENTS.txt (props changed)
lucene/dev/branches/branch_4x/lucene/analysis/ (props changed)
lucene/dev/branches/branch_4x/lucene/analysis/icu/src/java/org/apache/lucene/collation/ICUCollationKeyFilterFactory.java (props changed)
lucene/dev/branches/branch_4x/lucene/backwards/ (props changed)
lucene/dev/branches/branch_4x/lucene/benchmark/ (props changed)
lucene/dev/branches/branch_4x/lucene/build.xml (props changed)
lucene/dev/branches/branch_4x/lucene/classification/ (props changed)
lucene/dev/branches/branch_4x/lucene/classification/build.xml (props changed)
lucene/dev/branches/branch_4x/lucene/classification/ivy.xml (props changed)
lucene/dev/branches/branch_4x/lucene/classification/src/ (props changed)
lucene/dev/branches/branch_4x/lucene/codecs/ (props changed)
lucene/dev/branches/branch_4x/lucene/common-build.xml (props changed)
lucene/dev/branches/branch_4x/lucene/core/ (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/index.40.cfs.zip (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/index.40.nocfs.zip (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/index.40.optimized.cfs.zip (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/index.40.optimized.nocfs.zip (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestSort.java (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestSortDocValues.java (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestSortRandom.java (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestTopFieldCollector.java (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestTotalHitCountCollector.java (props changed)
lucene/dev/branches/branch_4x/lucene/demo/ (props changed)
lucene/dev/branches/branch_4x/lucene/facet/ (props changed)
lucene/dev/branches/branch_4x/lucene/grouping/ (props changed)
lucene/dev/branches/branch_4x/lucene/highlighter/ (props changed)
lucene/dev/branches/branch_4x/lucene/ivy-settings.xml (props changed)
lucene/dev/branches/branch_4x/lucene/join/ (props changed)
lucene/dev/branches/branch_4x/lucene/licenses/ (props changed)
lucene/dev/branches/branch_4x/lucene/memory/ (props changed)
lucene/dev/branches/branch_4x/lucene/misc/ (props changed)
lucene/dev/branches/branch_4x/lucene/module-build.xml (contents, props changed)
lucene/dev/branches/branch_4x/lucene/queries/ (props changed)
lucene/dev/branches/branch_4x/lucene/queries/src/test/org/apache/lucene/queries/function/TestFunctionQuerySort.java (props changed)
lucene/dev/branches/branch_4x/lucene/queryparser/ (props changed)
lucene/dev/branches/branch_4x/lucene/replicator/ (props changed)
lucene/dev/branches/branch_4x/lucene/sandbox/ (props changed)
lucene/dev/branches/branch_4x/lucene/site/ (props changed)
lucene/dev/branches/branch_4x/lucene/spatial/ (props changed)
lucene/dev/branches/branch_4x/lucene/suggest/ (props changed)
lucene/dev/branches/branch_4x/lucene/test-framework/ (props changed)
lucene/dev/branches/branch_4x/lucene/tools/ (props changed)
lucene/dev/branches/branch_4x/solr/ (props changed)
lucene/dev/branches/branch_4x/solr/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_4x/solr/LICENSE.txt (props changed)
lucene/dev/branches/branch_4x/solr/NOTICE.txt (props changed)
lucene/dev/branches/branch_4x/solr/README.txt (props changed)
lucene/dev/branches/branch_4x/solr/SYSTEM_REQUIREMENTS.txt (props changed)
lucene/dev/branches/branch_4x/solr/build.xml (props changed)
lucene/dev/branches/branch_4x/solr/cloud-dev/ (props changed)
lucene/dev/branches/branch_4x/solr/common-build.xml (contents, props changed)
lucene/dev/branches/branch_4x/solr/contrib/ (props changed)
lucene/dev/branches/branch_4x/solr/core/ (props changed)
lucene/dev/branches/branch_4x/solr/core/ivy.xml
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/QParserPlugin.java
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/schema.xml
lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/schema15.xml
lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/solrconfig.xml
lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestConfig.java (props changed)
lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java
lucene/dev/branches/branch_4x/solr/example/ (props changed)
lucene/dev/branches/branch_4x/solr/licenses/ (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpclient-LICENSE-ASL.txt (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpclient-NOTICE.txt (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpcore-LICENSE-ASL.txt (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpcore-NOTICE.txt (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpmime-LICENSE-ASL.txt (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpmime-NOTICE.txt (props changed)
lucene/dev/branches/branch_4x/solr/scripts/ (props changed)
lucene/dev/branches/branch_4x/solr/site/ (props changed)
lucene/dev/branches/branch_4x/solr/solrj/ (props changed)
lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java
lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java
lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
lucene/dev/branches/branch_4x/solr/test-framework/ (props changed)
lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
lucene/dev/branches/branch_4x/solr/webapp/ (props changed)
Modified: lucene/dev/branches/branch_4x/dev-tools/idea/solr/core/src/java/solr-core.iml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/dev-tools/idea/solr/core/src/java/solr-core.iml?rev=1513577&r1=1513576&r2=1513577&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/dev-tools/idea/solr/core/src/java/solr-core.iml (original)
+++ lucene/dev/branches/branch_4x/dev-tools/idea/solr/core/src/java/solr-core.iml Tue Aug 13 16:15:12 2013
@@ -25,5 +25,6 @@
<orderEntry type="module" module-name="analysis-common" />
<orderEntry type="module" module-name="lucene-core" />
<orderEntry type="module" module-name="queryparser" />
+ <orderEntry type="module" module-name="join" />
</component>
</module>
Modified: lucene/dev/branches/branch_4x/dev-tools/idea/solr/core/src/test/solr-core-tests.iml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/dev-tools/idea/solr/core/src/test/solr-core-tests.iml?rev=1513577&r1=1513576&r2=1513577&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/dev-tools/idea/solr/core/src/test/solr-core-tests.iml (original)
+++ lucene/dev/branches/branch_4x/dev-tools/idea/solr/core/src/test/solr-core-tests.iml Tue Aug 13 16:15:12 2013
@@ -27,5 +27,6 @@
<orderEntry type="module" scope="TEST" module-name="suggest" />
<orderEntry type="module" scope="TEST" module-name="spatial" />
<orderEntry type="module" scope="TEST" module-name="misc" />
+ <orderEntry type="module" scope="TEST" module-name="join" />
</component>
</module>
Modified: lucene/dev/branches/branch_4x/dev-tools/maven/solr/core/src/java/pom.xml.template
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/dev-tools/maven/solr/core/src/java/pom.xml.template?rev=1513577&r1=1513576&r2=1513577&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/dev-tools/maven/solr/core/src/java/pom.xml.template (original)
+++ lucene/dev/branches/branch_4x/dev-tools/maven/solr/core/src/java/pom.xml.template Tue Aug 13 16:15:12 2013
@@ -95,6 +95,11 @@
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-join</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<version>${project.version}</version>
<exclusions>
Modified: lucene/dev/branches/branch_4x/dev-tools/maven/solr/core/src/test/pom.xml.template
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/dev-tools/maven/solr/core/src/test/pom.xml.template?rev=1513577&r1=1513576&r2=1513577&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/dev-tools/maven/solr/core/src/test/pom.xml.template (original)
+++ lucene/dev/branches/branch_4x/dev-tools/maven/solr/core/src/test/pom.xml.template Tue Aug 13 16:15:12 2013
@@ -198,6 +198,12 @@
<artifactId>jetty-util</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ <version>1.6.1</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<sourceDirectory/>
Modified: lucene/dev/branches/branch_4x/lucene/module-build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/module-build.xml?rev=1513577&r1=1513576&r2=1513577&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/module-build.xml (original)
+++ lucene/dev/branches/branch_4x/lucene/module-build.xml Tue Aug 13 16:15:12 2013
@@ -132,6 +132,17 @@
</ant>
<property name="queryparser-javadocs.uptodate" value="true"/>
</target>
+
+ <property name="join.jar" value="${common.dir}/build/join/lucene-join-${version}.jar"/>
+ <target name="check-join-uptodate" unless="join.uptodate">
+ <module-uptodate name="join" jarfile="${join.jar}" property="join.uptodate"/>
+ </target>
+ <target name="jar-join" unless="join.uptodate" depends="check-join-uptodate">
+ <ant dir="${common.dir}/join" target="jar-core" inheritAll="false">
+ <propertyset refid="uptodate.and.compiled.properties"/>
+ </ant>
+ <property name="join.uptodate" value="true"/>
+ </target>
<property name="analyzers-common.jar" value="${common.dir}/build/analysis/common/lucene-analyzers-common-${version}.jar"/>
<target name="check-analyzers-common-uptodate" unless="analyzers-common.uptodate">
Modified: lucene/dev/branches/branch_4x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/CHANGES.txt?rev=1513577&r1=1513576&r2=1513577&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/solr/CHANGES.txt Tue Aug 13 16:15:12 2013
@@ -156,6 +156,7 @@ Upgrading from Solr 4.3.0
* LUCENE-5063: ByteField and ShortField have been deprecated and will be removed
in 5.0. If you are still using these field types, you should migrate your
fields to TrieIntField.
+
Detailed Change List
----------------------
@@ -236,6 +237,16 @@ New Features
* SOLR-4943: Add a new system wide info admin handler that exposes the system info
that could previously only be retrieved using a SolrCore. (Mark Miller)
+* SOLR-3076: Block joins. Documents and their sub-documents must be indexed
+ as a block.
+ {!parent which=<allParents>}<someChildren> takes in a query that matches child
+ documents and results in matches on their parents.
+ {!child of=<allParents>}<someParents> takes in a query that matches some parent
+ documents and results in matches on their children.
+ (Mikhail Khludnev, Vadim Kirilchuk, Alan Woodward, Tom Burton-West, Mike McCandless,
+ hossman, yonik)
+
+
Bug Fixes
----------------------
Modified: lucene/dev/branches/branch_4x/solr/common-build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/common-build.xml?rev=1513577&r1=1513576&r2=1513577&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/common-build.xml (original)
+++ lucene/dev/branches/branch_4x/solr/common-build.xml Tue Aug 13 16:15:12 2013
@@ -82,6 +82,7 @@
<pathelement location="${grouping.jar}"/>
<pathelement location="${queries.jar}"/>
<pathelement location="${queryparser.jar}"/>
+ <pathelement location="${join.jar}"/>
</path>
<path id="solr.base.classpath">
@@ -141,7 +142,7 @@
<target name="prep-lucene-jars"
depends="jar-lucene-core, jar-analyzers-phonetic, jar-analyzers-kuromoji, jar-codecs, jar-suggest, jar-highlighter, jar-memory,
- jar-misc, jar-spatial, jar-grouping, jar-queries, jar-queryparser">
+ jar-misc, jar-spatial, jar-grouping, jar-queries, jar-queryparser, jar-join">
<property name="solr.deps.compiled" value="true"/>
</target>
Modified: lucene/dev/branches/branch_4x/solr/core/ivy.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/ivy.xml?rev=1513577&r1=1513576&r2=1513577&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/ivy.xml (original)
+++ lucene/dev/branches/branch_4x/solr/core/ivy.xml Tue Aug 13 16:15:12 2013
@@ -41,6 +41,7 @@
<dependency org="org.restlet.jee" name="org.restlet" rev="2.1.1" conf="compile->*"/>
<dependency org="org.restlet.jee" name="org.restlet.ext.servlet" rev="2.1.1" conf="compile->*"/>
<dependency org="joda-time" name="joda-time" rev="2.2" conf="compile->*"/>
+ <dependency org="dom4j" name="dom4j" rev="1.6.1" transitive="false"/>
<dependency org="javax.servlet" name="javax.servlet-api" rev="3.0.1" conf="test->*"/>
<dependency org="org.easymock" name="easymock" rev="3.0" conf="test->*"/>
Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java?rev=1513577&r1=1513576&r2=1513577&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/loader/XMLLoader.java Tue Aug 13 16:15:12 2013
@@ -16,50 +16,51 @@ package org.apache.solr.handler.loader;
* limitations under the License.
*/
-import org.apache.solr.common.params.ModifiableSolrParams;
-import org.apache.solr.update.processor.UpdateRequestProcessor;
-import org.apache.solr.update.AddUpdateCommand;
-import org.apache.solr.update.CommitUpdateCommand;
-import org.apache.solr.update.RollbackUpdateCommand;
-import org.apache.solr.update.DeleteUpdateCommand;
-import org.apache.solr.util.xslt.TransformerProvider;
-import org.apache.solr.request.SolrQueryRequest;
-import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.common.util.ContentStream;
-import org.apache.solr.common.util.ContentStreamBase;
-import org.apache.solr.common.util.StrUtils;
-import org.apache.solr.common.util.XMLErrorLogger;
+import com.google.common.collect.Lists;
+import org.apache.commons.io.IOUtils;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.params.UpdateParams;
+import org.apache.solr.common.util.ContentStream;
+import org.apache.solr.common.util.ContentStreamBase;
+import org.apache.solr.common.util.StrUtils;
+import org.apache.solr.common.util.XMLErrorLogger;
import org.apache.solr.core.SolrConfig;
import org.apache.solr.handler.RequestHandlerUtils;
import org.apache.solr.handler.UpdateRequestHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.update.AddUpdateCommand;
+import org.apache.solr.update.CommitUpdateCommand;
+import org.apache.solr.update.DeleteUpdateCommand;
+import org.apache.solr.update.RollbackUpdateCommand;
+import org.apache.solr.update.processor.UpdateRequestProcessor;
import org.apache.solr.util.EmptyEntityResolver;
-import org.apache.commons.io.IOUtils;
+import org.apache.solr.util.xslt.TransformerProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamException;
+import javax.xml.parsers.SAXParserFactory;
import javax.xml.stream.FactoryConfigurationError;
-import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;
-import javax.xml.parsers.SAXParserFactory;
-
import java.io.ByteArrayInputStream;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -381,6 +382,7 @@ public class XMLLoader extends ContentSt
float boost = 1.0f;
boolean isNull = false;
String update = null;
+ Collection<SolrInputDocument> subDocs = null;
Map<String, Map<String, Object>> updateMap = null;
boolean complete = false;
while (!complete) {
@@ -395,9 +397,14 @@ public class XMLLoader extends ContentSt
case XMLStreamConstants.END_ELEMENT:
if ("doc".equals(parser.getLocalName())) {
+ if (subDocs != null && !subDocs.isEmpty()) {
+ doc.addChildDocuments(subDocs);
+ subDocs = null;
+ }
complete = true;
break;
} else if ("field".equals(parser.getLocalName())) {
+ // should I warn in some text has been found too
Object v = isNull ? null : text.toString();
if (update != null) {
if (updateMap == null) updateMap = new HashMap<String, Map<String, Object>>();
@@ -425,34 +432,43 @@ public class XMLLoader extends ContentSt
}
doc.addField(name, v, boost);
boost = 1.0f;
+ // field is over
+ name = null;
}
break;
case XMLStreamConstants.START_ELEMENT:
text.setLength(0);
String localName = parser.getLocalName();
- if (!"field".equals(localName)) {
- log.warn("unexpected XML tag doc/" + localName);
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
- "unexpected XML tag doc/" + localName);
+ if ("doc".equals(localName)) {
+ if (subDocs == null)
+ subDocs = Lists.newArrayList();
+ subDocs.add(readDoc(parser));
}
- boost = 1.0f;
- update = null;
- isNull = false;
- String attrVal = "";
- for (int i = 0; i < parser.getAttributeCount(); i++) {
- attrName = parser.getAttributeLocalName(i);
- attrVal = parser.getAttributeValue(i);
- if ("name".equals(attrName)) {
- name = attrVal;
- } else if ("boost".equals(attrName)) {
- boost = Float.parseFloat(attrVal);
- } else if ("null".equals(attrName)) {
- isNull = StrUtils.parseBoolean(attrVal);
- } else if ("update".equals(attrName)) {
- update = attrVal;
- } else {
- log.warn("Unknown attribute doc/field/@" + attrName);
+ else {
+ if (!"field".equals(localName)) {
+ log.warn("unexpected XML tag doc/" + localName);
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
+ "unexpected XML tag doc/" + localName);
+ }
+ boost = 1.0f;
+ update = null;
+ isNull = false;
+ String attrVal = "";
+ for (int i = 0; i < parser.getAttributeCount(); i++) {
+ attrName = parser.getAttributeLocalName(i);
+ attrVal = parser.getAttributeValue(i);
+ if ("name".equals(attrName)) {
+ name = attrVal;
+ } else if ("boost".equals(attrName)) {
+ boost = Float.parseFloat(attrVal);
+ } else if ("null".equals(attrName)) {
+ isNull = StrUtils.parseBoolean(attrVal);
+ } else if ("update".equals(attrName)) {
+ update = attrVal;
+ } else {
+ log.warn("Unknown attribute doc/field/@" + attrName);
+ }
}
}
break;
Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/QParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/QParserPlugin.java?rev=1513577&r1=1513576&r2=1513577&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/QParserPlugin.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/QParserPlugin.java Tue Aug 13 16:15:12 2013
@@ -20,6 +20,8 @@ import org.apache.solr.common.params.Sol
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.SolrInfoMBean;
import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.search.join.BlockJoinChildQParserPlugin;
+import org.apache.solr.search.join.BlockJoinParentQParserPlugin;
import org.apache.solr.util.plugin.NamedListInitializedPlugin;
import java.net.URL;
@@ -47,7 +49,9 @@ public abstract class QParserPlugin impl
JoinQParserPlugin.NAME, JoinQParserPlugin.class,
SurroundQParserPlugin.NAME, SurroundQParserPlugin.class,
SwitchQParserPlugin.NAME, SwitchQParserPlugin.class,
- MaxScoreQParserPlugin.NAME, MaxScoreQParserPlugin.class
+ MaxScoreQParserPlugin.NAME, MaxScoreQParserPlugin.class,
+ BlockJoinParentQParserPlugin.NAME, BlockJoinParentQParserPlugin.class,
+ BlockJoinChildQParserPlugin.NAME, BlockJoinChildQParserPlugin.class
};
/** return a {@link QParser} */
Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java?rev=1513577&r1=1513576&r2=1513577&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java Tue Aug 13 16:15:12 2013
@@ -27,10 +27,15 @@ import org.apache.solr.request.SolrQuery
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.SchemaField;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
/**
*
*/
-public class AddUpdateCommand extends UpdateCommand {
+public class AddUpdateCommand extends UpdateCommand implements Iterable<Document> {
// optional id in "internal" indexed form... if it is needed and not supplied,
// it will be obtained from the doc.
private BytesRef indexedId;
@@ -143,8 +148,64 @@ public class AddUpdateCommand extends Up
}
return id;
}
-
- @Override
+
+ public boolean isBlock() {
+ return solrDoc.hasChildDocuments();
+ }
+
+ @Override
+ public Iterator<Document> iterator() {
+ return new Iterator<Document>() {
+ Iterator<SolrInputDocument> iter;
+
+ {
+ List<SolrInputDocument> all = flatten(solrDoc);
+
+ SchemaField uniq = req.getSchema().getUniqueKeyField();
+ String idField = getHashableId();
+
+ for (SolrInputDocument sdoc : all) {
+ sdoc.setField("_root_", idField); // should this be a string or the same type as the ID?
+ // TODO: if possible concurrent modification exception (if SolrInputDocument not cloned and is being forwarded to replicas)
+ // then we could add this field to the generated lucene document instead.
+ }
+
+ iter = all.iterator();
+ }
+
+ @Override
+ public boolean hasNext() {
+ return iter.hasNext();
+ }
+
+ @Override
+ public Document next() {
+ return DocumentBuilder.toDocument(iter.next(), req.getSchema());
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ private List<SolrInputDocument> flatten(SolrInputDocument root) {
+ List<SolrInputDocument> unwrappedDocs = new ArrayList<SolrInputDocument>();
+ recUnwrapp(unwrappedDocs, root);
+ Collections.reverse(unwrappedDocs);
+ return unwrappedDocs;
+ }
+
+ private void recUnwrapp(List<SolrInputDocument> unwrappedDocs, SolrInputDocument currentDoc) {
+ unwrappedDocs.add(currentDoc);
+ for (SolrInputDocument child : currentDoc.getChildDocuments()) {
+ recUnwrapp(unwrappedDocs, child);
+ }
+ }
+
+
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder(super.toString());
sb.append(",id=").append(getPrintableId());
@@ -153,4 +214,6 @@ public class AddUpdateCommand extends Up
sb.append('}');
return sb.toString();
}
- }
+
+
+}
Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java?rev=1513577&r1=1513576&r2=1513577&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java Tue Aug 13 16:15:12 2013
@@ -20,16 +20,6 @@
package org.apache.solr.update;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.atomic.AtomicLong;
-
import org.apache.lucene.document.Document;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
@@ -56,12 +46,22 @@ import org.apache.solr.schema.IndexSchem
import org.apache.solr.schema.SchemaField;
import org.apache.solr.search.FunctionRangeQuery;
import org.apache.solr.search.QParser;
-import org.apache.solr.search.SyntaxError;
import org.apache.solr.search.QueryUtils;
import org.apache.solr.search.SolrIndexSearcher;
+import org.apache.solr.search.SyntaxError;
import org.apache.solr.search.function.ValueSourceRangeFilter;
import org.apache.solr.util.RefCounted;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
/**
* <code>DirectUpdateHandler2</code> implements an UpdateHandler where documents are added
* directly to the main Lucene index as opposed to adding to a separate smaller index.
@@ -199,19 +199,23 @@ public class DirectUpdateHandler2 extend
// normal update
Term updateTerm;
- Term idTerm = new Term(idField.getName(), cmd.getIndexedId());
+ Term idTerm = new Term(cmd.isBlock() ? "_root_" : idField.getName(), cmd.getIndexedId());
boolean del = false;
if (cmd.updateTerm == null) {
updateTerm = idTerm;
} else {
+ // this is only used by the dedup update processor
del = true;
updateTerm = cmd.updateTerm;
}
-
- Document luceneDocument = cmd.getLuceneDocument();
- // SolrCore.verbose("updateDocument",updateTerm,luceneDocument,writer);
- writer.updateDocument(updateTerm, luceneDocument,
- schema.getAnalyzer());
+
+ if (cmd.isBlock()) {
+ writer.updateDocuments(updateTerm, cmd, schema.getAnalyzer());
+ } else {
+ Document luceneDocument = cmd.getLuceneDocument();
+ // SolrCore.verbose("updateDocument",updateTerm,luceneDocument,writer);
+ writer.updateDocument(updateTerm, luceneDocument, schema.getAnalyzer());
+ }
// SolrCore.verbose("updateDocument",updateTerm,"DONE");
if (del) { // ensure id remains unique
@@ -234,7 +238,12 @@ public class DirectUpdateHandler2 extend
} else {
// allow duplicates
- writer.addDocument(cmd.getLuceneDocument(), schema.getAnalyzer());
+ if (cmd.isBlock()) {
+ writer.addDocuments(cmd, schema.getAnalyzer());
+ } else {
+ writer.addDocument(cmd.getLuceneDocument(), schema.getAnalyzer());
+ }
+
if (ulog != null) ulog.add(cmd);
}
Modified: lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/schema.xml?rev=1513577&r1=1513576&r2=1513577&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/schema.xml (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/schema.xml Tue Aug 13 16:15:12 2013
@@ -443,6 +443,8 @@
<fields>
<field name="id" type="int" indexed="true" stored="true" multiValued="false" required="false"/>
+ <field name="_root_" type="int" indexed="true" stored="true" multiValued="false" required="false"/>
+
<field name="signatureField" type="string" indexed="true" stored="false"/>
<field name="uuid" type="uuid" stored="true" />
<field name="name" type="nametext" indexed="true" stored="true"/>
Modified: lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/schema15.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/schema15.xml?rev=1513577&r1=1513576&r2=1513577&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/schema15.xml (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/schema15.xml Tue Aug 13 16:15:12 2013
@@ -527,13 +527,15 @@
<field name="uniq3" type="string" indexed="true" stored="true"/>
<field name="nouniq" type="string" indexed="true" stored="true" multiValued="true"/>
- <!-- for versioning -->
- <field name="_version_" type="long" indexed="true" stored="true"/>
-
-
+
<field name="copyfield_source" type="string" indexed="true" stored="true" multiValued="true"/>
+ <!-- for versioning -->
+ <field name="_version_" type="long" indexed="true" stored="true"/>
+ <!-- points to the root document of a block of nested documents -->
+ <field name="_root_" type="string" indexed="true" stored="true"/>
+
<dynamicField name="*_coordinate" type="tdouble" indexed="true" stored="false"/>
@@ -564,6 +566,7 @@
<dynamicField name="*_l" type="long" indexed="true" stored="true"/>
<dynamicField name="*_t" type="text" indexed="true" stored="true"/>
<dynamicField name="*_tt" type="text" indexed="true" stored="true"/>
+ <dynamicField name="*_ws" type="nametext" indexed="true" stored="true"/>
<dynamicField name="*_b" type="boolean" indexed="true" stored="true"/>
<dynamicField name="*_f" type="float" indexed="true" stored="true"/>
<dynamicField name="*_d" type="double" indexed="true" stored="true"/>
Modified: lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/solrconfig.xml?rev=1513577&r1=1513576&r2=1513577&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/solrconfig.xml (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/solrconfig.xml Tue Aug 13 16:15:12 2013
@@ -120,6 +120,12 @@
initialSize="512"
autowarmCount="0"/>
+ <cache name="perSegFilter"
+ class="solr.search.LRUCache"
+ size="10"
+ initialSize="0"
+ autowarmCount="10" />
+
<!-- If true, stored fields that are not requested will be loaded lazily.
-->
<enableLazyFieldLoading>true</enableLazyFieldLoading>
@@ -553,3 +559,4 @@
</updateRequestProcessorChain>
</config>
+
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java?rev=1513577&r1=1513576&r2=1513577&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java Tue Aug 13 16:15:12 2013
@@ -121,6 +121,8 @@ public class FullSolrCloudDistribCmdsTes
results = query(cloudClient);
assertEquals(2, results.getResults().getNumFound());
+ docId = testIndexQueryDeleteHierarchical(docId);
+
testIndexingWithSuss();
// TODO: testOptimisticUpdate(results);
@@ -235,6 +237,75 @@ public class FullSolrCloudDistribCmdsTes
assertEquals(0, query(cloudClient).getResults().getNumFound());
}
+ private long testIndexQueryDeleteHierarchical(long docId) throws Exception {
+ //index
+ int topDocsNum = atLeast(10);
+ int childsNum = atLeast(10);
+ for (int i = 0; i < topDocsNum; ++i) {
+ UpdateRequest uReq = new UpdateRequest();
+ SolrInputDocument topDocument = new SolrInputDocument();
+ topDocument.addField("id", docId++);
+ topDocument.addField("type_s", "parent");
+ topDocument.addField(i + "parent_f1_s", "v1");
+ topDocument.addField(i + "parent_f2_s", "v2");
+
+
+ for (int index = 0; index < childsNum; ++index) {
+ docId = addChildren("child", topDocument, index, false, docId);
+ }
+
+ uReq.add(topDocument);
+ uReq.process(cloudClient);
+ uReq.process(controlClient);
+ }
+
+ commit();
+ checkShardConsistency();
+ assertDocCounts(VERBOSE);
+
+ //query
+ // parents
+ SolrQuery query = new SolrQuery("type_s:parent");
+ QueryResponse results = cloudClient.query(query);
+ assertEquals(topDocsNum, results.getResults().getNumFound());
+
+ //childs
+ query = new SolrQuery("type_s:child");
+ results = cloudClient.query(query);
+ assertEquals(topDocsNum * childsNum, results.getResults().getNumFound());
+
+ //grandchilds
+ query = new SolrQuery("type_s:grand");
+ results = cloudClient.query(query);
+ //each topDoc has t childs where each child has x = 0 + 2 + 4 + ..(t-1)*2 grands
+ //x = 2 * (1 + 2 + 3 +.. (t-1)) => arithmetic summ of t-1
+ //x = 2 * ((t-1) * t / 2) = t * (t - 1)
+ assertEquals(topDocsNum * childsNum * (childsNum - 1), results.getResults().getNumFound());
+
+ //delete
+ del("*:*");
+ commit();
+
+ return docId;
+ }
+
+ private long addChildren(String prefix, SolrInputDocument topDocument, int childIndex, boolean lastLevel, long docId) {
+ SolrInputDocument childDocument = new SolrInputDocument();
+ childDocument.addField("id", docId++);
+ childDocument.addField("type_s", prefix);
+ for (int index = 0; index < childIndex; ++index) {
+ childDocument.addField(childIndex + prefix + index + "_s", childIndex + "value"+ index);
+ }
+
+ if (!lastLevel) {
+ for (int i = 0; i < childIndex * 2; ++i) {
+ docId = addChildren("grand", childDocument, i, true, docId);
+ }
+ }
+ topDocument.addChildDocument(childDocument);
+ return docId;
+ }
+
private void testIndexingWithSuss() throws Exception {
ConcurrentUpdateSolrServer suss = new ConcurrentUpdateSolrServer(
((HttpSolrServer) clients.get(0)).getBaseURL(), 3, 1);
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java?rev=1513577&r1=1513576&r2=1513577&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java Tue Aug 13 16:15:12 2013
@@ -298,6 +298,13 @@ public class QueryEqualityTest extends S
}
}
+ public void testBlockJoin() throws Exception {
+ assertQueryEquals("parent", "{!parent which=foo_s:parent}dude",
+ "{!parent which=foo_s:parent}dude");
+ assertQueryEquals("child", "{!child of=foo_s:parent}dude",
+ "{!child of=foo_s:parent}dude");
+ }
+
public void testQuerySurround() throws Exception {
assertQueryEquals("surround", "{!surround}and(apache,solr)",
"and(apache,solr)", "apache AND solr");
Modified: lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java?rev=1513577&r1=1513576&r2=1513577&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java (original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java Tue Aug 13 16:15:12 2013
@@ -133,6 +133,11 @@ public class ClientUtils
}
}
}
+
+ for (SolrInputDocument childDocument : doc.getChildDocuments()) {
+ writeXML(childDocument, writer);
+ }
+
writer.write("</doc>");
}
Modified: lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java?rev=1513577&r1=1513576&r2=1513577&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java (original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java Tue Aug 13 16:15:12 2013
@@ -18,9 +18,12 @@
package org.apache.solr.common;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -36,13 +39,16 @@ public class SolrInputDocument implement
{
private final Map<String,SolrInputField> _fields;
private float _documentBoost = 1.0f;
-
+ private List<SolrInputDocument> _childDocuments;
+
public SolrInputDocument() {
_fields = new LinkedHashMap<String,SolrInputField>();
+ _childDocuments = new ArrayList<SolrInputDocument>();
}
public SolrInputDocument(Map<String,SolrInputField> fields) {
_fields = fields;
+ _childDocuments = new ArrayList<SolrInputDocument>();
}
/**
@@ -52,7 +58,10 @@ public class SolrInputDocument implement
public void clear()
{
if( _fields != null ) {
- _fields.clear();
+ _fields.clear();
+ }
+ if (_childDocuments != null) {
+ _childDocuments.clear();
}
}
@@ -189,7 +198,7 @@ public class SolrInputDocument implement
@Override
public String toString()
{
- return "SolrInputDocument" + _fields.values();
+ return "SolrInputDocument(fields: " + _fields.values() + ", childs: " + _childDocuments + ")";
}
public SolrInputDocument deepCopy() {
@@ -199,6 +208,12 @@ public class SolrInputDocument implement
clone._fields.put(fieldEntry.getKey(), fieldEntry.getValue().deepCopy());
}
clone._documentBoost = _documentBoost;
+
+ clone._childDocuments = new ArrayList<SolrInputDocument>(_childDocuments.size());
+ for (SolrInputDocument child : _childDocuments) {
+ clone._childDocuments.add(child.deepCopy());
+ }
+
return clone;
}
@@ -260,4 +275,23 @@ public class SolrInputDocument implement
public Collection<SolrInputField> values() {
return _fields.values();
}
+
+ public void addChildDocument(SolrInputDocument child) {
+ _childDocuments.add(child);
+ }
+
+ public void addChildDocuments(Collection<SolrInputDocument> childs) {
+ for (SolrInputDocument child : childs) {
+ addChildDocument(child);
+ }
+ }
+
+ public List<SolrInputDocument> getChildDocuments() {
+ return _childDocuments;
+ }
+
+ public boolean hasChildDocuments() {
+ boolean isEmpty = (_childDocuments == null || _childDocuments.isEmpty());
+ return !isEmpty;
+ }
}
Modified: lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java?rev=1513577&r1=1513576&r2=1513577&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java (original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java Tue Aug 13 16:15:12 2013
@@ -62,6 +62,7 @@ public class JavaBinCodec {
END = 15,
SOLRINPUTDOC = 16,
+ SOLRINPUTDOC_CHILDS = 17,
// types that combine tag + length (or other info) in a single byte
TAG_AND_LEN = (byte) (1 << 5),
@@ -358,6 +359,8 @@ public class JavaBinCodec {
public SolrInputDocument readSolrInputDocument(DataInputInputStream dis) throws IOException {
int sz = readVInt(dis);
+ dis.readByte(); // skip childDocuments tag
+ int childsSize = readVInt(dis);
float docBoost = (Float)readVal(dis);
SolrInputDocument sdoc = new SolrInputDocument();
sdoc.setDocumentBoost(docBoost);
@@ -374,11 +377,17 @@ public class JavaBinCodec {
Object fieldVal = readVal(dis);
sdoc.setField(fieldName, fieldVal, boost);
}
+ for (int i = 0; i < childsSize; i++) {
+ dis.readByte(); // skip solrinputdoc tag
+ SolrInputDocument child = readSolrInputDocument(dis);
+ sdoc.addChildDocument(child);
+ }
return sdoc;
}
public void writeSolrInputDocument(SolrInputDocument sdoc) throws IOException {
writeTag(SOLRINPUTDOC, sdoc.size());
+ writeTag(SOLRINPUTDOC_CHILDS, sdoc.getChildDocuments().size());
writeFloat(sdoc.getDocumentBoost());
for (SolrInputField inputField : sdoc.values()) {
if (inputField.getBoost() != 1.0f) {
@@ -387,6 +396,9 @@ public class JavaBinCodec {
writeExternString(inputField.getName());
writeVal(inputField.getValue());
}
+ for (SolrInputDocument child : sdoc.getChildDocuments()) {
+ writeSolrInputDocument(child);
+ }
}
Modified: lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java?rev=1513577&r1=1513576&r2=1513577&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java (original)
+++ lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java Tue Aug 13 16:15:12 2013
@@ -72,6 +72,7 @@ import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
@@ -969,6 +970,10 @@ public abstract class SolrTestCaseJ4 ext
return sd;
}
+ public static List<SolrInputDocument> sdocs(SolrInputDocument... docs) {
+ return Arrays.asList(docs);
+ }
+
/** Converts "test JSON" and returns standard JSON.
* Currently this only consists of changing unescaped single quotes to double quotes,
* and escaped single quotes to single quotes.
@@ -1527,7 +1532,7 @@ public abstract class SolrTestCaseJ4 ext
}
/** Return a Map from field value to a list of document ids */
- Map<Comparable, List<Comparable>> invertField(Map<Comparable, Doc> model, String field) {
+ public Map<Comparable, List<Comparable>> invertField(Map<Comparable, Doc> model, String field) {
Map<Comparable, List<Comparable>> value_to_id = new HashMap<Comparable, List<Comparable>>();
// invert field