diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-graph.xml b/solr/core/src/test-files/solr/collection1/conf/schema-graph.xml
deleted file mode 100644
index a75ce663818..00000000000
--- a/solr/core/src/test-files/solr/collection1/conf/schema-graph.xml
+++ /dev/null
@@ -1,71 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- id
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/solr/core/src/test/org/apache/solr/search/join/GraphQueryTest.java b/solr/core/src/test/org/apache/solr/search/join/GraphQueryTest.java
index 357363c0c4a..b8f8fc867a8 100644
--- a/solr/core/src/test/org/apache/solr/search/join/GraphQueryTest.java
+++ b/solr/core/src/test/org/apache/solr/search/join/GraphQueryTest.java
@@ -18,8 +18,6 @@ package org.apache.solr.search.join;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.params.SolrParams;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.request.SolrQueryRequest;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -28,89 +26,78 @@ public class GraphQueryTest extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeTests() throws Exception {
- initCore("solrconfig.xml","schema-graph.xml");
+ initCore("solrconfig.xml","schema_latest.xml");
}
-
+
@Test
public void testGraph() throws Exception {
+ doGraph( params("node_id","node_s", "edge_id","edge_ss") );
+ // TODO: try with numeric fields... doGraph( params("node_id","node_i", "edge_id","edge_is") );
+ }
+
+ public void doGraph(SolrParams p) throws Exception {
+ String node_id = p.get("node_id");
+ String edge_id = p.get("edge_id");
+
// 1 -> 2 -> 3 -> ( 4 5 )
// 7 -> 1
// 8 -> ( 1 2 )
- assertU(adoc("id", "doc_1", "node_id", "1", "edge_id", "2", "text", "foo", "title", "foo10"));
- assertU(adoc("id", "doc_2", "node_id", "2", "edge_id", "3", "text", "foo"));
+ assertU(adoc("id", "doc_1", node_id, "1", edge_id, "2", "text", "foo", "title", "foo10" ));
+ assertU(adoc("id", "doc_2", node_id, "2", edge_id, "3", "text", "foo" ));
assertU(commit());
- assertU(adoc("id", "doc_3", "node_id", "3", "edge_id", "4", "edge_id", "5", "table", "foo"));
- assertU(adoc("id", "doc_4", "node_id", "4", "table", "foo"));
+ assertU(adoc("id", "doc_3", node_id, "3", edge_id, "4", edge_id, "5"));
+ assertU(adoc("id", "doc_4", node_id, "4" ));
assertU(commit());
- assertU(adoc("id", "doc_5", "node_id", "5", "edge_id", "7", "table", "bar"));
- assertU(adoc("id", "doc_6", "node_id", "6", "edge_id", "3" ));
- assertU(adoc("id", "doc_7", "node_id", "7", "edge_id", "1" ));
- assertU(adoc("id", "doc_8", "node_id", "8", "edge_id", "1", "edge_id", "2" ));
- assertU(adoc("id", "doc_9", "node_id", "9"));
+ assertU(adoc("id", "doc_5", node_id, "5", edge_id, "7" ));
+ assertU(adoc("id", "doc_6", node_id, "6", edge_id, "3" ));
+ assertU(adoc("id", "doc_7", node_id, "7", edge_id, "1" ));
+ assertU(adoc("id", "doc_8", node_id, "8", edge_id, "1", edge_id, "2" ));
+ assertU(adoc("id", "doc_9", node_id, "9"));
assertU(commit());
// update docs so they're in a new segment.
- assertU(adoc("id", "doc_1", "node_id", "1", "edge_id", "2", "text", "foo"));
- assertU(adoc("id", "doc_2", "node_id", "2", "edge_id", "3", "edge_id", "9", "text", "foo11"));
+ assertU(adoc("id", "doc_1", node_id, "1", edge_id, "2", "text", "foo"));
+ assertU(adoc("id", "doc_2", node_id, "2", edge_id, "3", edge_id, "9", "text", "foo11"));
assertU(commit());
// a graph for testing traversal filter 10 - 11 -> (12 | 13)
- assertU(adoc("id", "doc_10", "node_id", "10", "edge_id", "11", "title", "foo"));
- assertU(adoc("id", "doc_11", "node_id", "11", "edge_id", "12", "edge_id", "13", "text", "foo11"));
- assertU(adoc("id", "doc_12", "node_id", "12", "text", "foo10"));
- assertU(adoc("id", "doc_13", "node_id", "13", "edge_id", "12", "text", "foo10"));
+ assertU(adoc("id", "doc_10", node_id, "10", edge_id, "11", "title", "foo"));
+ assertU(adoc("id", "doc_11", node_id, "11", edge_id, "12", edge_id, "13", "text", "foo11"));
+ assertU(adoc("id", "doc_12", node_id, "12", "text", "foo10"));
+ assertU(adoc("id", "doc_13", node_id, "13", edge_id, "12", "text", "foo10"));
assertU(commit());
// Now we have created a simple graph
// start traversal from node id to edge id
- String gQuery = "{!graph from=\"node_id\" to=\"edge_id\"}id:doc_1";
- SolrQueryRequest qr = createRequest(gQuery);
- assertQ(qr,"//*[@numFound='7']");
-
- String g2Query = "{!graph from=\"node_id\" to=\"edge_id\" returnRoot=\"true\" returnOnlyLeaf=\"false\"}id:doc_8";
- qr = createRequest(g2Query);
- assertQ(qr,"//*[@numFound='8']");
- String g3Query = "{!graph from=\"node_id\" to=\"edge_id\" returnRoot=\"false\" returnOnlyLeaf=\"false\"}id:doc_8";
- qr = createRequest(g3Query);
- assertQ(qr,"//*[@numFound='7']");
-
- String g4Query = "{!graph from=\"node_id\" to=\"edge_id\" returnRoot=\"true\" returnOnlyLeaf=\"false\" traversalFilter=\"text:foo11\"}id:doc_8";
- qr = createRequest(g4Query);
- assertQ(qr,"//*[@numFound='2']");
-
- String g5Query = "{!graph from=\"node_id\" to=\"edge_id\" returnRoot=\"true\" returnOnlyLeaf=\"false\" maxDepth=0}id:doc_8";
- qr = createRequest(g5Query);
- assertQ(qr,"//*[@numFound='1']");
-
- String g6Query = "{!graph from=\"node_id\" to=\"edge_id\" returnRoot=\"true\" returnOnlyLeaf=\"false\" maxDepth=1}id:doc_8";
- qr = createRequest(g6Query);
- assertQ(qr,"//*[@numFound='3']");
-
- String g7Query = "{!graph from=\"node_id\" to=\"edge_id\" returnRoot=\"false\" returnOnlyLeaf=\"false\" maxDepth=1}id:doc_8";
- qr = createRequest(g7Query);
- assertQ(qr,"//*[@numFound='2']");
-
- String g8Query = "{!graph from=\"node_id\" to=\"edge_id\" returnRoot=\"false\" returnOnlyLeaf=\"true\" maxDepth=2}id:doc_8";
- qr = createRequest(g8Query);
- assertQ(qr,"//*[@numFound='1']");
-
- String g9Query = "{!graph from=\"node_id\" to=\"edge_id\" maxDepth=1}id:doc_1";
- qr = createRequest(g9Query);
- assertQ(qr,"//*[@numFound='2']");
-
- String g10Query = "{!graph from=\"node_id\" to=\"edge_id\" returnRoot=false maxDepth=1}id:doc_1";
- qr = createRequest(g10Query);
- assertQ(qr,"//*[@numFound='1']");
- }
-
- private SolrQueryRequest createRequest(String query) {
- SolrQueryRequest qr = req(query);
- NamedList