List of usage examples for org.apache.solr.client.solrj SolrQuery setRequestHandler
public SolrQuery setRequestHandler(String qt)
From source file:com.sindicetech.siren.solr.handler.TestSirenUpdateRequestHandler.java
License:Open Source License
/** * Check that nested array are properly flattened. *//*from w w w . ja v a2 s .c o m*/ @Test public void testNestedArray() throws QueryNodeException, IOException, SolrServerException { String input = "{ \"id\" : \"1\", \"aaa\" : null, \"bbb\" : [\"ccc\", [ \"ddd\", [\"eee\"] ] ] }"; this.sendUpdateRequest(input); this.commit(); SolrQuery query = new SolrQuery(); query.setParam("nested", "{!lucene} bbb:ccc"); query.setRequestHandler("tree"); long found = this.search(query).getNumFound(); assertEquals(1, found); query = new SolrQuery(); query.setParam("nested", "{!lucene} bbb:ddd"); query.setRequestHandler("tree"); found = this.search(query).getNumFound(); assertEquals(1, found); }
From source file:com.sindicetech.siren.solr.handler.TestSirenUpdateRequestHandler.java
License:Open Source License
/** * Check that nested objects are properly flattened. *//*w ww .j av a 2s.c om*/ @Test public void testNestedObject() throws QueryNodeException, IOException, SolrServerException { String input = "{ \"id\" : \"1\", \"aaa\" : null, \"bbb\" : { \"ccc\" : { \"ddd\" : \"eee\" }, \"fff\" : \"ggg\" } }"; this.sendUpdateRequest(input); this.commit(); SolrQuery query = new SolrQuery(); query.setParam("nested", "{!lucene} bbb.ccc.ddd:eee"); query.setRequestHandler("tree"); long found = this.search(query).getNumFound(); assertEquals(1, found); query = new SolrQuery(); query.setParam("nested", "{!lucene} bbb.fff:ggg"); query.setRequestHandler("tree"); found = this.search(query).getNumFound(); assertEquals(1, found); }
From source file:com.sindicetech.siren.solr.handler.TestSirenUpdateRequestHandler.java
License:Open Source License
/** * Check that nested objects in a mixed array are properly flattened. *///from w w w . j av a 2 s . co m @Test public void testNestedObjectInArray() throws QueryNodeException, IOException, SolrServerException { String input = "{ \"id\" : \"1\", \"aaa\" : null, \"bbb\" : [ \"ccc\", { \"ddd\" : \"eee\" }, \"ggg\" ] }"; this.sendUpdateRequest(input); this.commit(); SolrQuery query = new SolrQuery(); query.setParam("nested", "{!lucene} bbb:ccc"); query.setRequestHandler("tree"); long found = this.search(query).getNumFound(); assertEquals(1, found); query = new SolrQuery(); query.setParam("nested", "{!lucene} bbb.ddd:eee"); query.setRequestHandler("tree"); found = this.search(query).getNumFound(); assertEquals(1, found); }
From source file:com.sindicetech.siren.solr.handler.TestSirenUpdateRequestHandler.java
License:Open Source License
/** * Check that the special SIREn's object for datatype is properly flattened. *//*from w w w . j a v a 2 s . c o m*/ @Test public void testDatatypeObject() throws QueryNodeException, IOException, SolrServerException { String input = "{ \"id\" : \"1\", \"aaa\" : null, \"bbb\" : { \"_datatype_\" : \"uri\", \"_value_\" : \"ccc\" } }"; this.sendUpdateRequest(input); this.commit(); SolrQuery query = new SolrQuery(); query.setParam("nested", "{!lucene} bbb:ccc"); query.setRequestHandler("tree"); long found = this.search(query).getNumFound(); assertEquals(1, found); }
From source file:com.sindicetech.siren.solr.handler.TestSirenUpdateRequestHandler.java
License:Open Source License
/** * Check that the nested query and the main query are intersected, i.e., that each one is assigned a MUST operator. * See issue #60./* w w w . ja va2 s. co m*/ */ @Test public void testNestedQuery() throws IOException, SolrServerException, QueryNodeException { String input = "{ \"aaa\" : null, \"ChargeDeviceRef\" : \"CM765\", \"ChargeDeviceLocation\" : { \"Address\" : { \"PostTown\" : \"Peterborough\" } } }"; this.sendUpdateRequest(input); input = "{ \"aaa\" : null, \"ChargeDeviceRef\" : \"CM556\", \"ChargeDeviceLocation\" : { \"Address\" : { \"PostTown\" : \"Peterborough\" } } }"; this.sendUpdateRequest(input); input = "{ \"aaa\" : null, \"ChargeDeviceRef\" : \"CM779\", \"ChargeDeviceLocation\" : { \"Address\" : { \"PostTown\" : \"Peterborough\" } } }"; this.sendUpdateRequest(input); this.commit(); SolrQuery query = new SolrQuery(); final ConciseQueryBuilder b = new ConciseQueryBuilder(); query.setQuery(b.newNode("CM765").setAttribute("ChargeDeviceRef").toString()); query.setParam("nested", "ChargeDeviceLocation.Address.PostTown:Peterborough"); query.setRequestHandler("tree"); long found = this.search(query).getNumFound(); assertEquals(1, found); }
From source file:com.sindicetech.siren.solr.qparser.TestConciseTreeQParser.java
License:Open Source License
@Test public void testSimpleConciseTreeQuery() throws IOException, SolrServerException, QueryNodeException { this.addJsonString("1", "concise", "{ \"aaa\" : { \"bbb\" : \"ccc\" } }"); SolrQuery query = new SolrQuery(); final ConciseQueryBuilder b = new ConciseQueryBuilder(); query.setQuery(b.newTwig("aaa").with(b.newNode("ccc").setAttribute("bbb")).toString()); query.setRequestHandler("tree"); query.set("qf", "concise"); String[] results = this.search(query, ID_FIELD); assertEquals(1, results.length);// ww w .ja v a2 s . c om }
From source file:com.sindicetech.siren.solr.qparser.TestConciseTreeQParser.java
License:Open Source License
/** * Checks that a keyword query that matches no document (the term down is in the stop list) * does not throw exception and returns an empty result set. * * See #73./*from w ww .ja v a 2 s .c om*/ */ @Test public void testKeywordQueryMatchingNoDoc() throws IOException, SolrServerException, QueryNodeException { this.addJsonString("1", "concise", "{ \"aaa\" : { \"bbb\" : \"ccc\" } }"); SolrQuery query = new SolrQuery(); query.setQuery("{\"node\":{\"query\":\"down\"}}"); query.setRequestHandler("tree"); query.set("qf", "concise"); String[] results = this.search(query, ID_FIELD); assertEquals(0, results.length); }
From source file:com.sindicetech.siren.solr.qparser.TestConciseTreeQParser.java
License:Open Source License
@Test public void testConciseTreeAttributeWildcard() throws IOException, SolrServerException, QueryNodeException { this.addJsonString("1", "concise-attribute-wildcard", "{ \"aaa\" : { \"bbb\" : \"ccc\" } }"); SolrQuery query = new SolrQuery(); final ConciseQueryBuilder b = new ConciseQueryBuilder(); query.setQuery(b.newNode("ccc").toString()); query.setRequestHandler("tree"); query.set("qf", "concise-attribute-wildcard"); String[] results = this.search(query, ID_FIELD); assertEquals(1, results.length);// w ww . j ava 2 s . c om }
From source file:com.sindicetech.siren.solr.qparser.TestConciseTreeQParser.java
License:Open Source License
@Test public void testSpanConciseTreeQuery() throws IOException, SolrServerException, QueryNodeException { this.addJsonString("1", "concise", "{ \"aaa\" : { \"bbb\" : \"ccc\", \"ddd\" : \"eee\" } }"); SolrQuery query = new SolrQuery(); final ConciseQueryBuilder b = new ConciseQueryBuilder(); final TwigQuery twig = b.newTwig("aaa").with(b.newBoolean().with(b.newNode("ccc").setAttribute("bbb")) .with(b.newNode("eee").setAttribute("ddd")).setInOrder(false)); query.setQuery(twig.toString());/* www .j av a2s . c om*/ query.setRequestHandler("tree"); query.set("qf", "concise"); String[] results = this.search(query, ID_FIELD); assertEquals(1, results.length); }
From source file:com.sindicetech.siren.solr.qparser.TestConciseTreeQParser.java
License:Open Source License
/** * Issue #66: The query parser applies lowercase the expanded terms *//* w w w . j a v a2 s.c o m*/ @Test public void testPrefixQueryConciseTreeQuery() throws IOException, SolrServerException, QueryNodeException { this.addJsonString("1", "concise-keyword", "{ \"rdfs:label\" : \"COM_GRANAGLIONE\" }"); SolrQuery query = new SolrQuery(); final ConciseQueryBuilder b = new ConciseQueryBuilder(); query.setQuery(b.newNode("COM_*").setAttribute("rdfs:label").toString()); query.setRequestHandler("tree"); query.set("qf", "concise-keyword"); String[] results = this.search(query, ID_FIELD); assertEquals(1, results.length); }