use of org.apache.solr.request.SolrQueryRequest in project lucene-solr by apache.
the class LukeRequestHandlerTest method testCopyFieldLists.
public void testCopyFieldLists() throws Exception {
SolrQueryRequest req = req("qt", "/admin/luke", "show", "schema");
String xml = h.query(req);
String r = TestHarness.validateXPath(xml, field("text") + "/arr[@name='copySources']/str[.='title']", field("text") + "/arr[@name='copySources']/str[.='subject']", field("title") + "/arr[@name='copyDests']/str[.='text']", field("title") + "/arr[@name='copyDests']/str[.='title_stemmed']", dynfield("bar_copydest_*") + "/arr[@name='copySources']/str[.='foo_copysource_*']", dynfield("foo_copysource_*") + "/arr[@name='copyDests']/str[.='bar_copydest_*']");
assertEquals(xml, null, r);
}
use of org.apache.solr.request.SolrQueryRequest in project lucene-solr by apache.
the class XmlUpdateRequestHandlerTest method testExternalEntities.
@Test
public void testExternalEntities() throws Exception {
String file = getFile("mailing_lists.pdf").toURI().toASCIIString();
String xml = "<?xml version=\"1.0\"?>" + // check that external entities are not resolved!
"<!DOCTYPE foo [<!ENTITY bar SYSTEM \"" + file + "\">]>" + "<add>" + " &bar;" + " <doc>" + " <field name=\"id\">12345</field>" + " <field name=\"name\">kitten</field>" + " </doc>" + "</add>";
SolrQueryRequest req = req();
SolrQueryResponse rsp = new SolrQueryResponse();
BufferingRequestProcessor p = new BufferingRequestProcessor(null);
XMLLoader loader = new XMLLoader().init(null);
loader.load(req, rsp, new ContentStreamBase.StringStream(xml), p);
AddUpdateCommand add = p.addCommands.get(0);
assertEquals("12345", add.solrDoc.getField("id").getFirstValue());
req.close();
}
use of org.apache.solr.request.SolrQueryRequest in project lucene-solr by apache.
the class XmlUpdateRequestHandlerTest method testRequestParams.
@Test
public void testRequestParams() throws Exception {
String xml = "<add>" + " <doc>" + " <field name=\"id\">12345</field>" + " <field name=\"name\">kitten</field>" + " </doc>" + "</add>";
SolrQueryRequest req = req("commitWithin", "100", "overwrite", "false");
SolrQueryResponse rsp = new SolrQueryResponse();
BufferingRequestProcessor p = new BufferingRequestProcessor(null);
XMLLoader loader = new XMLLoader().init(null);
loader.load(req, rsp, new ContentStreamBase.StringStream(xml), p);
AddUpdateCommand add = p.addCommands.get(0);
assertEquals(100, add.commitWithin);
assertEquals(false, add.overwrite);
req.close();
}
use of org.apache.solr.request.SolrQueryRequest in project lucene-solr by apache.
the class BlockJoinFacetSimpleTest method testParentLevelFQExclusion.
@Test
public void testParentLevelFQExclusion() {
SolrQueryRequest req = req("qt", handler, "q", "{!parent which=type_s:parent}+SIZE_s:XL", "fq", "{!term f=BRAND_s tag=rbrand}Nike", "facet", "true", "facet.field", "BRAND_s", "child.facet.field", "COLOR_s");
assertQ("no exclusion, brand facet got only one Nike", req, "//*[@numFound='" + 1 + "']", "count(//lst[@name='BRAND_s']/int[.='1'])=1");
assertQ("nike filter is excluded, expecting both brand in facet", req("qt", handler, "q", "{!parent which=type_s:parent}+SIZE_s:XL", "fq", "{!term f=BRAND_s tag=rbrand}Nike", "facet", "true", "facet.field", "{!ex=rbrand}BRAND_s", "child.facet.field", "COLOR_s"), "//*[@numFound='" + 1 + "']", "count(//lst[@name='BRAND_s']/int[.='1'])=2");
}
use of org.apache.solr.request.SolrQueryRequest in project lucene-solr by apache.
the class GraphQueryTest method testGraph.
@Test
public void testGraph() throws Exception {
// 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(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(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(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(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(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']");
}
Aggregations