Java Code Examples for org.apache.solr.request.SolrQueryRequest#close()
The following examples show how to use
org.apache.solr.request.SolrQueryRequest#close() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractXJoinTestCase.java From BioSolr with Apache License 2.0 | 6 votes |
@SuppressWarnings("rawtypes") protected NamedList test(ModifiableSolrParams params, String componentName) { SolrCore core = h.getCore(); SearchComponent sc = core.getSearchComponent(componentName); assertTrue("XJoinSearchComponent not found in solrconfig", sc != null); QParserPlugin qp = core.getQueryPlugin("xjoin"); assertTrue("XJoinQParserPlugin not found in solrconfig", qp != null); params.add("q", "*:*"); params.add("fq", "{!xjoin}" + componentName); SolrQueryResponse rsp = new SolrQueryResponse(); rsp.add("responseHeader", new SimpleOrderedMap<>()); SolrQueryRequest req = new LocalSolrQueryRequest(core, params); SolrRequestHandler handler = core.getRequestHandler("standard"); handler.handleRequest(req, rsp); req.close(); assertNull(rsp.getException()); return rsp.getValues(); }
Example 2
Source File: InfoLoggingTest.java From querqy with Apache License 2.0 | 6 votes |
@Test public void testThatThereIsNoLogOutputIfOneRewriterDoesntSupplyAMessage() { String q = "a x"; SolrQueryRequest req = req("q", q, DisMaxParams.QF, "f1 f2 f3", QuerqyDismaxParams.INFO_LOGGING, "on", "defType", "querqy" ); assertQ("Empty log output for rewriter", req, "count(//lst[@name='querqy.infoLog']/arr[@name='common2']) = 0" ); req.close(); }
Example 3
Source File: DefaultQuerqyDismaxQParserTest.java From querqy with Apache License 2.0 | 6 votes |
@Test public void testThatBoostUpInPurelyNegativeSingleTokenQueryIsApplied() { SolrQueryRequest req = req("q", "xx uu", DisMaxParams.QF, "f1", DisMaxParams.MM, "1", "defType", "querqy", "debugQuery", "true"); assertQ("UP on negative single query not working", req, "//result[@name='response' and @numFound='2']", "//result/doc[1]/str[@name='id'][text()='11']" ); req.close(); }
Example 4
Source File: ResponseLogComponentTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testToLogScores() throws Exception { SolrQueryRequest req = null; try { String handler="/withlog"; req = req("indent","true", "qt","/withlog", "q","aa", "rows","2", "fl","id,subject,score", "responseLog","true"); SolrQueryResponse qr = h.queryAndResponse(handler, req); NamedList<Object> entries = qr.getToLog(); String responseLog = (String) entries.get("responseLog"); assertNotNull(responseLog); assertTrue(responseLog.matches("\\w+:\\d+\\.\\d+,\\w+:\\d+\\.\\d+")); } finally { req.close(); } }
Example 5
Source File: DefaultQuerqyDismaxQParserTest.java From querqy with Apache License 2.0 | 6 votes |
@Test public void testThatBoostDownInPurelyNegativeSingleTokenQueryIsApplied() { SolrQueryRequest req = req("q", "ff uu", DisMaxParams.QF, "f1", DisMaxParams.MM, "1", "defType", "querqy", "debugQuery", "true"); assertQ("UP on negative single query not working", req, "//result[@name='response' and @numFound='2']", "//result/doc[1]/str[@name='id'][text()='11']" ); req.close(); }
Example 6
Source File: ReplaceRewriterFactoryTest.java From querqy with Apache License 2.0 | 6 votes |
@Test public void testMultipleSubsequentReplacements() { String q; SolrQueryRequest req; q = "b c d e h"; req = req("q", q, DisMaxParams.QF, "f1", "defType", "querqy", "debugQuery", "on" ); assertQ("Replace rules", req, "//str[@name='parsedquery_toString'][text() = 'f1:a f1:b f1:c f1:d f1:e f1:f f1:g f1:h']" ); req.close(); }
Example 7
Source File: CommonRulesConfigTest.java From querqy with Apache License 2.0 | 6 votes |
@Test public void testIgnoreCaseFalse() throws Exception { String q = "M"; SolrQueryRequest req = req("q", q, DisMaxParams.QF, "f1", "defType", "querqy3", "debugQuery", "true" ); assertQ("Config for ignoreCase=false fails", req, "//str[@name='parsedquery'][not(contains(.,'f1:d'))]" ); req.close(); }
Example 8
Source File: QuerqyDismaxQParserWithSolrSynonymsTest.java From querqy with Apache License 2.0 | 6 votes |
@Test public void testThatGeneratedTermsArePenalised() { SolrQueryRequest req = req("q", "a b", DisMaxParams.QF, "f1^2", DisMaxParams.PF, "f1^0.5", GFB, "0.8", "defType", "querqy", "debugQuery", "true"); assertQ(GFB + " not working", req, "//str[@name='parsedquery'][contains(.,'f1:a^2.0 | f1:x^1.6')]", "//str[@name='parsedquery'][contains(.,'PhraseQuery(f1:\"a b\")^0.5')]"); req.close(); }
Example 9
Source File: CommonRulesDeleteLastTermTest.java From querqy with Apache License 2.0 | 6 votes |
@Test public void testThatQueryDoesNotMatchIfContainsBoostDownQueryAndHasNoTerm() { String q = "e"; SolrQueryRequest req = req("q", q, DisMaxParams.QF, "f1", "debugQuery", "on", "defType", "querqy"); assertQ("", req, "//result[@name='response' and @numFound='0']" ); req.close(); }
Example 10
Source File: InfoLoggingTest.java From querqy with Apache License 2.0 | 6 votes |
@Test public void testThatTheIdIsReturnedIfThereIsNoLogProperty() { String q = "c"; SolrQueryRequest req = req("q", q, DisMaxParams.QF, "f1 f2 f3", QuerqyDismaxParams.INFO_LOGGING, "on", "defType", "querqy" ); assertQ("Logged ID is missing", req, "//lst[@name='querqy.infoLog']/arr[@name='common1']/lst/arr[@name='APPLIED_RULES']/" + "str[text() = 'ID 1']", "count(//lst[@name='querqy.infoLog']/arr[@name='common1']/lst/arr[@name='APPLIED_RULES']/" + "str) = 1" ); req.close(); }
Example 11
Source File: CriteriaSelectionTest.java From querqy with Apache License 2.0 | 6 votes |
@Test public void testFilterByProperty() { SolrQueryRequest req = req("q", "input1 input2", DisMaxParams.QF, "f1", DisMaxParams.MM, "1", getStrategyParamName(REWRITER_ID_1), "criteria", getFilterParamName(REWRITER_ID_1), "group:1", "defType", "querqy", "debugQuery", "true" ); assertQ("Filter criterion doesn't work", req, "//result[@name='response' and @numFound='2']" ); req.close(); }
Example 12
Source File: DefaultQuerqyDismaxQParserTest.java From querqy with Apache License 2.0 | 5 votes |
public void verifyQueryString(SolrQueryRequest req, String q, String... expectedSubstrings) throws Exception { QuerqyDismaxQParser parser = new QuerqyDismaxQParser(q, null, req.getParams(), req, new WhiteSpaceQuerqyParser(), new RewriteChain(), new InfoLogging(Collections.emptyMap()), null); Query query = parser.parse(); req.close(); assertTrue(query instanceof BooleanQuery); BooleanQuery bq = (BooleanQuery) query; String qStr = bq.toString(); for (String exp : expectedSubstrings) { assertTrue("Missing: " + exp + " in " + bq, qStr.contains(exp)); } }
Example 13
Source File: InfoLoggingTest.java From querqy with Apache License 2.0 | 5 votes |
@Test public void testThatLogsAreReturnedForAllMatchingInputsOfTheSameRewriter() { String q = "a c d k m"; SolrQueryRequest req = req("q", q, DisMaxParams.QF, "f1 f2 f3", QuerqyDismaxParams.INFO_LOGGING, "on", "defType", "querqy" ); assertQ("Logging multiple logs for same input false", req, "//lst[@name='querqy.infoLog']/arr[@name='common1']/lst/arr[@name='APPLIED_RULES']/" + "str[text() = 'log msg 1 of input a']", "//lst[@name='querqy.infoLog']/arr[@name='common1']/lst/arr[@name='APPLIED_RULES']/" + "str[text() = 'ID 1']", "//lst[@name='querqy.infoLog']/arr[@name='common1']/lst/arr[@name='APPLIED_RULES']/" + "str[text() = 'LOG for k']", "//lst[@name='querqy.infoLog']/arr[@name='common1']/lst/arr[@name='APPLIED_RULES']/" + "str[text() = 'd#2']", "//lst[@name='querqy.infoLog']/arr[@name='common1']/lst/arr[@name='APPLIED_RULES']/" + "str[text() = 'LOG 1 for m']", "//lst[@name='querqy.infoLog']/arr[@name='common1']/lst/arr[@name='APPLIED_RULES']/" + "str[text() = 'LOG 2 for m']", "count(//lst[@name='querqy.infoLog']/arr[@name='common1']/lst/arr[@name='APPLIED_RULES']/" + "str) = 6" ); req.close(); }
Example 14
Source File: SolrTermQueryCacheTest.java From querqy with Apache License 2.0 | 5 votes |
@Test public void testThatCacheIsAvailable() throws Exception { SolrQueryRequest req = req( CommonParams.QT, "/admin/mbeans", "cat", "CACHE", "stats", "true" ); assertQ("Missing querqy cache", req, "//lst[@name='CACHE']/lst[@name='querqyTermQueryCache']"); req.close(); }
Example 15
Source File: BasicFunctionalityTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testXMLWriter() throws Exception { SolrQueryResponse rsp = new SolrQueryResponse(); rsp.add("\"quoted\"", "\"value\""); StringWriter writer = new StringWriter(32000); SolrQueryRequest req = req("foo"); XMLWriter.writeResponse(writer,req,rsp); DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); builder.parse(new ByteArrayInputStream (writer.toString().getBytes(StandardCharsets.UTF_8))); req.close(); }
Example 16
Source File: QueryEqualityTest.java From lucene-solr with Apache License 2.0 | 5 votes |
public void testFuncScale() throws Exception { SolrQueryRequest req = req("someVar","27"); try { assertFuncEquals(req, "scale(field(foo_i),$someVar,42)", "scale(foo_i, 27, 42)"); } finally { req.close(); } }
Example 17
Source File: XsltUpdateRequestHandlerTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testEntities() throws Exception { // use a binary file, so when it's loaded fail with XML eror: String file = getFile("mailing_lists.pdf").toURI().toASCIIString(); String xml = "<?xml version=\"1.0\"?>" + "<!DOCTYPE foo [" + // check that external entities are not resolved! "<!ENTITY bar SYSTEM \""+file+"\">"+ // but named entities should be "<!ENTITY wacky \"zzz\">"+ "]>" + "<random>" + " &bar;" + " <document>" + " <node name=\"id\" value=\"12345\"/>" + " <node name=\"foo_s\" value=\"&wacky;\"/>" + " </document>" + "</random>"; SolrQueryRequest req = req(CommonParams.TR, "xsl-update-handler-test.xsl"); 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()); assertEquals("zzz", add.solrDoc.getField("foo_s").getFirstValue()); req.close(); }
Example 18
Source File: QueryEqualityTest.java From lucene-solr with Apache License 2.0 | 5 votes |
public void testFuncBoost() throws Exception { SolrQueryRequest req = req("myQ","asdf"); try { assertFuncEquals(req, "boost($myQ,sum(4,5))", "boost({!lucene v=$myQ},sum(4,5))"); } finally { req.close(); } }
Example 19
Source File: QueryEqualityTest.java From lucene-solr with Apache License 2.0 | 5 votes |
public void testFuncDoubleValueBools() throws Exception { SolrQueryRequest req = req("myField","field_b","myTrue","true"); try { for (final String type : new String[]{"and","or","xor"}) { assertFuncEquals(req, type + "(field_b,true)", type + "(field_b,$myTrue)", type + "(field('field_b'),true)", type + "(field($myField),$myTrue)", type + "($myField,$myTrue)"); } } finally { req.close(); } }
Example 20
Source File: DefaultQuerqyDismaxQParserWithEmptyCommonRulesTest.java From querqy with Apache License 2.0 | 4 votes |
@Test public void testSolrIsLoadedAndQueryIsAnswered() { String q = "a"; SolrQueryRequest req = req("q", q, DisMaxParams.QF, "f1 f2 f3", DisMaxParams.MM, "1", QueryParsing.OP, "OR", "defType", "querqy" ); assertQ("Solr filter query fails", req, "//result[@name='response' and @numFound='3']" ); req.close(); }