当前位置: 首页>>代码示例>>Java>>正文


Java SolrQueryRequest.close方法代码示例

本文整理汇总了Java中org.apache.solr.request.SolrQueryRequest.close方法的典型用法代码示例。如果您正苦于以下问题:Java SolrQueryRequest.close方法的具体用法?Java SolrQueryRequest.close怎么用?Java SolrQueryRequest.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.request.SolrQueryRequest的用法示例。


在下文中一共展示了SolrQueryRequest.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test_QParserGetsCalled

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
/**
 * Basic test that checks that the "/similarity-query"
 * defined in the resources/solrconfig.xml does set the query parser
 * to the <code>{@link SimilarityParserPlugin}</code>
 */
public void test_QParserGetsCalled() throws Exception {

    // arrange
    SolrQueryRequest queryRequest = req("testQueryString");

    // act
    SolrQueryResponse resp = h.queryAndResponse("/similarity-query", queryRequest);

    // assert - the only way to check that the similarity parser was used is to check
    //          the type of the query returned by the similarity parser (for a single term): AugmentedTermQuery
    BasicResultContext basicResultContext = (BasicResultContext)resp.getResponse();
    Query usedLuceneQuery = basicResultContext.getQuery();
    assertTrue(usedLuceneQuery instanceof AugmentedTermQuery);

    // cleanup
    queryRequest.close();
}
 
开发者ID:sebastian-hofstaetter,项目名称:ir-generalized-translation-models,代码行数:23,代码来源:SimilarityParserPluginIntegrationTest.java

示例2: test_QParserTwoTerms

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
/**
 * Checks that two terms are parsed and 2 <code>{@link AugmentedTermQuery}</code> inside
 * 1 <code>{@link org.apache.lucene.search.BooleanQuery}</code> are returned.
 * The schema.xml must define an analyzer for the default field defined in solrconfig.xml
 */
public void test_QParserTwoTerms() throws Exception {

    // arrange
    SolrQueryRequest queryRequest = req("good days");

    // act
    SolrQueryResponse resp = h.queryAndResponse("/similarity-query", queryRequest);

    // assert - the only way to check that the similarity parser was used is to check
    //          the type of the query returned by the similarity parser (for a single term): AugmentedTermQuery
    BasicResultContext basicResultContext = (BasicResultContext)resp.getResponse();
    Query usedLuceneQuery = basicResultContext.getQuery();
    assertTrue(usedLuceneQuery instanceof BooleanQuery);
    BooleanQuery booleanQuery = (BooleanQuery) usedLuceneQuery;

    assertEquals(2, booleanQuery.clauses().size());
    assertTrue(booleanQuery.clauses().get(0).getQuery() instanceof AugmentedTermQuery);
    assertTrue(booleanQuery.clauses().get(1).getQuery() instanceof AugmentedTermQuery);

    // cleanup
    queryRequest.close();
}
 
开发者ID:sebastian-hofstaetter,项目名称:ir-generalized-translation-models,代码行数:28,代码来源:SimilarityParserPluginIntegrationTest.java

示例3: test_QParserTwoTerms_ET

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
/**
 * Checks that two terms are parsed and 2 <code>{@link AugmentedTermQuery}</code> inside
 * 1 <code>{@link org.apache.lucene.search.BooleanQuery}</code> are returned.
 * The schema.xml must define an analyzer for the default field defined in solrconfig.xml
 */
public void test_QParserTwoTerms_ET() throws Exception {

    // arrange
    SolrQueryRequest queryRequest = req("good days");

    // act
    SolrQueryResponse resp = h.queryAndResponse("/similarity-query-et", queryRequest);

    // assert - the only way to check that the similarity parser was used is to check
    //          the type of the query returned by the similarity parser (for a single term): AugmentedTermQuery
    BasicResultContext basicResultContext = (BasicResultContext)resp.getResponse();
    Query usedLuceneQuery = basicResultContext.getQuery();
    assertTrue(usedLuceneQuery instanceof BooleanQuery);
    BooleanQuery booleanQuery = (BooleanQuery) usedLuceneQuery;

    assertEquals(2, booleanQuery.clauses().size());
    assertTrue(booleanQuery.clauses().get(0).getQuery() instanceof AugmentedTermQuery);
    assertTrue(booleanQuery.clauses().get(1).getQuery() instanceof AugmentedTermQuery);

    // cleanup
    queryRequest.close();
}
 
开发者ID:sebastian-hofstaetter,项目名称:ir-generalized-translation-models,代码行数:28,代码来源:SimilarityParserPluginIntegrationTest.java

