當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。