當前位置: 首頁>>代碼示例>>Java>>正文


Java ElevationObj類代碼示例

本文整理匯總了Java中org.apache.solr.handler.component.QueryElevationComponent.ElevationObj的典型用法代碼示例。如果您正苦於以下問題:Java ElevationObj類的具體用法?Java ElevationObj怎麽用?Java ElevationObj使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ElevationObj類屬於org.apache.solr.handler.component.QueryElevationComponent包,在下文中一共展示了ElevationObj類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testElevationReloading

import org.apache.solr.handler.component.QueryElevationComponent.ElevationObj; //導入依賴的package包/類
@Test
public void testElevationReloading() throws Exception {
  try {
    init("schema12.xml");
    String testfile = "data-elevation.xml";
    File f = new File(h.getCore().getDataDir(), testfile);
    writeFile(f, "aaa", "A");

    QueryElevationComponent comp = (QueryElevationComponent) h.getCore().getSearchComponent("elevate");
    NamedList<String> args = new NamedList<>();
    args.add(QueryElevationComponent.CONFIG_FILE, testfile);
    comp.init(args);
    comp.inform(h.getCore());

    SolrQueryRequest req = req();
    IndexReader reader = req.getSearcher().getIndexReader();
    Map<String, ElevationObj> map = comp.getElevationMap(reader, h.getCore());
    assertTrue(map.get("aaa").priority.containsKey(new BytesRef("A")));
    assertNull(map.get("bbb"));
    req.close();

    // now change the file
    writeFile(f, "bbb", "B");
    assertU(adoc("id", "10000")); // will get same reader if no index change
    assertU(commit());

    req = req();
    reader = req.getSearcher().getIndexReader();
    map = comp.getElevationMap(reader, h.getCore());
    assertNull(map.get("aaa"));
    assertTrue(map.get("bbb").priority.containsKey(new BytesRef("B")));
    req.close();
  } finally {
    delete();
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:37,代碼來源:QueryElevationComponentTest.java

示例2: testElevationReloading

import org.apache.solr.handler.component.QueryElevationComponent.ElevationObj; //導入依賴的package包/類
@Test
public void testElevationReloading() throws Exception {
  try {
    init("schema12.xml");
    String testfile = "data-elevation.xml";
    File f = new File(h.getCore().getDataDir(), testfile);
    writeFile(f, "aaa", "A");

    QueryElevationComponent comp = (QueryElevationComponent) h.getCore().getSearchComponent("elevate");
    NamedList<String> args = new NamedList<String>();
    args.add(QueryElevationComponent.CONFIG_FILE, testfile);
    comp.init(args);
    comp.inform(h.getCore());

    SolrQueryRequest req = req();
    IndexReader reader = req.getSearcher().getIndexReader();
    Map<String, ElevationObj> map = comp.getElevationMap(reader, h.getCore());
    assertTrue(map.get("aaa").priority.containsKey(new BytesRef("A")));
    assertNull(map.get("bbb"));
    req.close();

    // now change the file
    writeFile(f, "bbb", "B");
    assertU(adoc("id", "10000")); // will get same reader if no index change
    assertU(commit());

    req = req();
    reader = req.getSearcher().getIndexReader();
    map = comp.getElevationMap(reader, h.getCore());
    assertNull(map.get("aaa"));
    assertTrue(map.get("bbb").priority.containsKey(new BytesRef("B")));
    req.close();
  } finally {
    delete();
  }
}
 
開發者ID:pkarmstr,項目名稱:NYBC,代碼行數:37,代碼來源:QueryElevationComponentTest.java

示例3: testInterface

import org.apache.solr.handler.component.QueryElevationComponent.ElevationObj; //導入依賴的package包/類
@Test
public void testInterface() throws Exception {
  try {
    init("schema12.xml");
    SolrCore core = h.getCore();

    NamedList<String> args = new NamedList<>();
    args.add(QueryElevationComponent.FIELD_TYPE, "string");
    args.add(QueryElevationComponent.CONFIG_FILE, "elevate.xml");

    QueryElevationComponent comp = new QueryElevationComponent();
    comp.init(args);
    comp.inform(core);

    SolrQueryRequest req = req();
    IndexReader reader = req.getSearcher().getIndexReader();
    Map<String, ElevationObj> map = comp.getElevationMap(reader, core);
    req.close();

    // Make sure the boosts loaded properly
    assertEquals(7, map.size());
    assertEquals(1, map.get("XXXX").priority.size());
    assertEquals(2, map.get("YYYY").priority.size());
    assertEquals(3, map.get("ZZZZ").priority.size());
    assertEquals(null, map.get("xxxx"));
    assertEquals(null, map.get("yyyy"));
    assertEquals(null, map.get("zzzz"));

    // Now test the same thing with a lowercase filter: 'lowerfilt'
    args = new NamedList<>();
    args.add(QueryElevationComponent.FIELD_TYPE, "lowerfilt");
    args.add(QueryElevationComponent.CONFIG_FILE, "elevate.xml");

    comp = new QueryElevationComponent();
    comp.init(args);
    comp.inform(core);
    map = comp.getElevationMap(reader, core);
    assertEquals(7, map.size());
    assertEquals(null, map.get("XXXX"));
    assertEquals(null, map.get("YYYY"));
    assertEquals(null, map.get("ZZZZ"));
    assertEquals(1, map.get("xxxx").priority.size());
    assertEquals(2, map.get("yyyy").priority.size());
    assertEquals(3, map.get("zzzz").priority.size());

    assertEquals("xxxx", comp.getAnalyzedQuery("XXXX"));
    assertEquals("xxxxyyyy", comp.getAnalyzedQuery("XXXX YYYY"));

    assertQ("Make sure QEC handles null queries", req("qt", "/elevate", "q.alt", "*:*", "defType", "dismax"),
        "//*[@numFound='0']");
  } finally {
    delete();
  }

}
 
開發者ID:europeana,項目名稱:search,代碼行數:56,代碼來源:QueryElevationComponentTest.java

示例4: testInterface

import org.apache.solr.handler.component.QueryElevationComponent.ElevationObj; //導入依賴的package包/類
@Test
public void testInterface() throws Exception {
  try {
    init("schema12.xml");
    SolrCore core = h.getCore();

    NamedList<String> args = new NamedList<String>();
    args.add(QueryElevationComponent.FIELD_TYPE, "string");
    args.add(QueryElevationComponent.CONFIG_FILE, "elevate.xml");

    QueryElevationComponent comp = new QueryElevationComponent();
    comp.init(args);
    comp.inform(core);

    SolrQueryRequest req = req();
    IndexReader reader = req.getSearcher().getIndexReader();
    Map<String, ElevationObj> map = comp.getElevationMap(reader, core);
    req.close();

    // Make sure the boosts loaded properly
    assertEquals(7, map.size());
    assertEquals(1, map.get("XXXX").priority.size());
    assertEquals(2, map.get("YYYY").priority.size());
    assertEquals(3, map.get("ZZZZ").priority.size());
    assertEquals(null, map.get("xxxx"));
    assertEquals(null, map.get("yyyy"));
    assertEquals(null, map.get("zzzz"));

    // Now test the same thing with a lowercase filter: 'lowerfilt'
    args = new NamedList<String>();
    args.add(QueryElevationComponent.FIELD_TYPE, "lowerfilt");
    args.add(QueryElevationComponent.CONFIG_FILE, "elevate.xml");

    comp = new QueryElevationComponent();
    comp.init(args);
    comp.inform(core);
    map = comp.getElevationMap(reader, core);
    assertEquals(7, map.size());
    assertEquals(null, map.get("XXXX"));
    assertEquals(null, map.get("YYYY"));
    assertEquals(null, map.get("ZZZZ"));
    assertEquals(1, map.get("xxxx").priority.size());
    assertEquals(2, map.get("yyyy").priority.size());
    assertEquals(3, map.get("zzzz").priority.size());

    assertEquals("xxxx", comp.getAnalyzedQuery("XXXX"));
    assertEquals("xxxxyyyy", comp.getAnalyzedQuery("XXXX YYYY"));

    assertQ("Make sure QEC handles null queries", req("qt", "/elevate", "q.alt", "*:*", "defType", "dismax"),
        "//*[@numFound='0']");
  } finally {
    delete();
  }

}
 
開發者ID:pkarmstr,項目名稱:NYBC,代碼行數:56,代碼來源:QueryElevationComponentTest.java


注:本文中的org.apache.solr.handler.component.QueryElevationComponent.ElevationObj類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。