示例4: handleSuggestionHitsRequest

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
public long handleSuggestionHitsRequest(ReSearcherRequestContext ctx, String query, Set<String> componentNames) throws Exception {
  ModifiableSolrParams params = new ModifiableSolrParams(ctx.getParams());
  params.set(CommonParams.ROWS, "0");
  for(String componentName : componentNames) {
    params.set(componentName, "false");
  }
  params.set(CommonParams.Q, query);

  SolrQueryRequest req = new SolrQueryRequestBase(ctx.getCore(), params) {};
  SolrQueryResponse rsp = new SolrQueryResponse();
  ResponseBuilder rb = new ResponseBuilder(req, rsp, ctx.getQueryOnlyComponents());
  
  try {
    handleSuggestionRequest(ctx, rb, ctx.getQueryOnlyComponents(), true);
  } finally {
    req.close();
  }
  
  return ReSearcherUtils.extractOriginalQueryHits(rb);
}
 
开发者ID:sematext,项目名称:solr-researcher,代码行数:21,代码来源:ReSearcherHandler.java

示例5: testFuncDoubleValueMathFuncs

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
public void testFuncDoubleValueMathFuncs() throws Exception {
  SolrQueryRequest req = req("myVal","45", "myOtherVal", "27",
                             "myField","foo_i");
  for (final String func : new String[] {"pow","hypot","atan2"}) {
    try {
      assertFuncEquals(req,
                       func + "(field(foo_i),$myVal)", func+"(foo_i,$myVal)", 
                       func + "($myField,45)");
      assertFuncEquals(req, 
                       func+"(45,$myOtherVal)", func+"($myVal,27)",
                       func+"($myVal,$myOtherVal)");
                       
    } finally {
      req.close();
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:QueryEqualityTest.java

示例6: testCommitWithin

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
@Test
public void testCommitWithin() throws Exception {
  ExtractingRequestHandler handler = (ExtractingRequestHandler) h.getCore().getRequestHandler("/update/extract");
  assertTrue("handler is null and it shouldn't be", handler != null);
  
  SolrQueryRequest req = req("literal.id", "one",
                             ExtractingParams.RESOURCE_NAME, "extraction/version_control.txt",
                             "commitWithin", "200"
                             );
  SolrQueryResponse rsp = new SolrQueryResponse();
  BufferingRequestProcessor p = new BufferingRequestProcessor(null);

  ExtractingDocumentLoader loader = (ExtractingDocumentLoader) handler.newLoader(req, p);
  loader.load(req, rsp, new ContentStreamBase.FileStream(getFile("extraction/version_control.txt")),p);

  AddUpdateCommand add = p.addCommands.get(0);
  assertEquals(200, add.commitWithin);

  req.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:ExtractingRequestHandlerTest.java

示例7: testIndexAndQuery

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
@Test
public void testIndexAndQuery() throws Exception {
  assertU("<add><doc><field name=\"id\">123</field><field name=\"text\">The counter counts the beans: 1 and 2 and three.</field></doc></add>");
  assertU(commit());
  SolrQueryRequest req = req("qt", "/terms", "terms.fl", "nouns");
  assertQ(req, "//lst[@name='nouns']/int[@name='beans']");
  assertQ(req, "//lst[@name='nouns']/int[@name='counter']");
  assertQ(req, "//lst[@name='nouns']/int[@name!='The']");
  assertQ(req, "//lst[@name='nouns']/int[@name!='counts']");
  assertQ(req, "//lst[@name='nouns']/int[@name!='the']");
  assertQ(req, "//lst[@name='nouns']/int[@name!=':']");
  assertQ(req, "//lst[@name='nouns']/int[@name!='1']");
  assertQ(req, "//lst[@name='nouns']/int[@name!='and']");
  assertQ(req, "//lst[@name='nouns']/int[@name!='2']");
  assertQ(req, "//lst[@name='nouns']/int[@name!='three']");
  assertQ(req, "//lst[@name='nouns']/int[@name!='.']");
  req.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:UIMATypeAwareAnnotationsTokenizerFactoryTest.java

示例8: testExternalEntities

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
@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();
}
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:XmlUpdateRequestHandlerTest.java

示例9: testFuncIf

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
public void testFuncIf() throws Exception {
  SolrQueryRequest req = req("myBoolField","foo_b",
                             "myIntField","bar_i",
                             "myTrue","true");
  try {
    assertFuncEquals(req, 
                     "if(foo_b,bar_i,25)",
                     "if($myBoolField,bar_i,25)",
                     "if(field('foo_b'),$myIntField,25)",
                     "if(field($myBoolField),field('bar_i'),25)");
    assertFuncEquals(req, 
                     "if(true,37,field($myIntField))",
                     "if($myTrue,37,$myIntField)");
  } finally {
    req.close();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:QueryEqualityTest.java

示例10: checkFieldValueOrdering

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
private void checkFieldValueOrdering(String rawJson, float fBoost) throws Exception {
  SolrQueryRequest req = req();
  SolrQueryResponse rsp = new SolrQueryResponse();
  BufferingRequestProcessor p = new BufferingRequestProcessor(null);
  JsonLoader loader = new JsonLoader();
  loader.load(req, rsp, new ContentStreamBase.StringStream(rawJson), p);
  assertEquals( 2, p.addCommands.size() );

  SolrInputDocument d = p.addCommands.get(0).solrDoc;
  assertEquals(2, d.getFieldNames().size());
  assertEquals("1", d.getFieldValue("id"));
  assertEquals(new Object[] {45L, 67L, 89L} , d.getFieldValues("f").toArray());
  assertEquals(0.0F, fBoost, d.getField("f").getBoost());

  d = p.addCommands.get(1).solrDoc;
  assertEquals(1, d.getFieldNames().size());
  assertEquals("2", d.getFieldValue("id"));

  req.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:JsonLoaderTest.java

示例11: handleSuggestionResponseRequest

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
public SolrQueryResponse handleSuggestionResponseRequest(ReSearcherRequestContext ctx, ModifiableSolrParams params, String componentName, List<SearchComponent> components) throws Exception {
  params.set(componentName, "false");

  SolrQueryRequest req = new SolrQueryRequestBase(ctx.getCore(), params) {};
  SolrQueryResponse rsp = new SolrQueryResponse();
  ResponseBuilder rb = new ResponseBuilder(req, rsp, components);
  
  try {
    handleSuggestionRequest(ctx, rb, components, false);
  } finally {
    req.close();
  }
  
  return rsp;
}
 
开发者ID:sematext,项目名称:solr-researcher,代码行数:16,代码来源:ReSearcherHandler.java

示例12: testEmptyChildDocs

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
@Test
public void testEmptyChildDocs() throws Exception {
  String str = "{\n" +
      "    \"add\": {\n" +
      "        \"doc\": {\n" +
      "            \"id\": \"1\",\n" +
      "            \"_childDocuments_\": []\n" +
      "        }\n" +
      "    }\n" +
      "}";
  SolrQueryRequest req = req("commit","true");
  SolrQueryResponse rsp = new SolrQueryResponse();
  BufferingRequestProcessor p = new BufferingRequestProcessor(null);
  JsonLoader loader = new JsonLoader();
  loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);

  assertEquals( 1, p.addCommands.size() );

  AddUpdateCommand add = p.addCommands.get(0);
  SolrInputDocument d = add.solrDoc;
  SolrInputField f = d.getField( "id" );
  assertEquals("1", f.getValue());
  List<SolrInputDocument> cd = d.getChildDocuments();
  assertNull(cd);

  req.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:28,代码来源:JsonLoaderTest.java

示例13: testIndexAndQuery

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
@Test
public void testIndexAndQuery() throws Exception {
  assertU("<add><doc><field name=\"id\">123</field><field name=\"text\">One and 1 is two. Instead One or 1 is 0.</field></doc></add>");
  assertU(commit());
  SolrQueryRequest req = req("qt", "/terms", "terms.fl", "sentences");
  assertQ(req, "//lst[@name='sentences']/int[@name='One and 1 is two.']");
  assertQ(req, "//lst[@name='sentences']/int[@name=' Instead One or 1 is 0.']");
  req.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:UIMAAnnotationsTokenizerFactoryTest.java

示例14: processAdd

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
/**
 * Runs a document through the specified chain, and returns the final 
 * document used when the chain is completed (NOTE: some chains may 
 * modify the document in place
 */
SolrInputDocument processAdd(final String chain, 
                             final SolrInputDocument docIn) 
  throws IOException {

  SolrCore core = h.getCore();
  UpdateRequestProcessorChain pc = core.getUpdateProcessingChain(chain);
  assertNotNull("No Chain named: " + chain, pc);

  SolrQueryResponse rsp = new SolrQueryResponse();

  SolrQueryRequest req = new LocalSolrQueryRequest
    (core, new ModifiableSolrParams());
  try {
    SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req,rsp));
    AddUpdateCommand cmd = new AddUpdateCommand(req);
    cmd.solrDoc = docIn;

    UpdateRequestProcessor processor = pc.createProcessor(req, rsp);
    processor.processAdd(cmd);

    return cmd.solrDoc;
  } finally {
    SolrRequestInfo.clearRequestInfo();
    req.close();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:32,代码来源:DefaultValueUpdateProcessorTest.java

示例15: makeRequest

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
/**
 * Helper Method: Executes the request against the handler, returns 
 * the response, and closes the request.
 */
private SolrQueryResponse makeRequest(PingRequestHandler handler,
                                      SolrQueryRequest req) 
  throws Exception {

  SolrQueryResponse rsp = new SolrQueryResponse();
  try {
    handler.handleRequestBody(req, rsp);
  } finally {
    req.close();
  }
  return rsp;
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:PingRequestHandlerTest.java


注:本文中的org.apache.solr.request.SolrQueryRequest.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。