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


Java SolrCore.getSearchComponent方法代码示例

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


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

示例1: testCollateWithFilter

import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
@Test
public void testCollateWithFilter() throws Exception
{
  SolrCore core = h.getCore();
  SearchComponent speller = core.getSearchComponent("spellcheck");
  assertTrue("speller is null and it shouldn't be", speller != null);

  ModifiableSolrParams params = new ModifiableSolrParams();
  params.add(SpellCheckComponent.COMPONENT_NAME, "true");
  params.add(SpellingParams.SPELLCHECK_BUILD, "true");
  params.add(SpellingParams.SPELLCHECK_COUNT, "10");
  params.add(SpellingParams.SPELLCHECK_COLLATE, "true");
  params.add(SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, "10");
  params.add(SpellingParams.SPELLCHECK_MAX_COLLATIONS, "10");
  params.add(CommonParams.Q, "lowerfilt:(+fauth +home +loane)");
  params.add(CommonParams.FQ, "NOT(id:1)");

  //Because a FilterQuery is applied which removes doc id#1 from possible hits, we would
  //not want the collations to return us "lowerfilt:(+faith +hope +loaves)" as this only matches doc id#1.
  SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
  SolrQueryResponse rsp = new SolrQueryResponse();
  rsp.add("responseHeader", new SimpleOrderedMap());
  SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
  handler.handleRequest(req, rsp);
  req.close();
  NamedList values = rsp.getValues();
  NamedList spellCheck = (NamedList) values.get("spellcheck");
  NamedList suggestions = (NamedList) spellCheck.get("suggestions");
  List<String> collations = suggestions.getAll("collation");
  assertTrue(collations.size() > 0);
  for(String collation : collations) {
    assertTrue(!collation.equals("lowerfilt:(+faith +hope +loaves)"));
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:35,代码来源:SpellCheckCollatorTest.java

示例2: testCollateWithGrouping

import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
@Test
public void testCollateWithGrouping() throws Exception
{
  SolrCore core = h.getCore();
  SearchComponent speller = core.getSearchComponent("spellcheck");
  assertTrue("speller is null and it shouldn't be", speller != null);

  ModifiableSolrParams params = new ModifiableSolrParams();
  params.add(SpellCheckComponent.COMPONENT_NAME, "true");
  params.add(SpellingParams.SPELLCHECK_BUILD, "true");
  params.add(SpellingParams.SPELLCHECK_COUNT, "10");
  params.add(SpellingParams.SPELLCHECK_COLLATE, "true");
  params.add(SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, "5");
  params.add(SpellingParams.SPELLCHECK_MAX_COLLATIONS, "1");
  params.add(CommonParams.Q, "lowerfilt:(+fauth)");
  params.add(GroupParams.GROUP, "true");
  params.add(GroupParams.GROUP_FIELD, "id");

  //Because a FilterQuery is applied which removes doc id#1 from possible hits, we would
  //not want the collations to return us "lowerfilt:(+faith +hope +loaves)" as this only matches doc id#1.
  SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
  SolrQueryResponse rsp = new SolrQueryResponse();
  rsp.add("responseHeader", new SimpleOrderedMap());
  SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
  handler.handleRequest(req, rsp);
  req.close();
  NamedList values = rsp.getValues();
  NamedList spellCheck = (NamedList) values.get("spellcheck");
  NamedList suggestions = (NamedList) spellCheck.get("suggestions");
  List<String> collations = suggestions.getAll("collation");
  assertTrue(collations.size() == 1);
}
 
开发者ID:europeana,项目名称:search,代码行数:33,代码来源:SpellCheckCollatorTest.java

示例3: testZeroTries

import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
@Test
public void testZeroTries() throws Exception
{
  SolrCore core = h.getCore();
  SearchComponent speller = core.getSearchComponent("spellcheck");
  assertTrue("speller is null and it shouldn't be", speller != null);
  
  ModifiableSolrParams params = new ModifiableSolrParams();   
  params.add(SpellCheckComponent.COMPONENT_NAME, "true");
  params.add(SpellCheckComponent.SPELLCHECK_BUILD, "true");
  params.add(SpellCheckComponent.SPELLCHECK_COUNT, "10");   
  params.add(SpellCheckComponent.SPELLCHECK_COLLATE, "true");
  params.add(SpellCheckComponent.SPELLCHECK_MAX_COLLATION_TRIES, "0");
  params.add(SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "2");
  params.add(CommonParams.Q, "lowerfilt:(+fauth)");
  SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
  SolrQueryResponse rsp = new SolrQueryResponse();
  rsp.add("responseHeader", new SimpleOrderedMap());
  SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
  handler.handleRequest(req, rsp);
  req.close();
  NamedList values = rsp.getValues();
  NamedList spellCheck = (NamedList) values.get("spellcheck");
  NamedList suggestions = (NamedList) spellCheck.get("suggestions");
  List<String> collations = suggestions.getAll("collation");
  assertTrue(collations.size() == 2);
}
 
开发者ID:europeana,项目名称:search,代码行数:28,代码来源:SpellCheckCollatorTest.java


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