mirror of https://github.com/apache/lucene.git
SOLR-5175: keep child order in block index
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1520042 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d46bb05fe0
commit
7e7cf0961f
|
@ -194,15 +194,14 @@ public class AddUpdateCommand extends UpdateCommand implements Iterable<IndexDoc
|
|||
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);
|
||||
}
|
||||
unwrappedDocs.add(currentDoc);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,13 +19,9 @@ package org.apache.solr.search.join;
|
|||
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.search.QParser;
|
||||
import org.apache.solr.search.SolrCache;
|
||||
import org.apache.solr.search.SyntaxError;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -111,6 +107,7 @@ public class BJQParserTest extends SolrTestCaseJ4 {
|
|||
// add grandchildren after children
|
||||
for (ListIterator<String[]> iter = block.listIterator(); iter.hasNext();) {
|
||||
String[] child = iter.next();
|
||||
assert child[0]=="child_s" && child[2]=="parentchild_s": Arrays.toString(child);
|
||||
String child_s = child[1];
|
||||
String parentchild_s = child[3];
|
||||
int grandChildPos = 0;
|
||||
|
@ -193,7 +190,6 @@ public class BJQParserTest extends SolrTestCaseJ4 {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Ignore("SOLR-5168")
|
||||
public void testGrandChildren() throws IOException {
|
||||
assertQ(
|
||||
req("q", "{!parent which=$parentfilter v=$children}", "children",
|
||||
|
|
|
@ -221,44 +221,13 @@ public class AddBlockUpdateTest extends SolrTestCaseJ4 {
|
|||
assertSingleParentOf(searcher, one("mno"), "P");
|
||||
assertSingleParentOf(searcher, one("qrs"), "T");
|
||||
assertSingleParentOf(searcher, one("uvw"), "X");
|
||||
|
||||
assertQ(req("q",child+":(a b c)", "sort","_docid_ asc"),
|
||||
"//*[@numFound='3']", // assert physical order of children
|
||||
"//doc[1]/arr[@name='child_s']/str[text()='a']",
|
||||
"//doc[2]/arr[@name='child_s']/str[text()='b']",
|
||||
"//doc[3]/arr[@name='child_s']/str[text()='c']");
|
||||
}
|
||||
|
||||
/***
|
||||
@Test
|
||||
public void testSmallBlockDirect() throws Exception {
|
||||
final AddBlockUpdateCommand cmd = new AddBlockUpdateCommand(req("*:*"));
|
||||
final List<SolrInputDocument> docs = Arrays.asList(new SolrInputDocument() {
|
||||
{
|
||||
addField("id", id());
|
||||
addField(child, "a");
|
||||
}
|
||||
}, new SolrInputDocument() {
|
||||
{
|
||||
addField("id", id());
|
||||
addField(parent, "B");
|
||||
}
|
||||
});
|
||||
cmd.setDocs(docs);
|
||||
assertEquals(2, h.getCore().getUpdateHandler().addBlock(cmd));
|
||||
assertU(commit());
|
||||
|
||||
final SolrIndexSearcher searcher = getSearcher();
|
||||
assertQ(req("*:*"), "//*[@numFound='2']");
|
||||
assertSingleParentOf(searcher, one("a"), "B");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyDirect() throws Exception {
|
||||
final AddBlockUpdateCommand cmd = new AddBlockUpdateCommand(req("*:*"));
|
||||
// let's add empty one
|
||||
cmd.setDocs(Collections.<SolrInputDocument> emptyList());
|
||||
assertEquals(0,
|
||||
((DirectUpdateHandler2) h.getCore().getUpdateHandler()).addBlock(cmd));
|
||||
assertU(commit());
|
||||
|
||||
assertQ(req("*:*"), "//*[@numFound='0']");
|
||||
}
|
||||
***/
|
||||
|
||||
@Test
|
||||
public void testExceptionThrown() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue