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


Java HighlightComponent.getHighlighter方法代码示例

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


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

示例1: testConfig

import org.apache.solr.handler.component.HighlightComponent; //导入方法依赖的package包/类
@Test
public void testConfig()
{
  DefaultSolrHighlighter highlighter = (DefaultSolrHighlighter) HighlightComponent.getHighlighter(h.getCore());

  // Make sure we loaded the one formatter
  SolrFormatter fmt1 = highlighter.formatters.get( null );
  SolrFormatter fmt2 = highlighter.formatters.get( "" );
  assertSame( fmt1, fmt2 );
  assertTrue( fmt1 instanceof HtmlFormatter );
  
  
  // Make sure we loaded the one formatter
  SolrFragmenter gap = highlighter.fragmenters.get( "gap" );
  SolrFragmenter regex = highlighter.fragmenters.get( "regex" );
  SolrFragmenter frag = highlighter.fragmenters.get( null );
  assertSame( gap, frag );
  assertTrue( gap instanceof GapFragmenter );
  assertTrue( regex instanceof RegexFragmenter );
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:HighlighterTest.java

示例2: testConfig

import org.apache.solr.handler.component.HighlightComponent; //导入方法依赖的package包/类
public void testConfig()
{
        SolrHighlighter highlighter = HighlightComponent.getHighlighter(h.getCore());
  log.info( "highlighter" );

  assertTrue( highlighter instanceof DummyHighlighter );

  // check to see that doHighlight is called from the DummyHighlighter
  HashMap<String,String> args = new HashMap<>();
  args.put("hl", "true");
  args.put("df", "t_text");
  args.put("hl.fl", "");
  TestHarness.LocalRequestFactory sumLRF = h.getRequestFactory(
    "standard", 0, 200, args);

  assertU(adoc("t_text", "a long day's night", "id", "1"));
  assertU(commit());
  assertU(optimize());
  assertQ("Basic summarization",
          sumLRF.makeRequest("long"),
          "//lst[@name='highlighting']/str[@name='dummy']"
          );
}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:HighlighterConfigTest.java

示例3: beforeClass

import org.apache.solr.handler.component.HighlightComponent; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
  initCore("solrconfig-postingshighlight.xml", "schema-postingshighlight.xml");
  
  // test our config is sane, just to be sure:
  
  // postingshighlighter should be used
  SolrHighlighter highlighter = HighlightComponent.getHighlighter(h.getCore());
  assertTrue("wrong highlighter: " + highlighter.getClass(), highlighter instanceof PostingsSolrHighlighter);
  
  // 'text' and 'text3' should have offsets, 'text2' should not
  IndexSchema schema = h.getCore().getLatestSchema();
  assertTrue(schema.getField("text").storeOffsetsWithPositions());
  assertTrue(schema.getField("text3").storeOffsetsWithPositions());
  assertFalse(schema.getField("text2").storeOffsetsWithPositions());
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:TestPostingsSolrHighlighter.java

示例4: testConfig

import org.apache.solr.handler.component.HighlightComponent; //导入方法依赖的package包/类
@Test
public void testConfig()
{
  SolrHighlighter highlighter = HighlightComponent.getHighlighter(h.getCore());

  // Make sure we loaded the one formatter
  SolrFormatter fmt1 = highlighter.formatters.get( null );
  SolrFormatter fmt2 = highlighter.formatters.get( "" );
  assertSame( fmt1, fmt2 );
  assertTrue( fmt1 instanceof HtmlFormatter );
  
  
  // Make sure we loaded the one formatter
  SolrFragmenter gap = highlighter.fragmenters.get( "gap" );
  SolrFragmenter regex = highlighter.fragmenters.get( "regex" );
  SolrFragmenter frag = highlighter.fragmenters.get( null );
  assertSame( gap, frag );
  assertTrue( gap instanceof GapFragmenter );
  assertTrue( regex instanceof RegexFragmenter );
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:21,代码来源:HighlighterTest.java

示例5: testConfig

import org.apache.solr.handler.component.HighlightComponent; //导入方法依赖的package包/类
public void testConfig()
{
        SolrHighlighter highlighter = HighlightComponent.getHighlighter(h.getCore());
  log.info( "highlighter" );

  assertTrue( highlighter instanceof DummyHighlighter );

  // check to see that doHighlight is called from the DummyHighlighter
  HashMap<String,String> args = new HashMap<String,String>();
  args.put("hl", "true");
  args.put("df", "t_text");
  args.put("hl.fl", "");
  TestHarness.LocalRequestFactory sumLRF = h.getRequestFactory(
    "standard", 0, 200, args);

  assertU(adoc("t_text", "a long day's night", "id", "1"));
  assertU(commit());
  assertU(optimize());
  assertQ("Basic summarization",
          sumLRF.makeRequest("long"),
          "//lst[@name='highlighting']/str[@name='dummy']"
          );
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:24,代码来源:HighlighterConfigTest.java

示例6: beforeClass

import org.apache.solr.handler.component.HighlightComponent; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
  initCore("solrconfig-postingshighlight.xml", "schema-postingshighlight.xml");
  
  // test our config is sane, just to be sure:
  
  // postingshighlighter should be used
  SolrHighlighter highlighter = HighlightComponent.getHighlighter(h.getCore());
  assertTrue("wrong highlighter: " + highlighter.getClass(), highlighter instanceof PostingsSolrHighlighter);
  
  // 'text' and 'text3' should have offsets, 'text2' should not
  IndexSchema schema = h.getCore().getSchema();
  assertTrue(schema.getField("text").storeOffsetsWithPositions());
  assertTrue(schema.getField("text3").storeOffsetsWithPositions());
  assertFalse(schema.getField("text2").storeOffsetsWithPositions());
  
  assertU(adoc("text", "document one", "text2", "document one", "text3", "crappy document", "id", "101"));
  assertU(adoc("text", "second document", "text2", "second document", "text3", "crappier document", "id", "102"));
  assertU(commit());
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:21,代码来源:TestPostingsSolrHighlighter.java

示例7: optimizePreFetchDocs

import org.apache.solr.handler.component.HighlightComponent; //导入方法依赖的package包/类
/**
 * Pre-fetch documents into the index searcher's document cache.
 *
 * This is an entirely optional step which you might want to perform for
 * the following reasons:
 *
 * <ul>
 *     <li>Locates the document-retrieval costs in one spot, which helps
 *     detailed performance measurement</li>
 *
 *     <li>Determines a priori what fields will be needed to be fetched by
 *     various subtasks, like response writing and highlighting.  This
 *     minimizes the chance that many needed fields will be loaded lazily.
 *     (it is more efficient to load all the field we require normally).</li>
 * </ul>
 *
 * If lazy field loading is disabled, this method does nothing.
 */
public static void optimizePreFetchDocs(ResponseBuilder rb,
                                        DocList docs,
                                        Query query,
                                        SolrQueryRequest req,
                                        SolrQueryResponse res) throws IOException {
  SolrIndexSearcher searcher = req.getSearcher();
  if(!searcher.enableLazyFieldLoading) {
    // nothing to do
    return;
  }

  ReturnFields returnFields = res.getReturnFields();
  if(returnFields.getLuceneFieldNames() != null) {
    Set<String> fieldFilter = returnFields.getLuceneFieldNames();

    if (rb.doHighlights) {
      // copy return fields list
      fieldFilter = new HashSet<>(fieldFilter);
      // add highlight fields

      SolrHighlighter highlighter = HighlightComponent.getHighlighter(req.getCore());
      for (String field: highlighter.getHighlightFields(query, req, null))
        fieldFilter.add(field);

      // fetch unique key if one exists.
      SchemaField keyField = searcher.getSchema().getUniqueKeyField();
      if(null != keyField)
        fieldFilter.add(keyField.getName());
    }

    // get documents
    DocIterator iter = docs.iterator();
    for (int i=0; i<docs.size(); i++) {
      searcher.doc(iter.nextDoc(), fieldFilter);
    }

  }

}
 
开发者ID:europeana,项目名称:search,代码行数:58,代码来源:SolrPluginUtils.java

示例8: testConfig

import org.apache.solr.handler.component.HighlightComponent; //导入方法依赖的package包/类
@Test
public void testConfig(){
  DefaultSolrHighlighter highlighter = (DefaultSolrHighlighter) HighlightComponent.getHighlighter(h.getCore());

  // Make sure we loaded one fragListBuilder
  SolrFragListBuilder solrFlbNull = highlighter.fragListBuilders.get( null );
  SolrFragListBuilder solrFlbEmpty = highlighter.fragListBuilders.get( "" );
  SolrFragListBuilder solrFlbSimple = highlighter.fragListBuilders.get( "simple" );
  assertSame( solrFlbNull, solrFlbEmpty );
  assertTrue( solrFlbNull instanceof SimpleFragListBuilder );
  assertTrue( solrFlbSimple instanceof SimpleFragListBuilder );
      
  // Make sure we loaded two fragmentsBuilders
  SolrFragmentsBuilder solrFbNull = highlighter.fragmentsBuilders.get( null );
  SolrFragmentsBuilder solrFbEmpty = highlighter.fragmentsBuilders.get( "" );
  SolrFragmentsBuilder solrFbSimple = highlighter.fragmentsBuilders.get( "simple" );
  SolrFragmentsBuilder solrFbSO = highlighter.fragmentsBuilders.get( "scoreOrder" );
  assertSame( solrFbNull, solrFbEmpty );
  assertTrue( solrFbNull instanceof SimpleFragmentsBuilder );
  assertTrue( solrFbSimple instanceof SimpleFragmentsBuilder );
  assertTrue( solrFbSO instanceof ScoreOrderFragmentsBuilder );
  
  // Make sure we loaded two boundaryScanners
  SolrBoundaryScanner solrBsNull = highlighter.boundaryScanners.get(null);
  SolrBoundaryScanner solrBsEmpty = highlighter.boundaryScanners.get("");
  SolrBoundaryScanner solrBsSimple = highlighter.boundaryScanners.get("simple");
  SolrBoundaryScanner solrBsBI = highlighter.boundaryScanners.get("breakIterator");
  assertSame(solrBsNull, solrBsEmpty);
  assertTrue(solrBsNull instanceof SimpleBoundaryScanner);
  assertTrue(solrBsSimple instanceof SimpleBoundaryScanner);
  assertTrue(solrBsBI instanceof BreakIteratorBoundaryScanner);
}
 
开发者ID:europeana,项目名称:search,代码行数:33,代码来源:FastVectorHighlighterTest.java

示例9: optimizePreFetchDocs

import org.apache.solr.handler.component.HighlightComponent; //导入方法依赖的package包/类
/**
 * Pre-fetch documents into the index searcher's document cache.
 *
 * This is an entirely optional step which you might want to perform for
 * the following reasons:
 *
 * <ul>
 *     <li>Locates the document-retrieval costs in one spot, which helps
 *     detailed performance measurement</li>
 *
 *     <li>Determines a priori what fields will be needed to be fetched by
 *     various subtasks, like response writing and highlighting.  This
 *     minimizes the chance that many needed fields will be loaded lazily.
 *     (it is more efficient to load all the field we require normally).</li>
 * </ul>
 *
 * If lazy field loading is disabled, this method does nothing.
 */
public static void optimizePreFetchDocs(ResponseBuilder rb,
                                        DocList docs,
                                        Query query,
                                        SolrQueryRequest req,
                                        SolrQueryResponse res) throws IOException {
  SolrIndexSearcher searcher = req.getSearcher();
  if(!searcher.enableLazyFieldLoading) {
    // nothing to do
    return;
  }

  ReturnFields returnFields = res.getReturnFields();
  if(returnFields.getLuceneFieldNames() != null) {
    Set<String> fieldFilter = returnFields.getLuceneFieldNames();

    if (rb.doHighlights) {
      // copy return fields list
      fieldFilter = new HashSet<String>(fieldFilter);
      // add highlight fields

      SolrHighlighter highlighter = HighlightComponent.getHighlighter(req.getCore());
      for (String field: highlighter.getHighlightFields(query, req, null))
        fieldFilter.add(field);

      // fetch unique key if one exists.
      SchemaField keyField = req.getSearcher().getSchema().getUniqueKeyField();
      if(null != keyField)
        fieldFilter.add(keyField.getName());
    }

    // get documents
    DocIterator iter = docs.iterator();
    for (int i=0; i<docs.size(); i++) {
      searcher.doc(iter.nextDoc(), fieldFilter);
    }

  }

}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:58,代码来源:SolrPluginUtils.java

示例10: testConfig

import org.apache.solr.handler.component.HighlightComponent; //导入方法依赖的package包/类
@Test
public void testConfig(){
  SolrHighlighter highlighter = HighlightComponent.getHighlighter(h.getCore());

  // Make sure we loaded one fragListBuilder
  SolrFragListBuilder solrFlbNull = highlighter.fragListBuilders.get( null );
  SolrFragListBuilder solrFlbEmpty = highlighter.fragListBuilders.get( "" );
  SolrFragListBuilder solrFlbSimple = highlighter.fragListBuilders.get( "simple" );
  assertSame( solrFlbNull, solrFlbEmpty );
  assertTrue( solrFlbNull instanceof SimpleFragListBuilder );
  assertTrue( solrFlbSimple instanceof SimpleFragListBuilder );
      
  // Make sure we loaded two fragmentsBuilders
  SolrFragmentsBuilder solrFbNull = highlighter.fragmentsBuilders.get( null );
  SolrFragmentsBuilder solrFbEmpty = highlighter.fragmentsBuilders.get( "" );
  SolrFragmentsBuilder solrFbSimple = highlighter.fragmentsBuilders.get( "simple" );
  SolrFragmentsBuilder solrFbSO = highlighter.fragmentsBuilders.get( "scoreOrder" );
  assertSame( solrFbNull, solrFbEmpty );
  assertTrue( solrFbNull instanceof SimpleFragmentsBuilder );
  assertTrue( solrFbSimple instanceof SimpleFragmentsBuilder );
  assertTrue( solrFbSO instanceof ScoreOrderFragmentsBuilder );
  
  // Make sure we loaded two boundaryScanners
  SolrBoundaryScanner solrBsNull = highlighter.boundaryScanners.get(null);
  SolrBoundaryScanner solrBsEmpty = highlighter.boundaryScanners.get("");
  SolrBoundaryScanner solrBsSimple = highlighter.boundaryScanners.get("simple");
  SolrBoundaryScanner solrBsBI = highlighter.boundaryScanners.get("breakIterator");
  assertSame(solrBsNull, solrBsEmpty);
  assertTrue(solrBsNull instanceof SimpleBoundaryScanner);
  assertTrue(solrBsSimple instanceof SimpleBoundaryScanner);
  assertTrue(solrBsBI instanceof BreakIteratorBoundaryScanner);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:33,代码来源:FastVectorHighlighterTest.java

示例11: optimizePreFetchDocs

import org.apache.solr.handler.component.HighlightComponent; //导入方法依赖的package包/类
/**
 * Pre-fetch documents into the index searcher's document cache.
 *
 * This is an entirely optional step which you might want to perform for
 * the following reasons:
 *
 * <ul>
 *     <li>Locates the document-retrieval costs in one spot, which helps
 *     detailed performance measurement</li>
 *
 *     <li>Determines a priori what fields will be needed to be fetched by
 *     various subtasks, like response writing and highlighting.  This
 *     minimizes the chance that many needed fields will be loaded lazily.
 *     (it is more efficient to load all the field we require normally).</li>
 * </ul>
 *
 * If lazy field loading is disabled, this method does nothing.
 */
public static void optimizePreFetchDocs(ResponseBuilder rb,
                                        DocList docs,
                                        Query query,
                                        SolrQueryRequest req,
                                        SolrQueryResponse res) throws IOException {
  SolrIndexSearcher searcher = req.getSearcher();
  if(!searcher.enableLazyFieldLoading) {
    // nothing to do
    return;
  }

  ReturnFields returnFields = res.getReturnFields();
  if(returnFields.getLuceneFieldNames() != null) {
    Set<String> fieldFilter = returnFields.getLuceneFieldNames();

    if (rb.doHighlights) {
      // copy return fields list
      fieldFilter = new HashSet<String>(fieldFilter);
      // add highlight fields

      SolrHighlighter highlighter = HighlightComponent.getHighlighter(req.getCore());
      for (String field: highlighter.getHighlightFields(query, req, null))
        fieldFilter.add(field);

      // fetch unique key if one exists.
      SchemaField keyField = searcher.getSchema().getUniqueKeyField();
      if(null != keyField)
        fieldFilter.add(keyField.getName());
    }

    // get documents
    DocIterator iter = docs.iterator();
    for (int i=0; i<docs.size(); i++) {
      searcher.doc(iter.nextDoc(), fieldFilter);
    }

  }

}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:58,代码来源:SolrPluginUtils.java

示例12: testGetHighlightFields

import org.apache.solr.handler.component.HighlightComponent; //导入方法依赖的package包/类
@Test
public void testGetHighlightFields() {
  HashMap<String, String> args = new HashMap<>();
  args.put("fl", "id score");
  args.put("hl", "true");
  args.put("hl.fl", "t*");

  assertU(adoc("id", "0", "title", "test", // static stored
      "text", "test", // static not stored
      "foo_s", "test", // dynamic stored
      "foo_sI", "test", // dynamic not stored
      "weight", "1.0")); // stored but not text
  assertU(commit());
  assertU(optimize());

  TestHarness.LocalRequestFactory lrf = h.getRequestFactory("standard", 0,
      10, args);

  SolrQueryRequest request = lrf.makeRequest("test");
  SolrHighlighter highlighter = HighlightComponent.getHighlighter(h.getCore());
  List<String> highlightFieldNames = Arrays.asList(highlighter
      .getHighlightFields(null, request, new String[] {}));
  assertTrue("Expected to highlight on field \"title\"", highlightFieldNames
      .contains("title"));
  assertFalse("Expected to not highlight on field \"text\"",
      highlightFieldNames.contains("text"));
  assertFalse("Expected to not highlight on field \"weight\"",
      highlightFieldNames.contains("weight"));
  request.close();

  args.put("hl.fl", "foo_*");
  lrf = h.getRequestFactory("standard", 0, 10, args);
  request = lrf.makeRequest("test");
  highlighter = HighlightComponent.getHighlighter(h.getCore());
  highlightFieldNames = Arrays.asList(highlighter.getHighlightFields(null,
      request, new String[] {}));
  assertEquals("Expected one field to highlight on", 1, highlightFieldNames
      .size());
  assertEquals("Expected to highlight on field \"foo_s\"", "foo_s",
      highlightFieldNames.get(0));
  request.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:43,代码来源:HighlighterTest.java

示例13: beforeClass

import org.apache.solr.handler.component.HighlightComponent; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
  initCore("tagged-highlighting-solrconfig.xml", "schema.xml");
  SolrHighlighter highlighter = HighlightComponent.getHighlighter(h.getCore());
  assertTrue("wrong highlighter: " + highlighter.getClass(), highlighter instanceof TaggedQueryHighlighter);
}
 
开发者ID:sematext,项目名称:solr-redis,代码行数:7,代码来源:TestTaggedQueryHighlighterIT.java

示例14: testGetHighlightFields

import org.apache.solr.handler.component.HighlightComponent; //导入方法依赖的package包/类
@Test
public void testGetHighlightFields() {
  HashMap<String, String> args = new HashMap<String, String>();
  args.put("fl", "id score");
  args.put("hl", "true");
  args.put("hl.fl", "t*");

  assertU(adoc("id", "0", "title", "test", // static stored
      "text", "test", // static not stored
      "foo_s", "test", // dynamic stored
      "foo_sI", "test", // dynamic not stored
      "weight", "1.0")); // stored but not text
  assertU(commit());
  assertU(optimize());

  TestHarness.LocalRequestFactory lrf = h.getRequestFactory("standard", 0,
      10, args);

  SolrQueryRequest request = lrf.makeRequest("test");
  SolrHighlighter highlighter = HighlightComponent.getHighlighter(h.getCore());
  List<String> highlightFieldNames = Arrays.asList(highlighter
      .getHighlightFields(null, request, new String[] {}));
  assertTrue("Expected to highlight on field \"title\"", highlightFieldNames
      .contains("title"));
  assertFalse("Expected to not highlight on field \"text\"",
      highlightFieldNames.contains("text"));
  assertFalse("Expected to not highlight on field \"weight\"",
      highlightFieldNames.contains("weight"));
  request.close();

  args.put("hl.fl", "foo_*");
  lrf = h.getRequestFactory("standard", 0, 10, args);
  request = lrf.makeRequest("test");
  highlighter = HighlightComponent.getHighlighter(h.getCore());
  highlightFieldNames = Arrays.asList(highlighter.getHighlightFields(null,
      request, new String[] {}));
  assertEquals("Expected one field to highlight on", 1, highlightFieldNames
      .size());
  assertEquals("Expected to highlight on field \"foo_s\"", "foo_s",
      highlightFieldNames.get(0));
  request.close();
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:43,代码来源:HighlighterTest.java


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