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


Java HighlightComponent类代码示例

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


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

示例1: init

import org.apache.solr.handler.component.HighlightComponent; //导入依赖的package包/类
@Override
@SuppressWarnings("rawtypes")
public void init(NamedList args) {
  maxOriginalResults = getInt(args, "maxOriginalResults");
  String tmp = (String) args.get("allComponentNames");
  if (tmp != null) {
    componentNames.addAll(Arrays.asList(tmp.split("\\s*,\\s*")));
  }
  componentNames.add(getComponentName());
  componentNames.add(FacetComponent.COMPONENT_NAME);
  componentNames.add(HighlightComponent.COMPONENT_NAME);
  componentNames.add(StatsComponent.COMPONENT_NAME);
  componentNames.add(TermsComponent.COMPONENT_NAME);
  componentNames.add(TermVectorComponent.COMPONENT_NAME);
  componentNames.add(SpellCheckComponent.COMPONENT_NAME);
  componentNames.add(MoreLikeThisComponent.COMPONENT_NAME);
  componentNames.add(GroupParams.GROUP);
  componentNames.add("queryRelaxer");
  componentNames.add("DymReSearcher");
  componentNames.add("autoComplete");
  commonMisspellingsFileLocation = (String) args.get("commonMisspellingsFile");
  commonMisspellingsMap = CommonMisspellings.loadCommonMisspellingsFile(commonMisspellingsFileLocation);
}
 
开发者ID:sematext,项目名称:solr-researcher,代码行数:24,代码来源:AbstractReSearcherComponent.java

示例2: loadSearchComponents

import org.apache.solr.handler.component.HighlightComponent; //导入依赖的package包/类
/**
 * Register the default search components
 */
private Map<String, SearchComponent> loadSearchComponents()
{
  Map<String, SearchComponent> components = new HashMap<>();
  initPlugins(components,SearchComponent.class);
  for (Map.Entry<String, SearchComponent> e : components.entrySet()) {
    SearchComponent c = e.getValue();
    if (c instanceof HighlightComponent) {
      HighlightComponent hl = (HighlightComponent) c;
      if(!HighlightComponent.COMPONENT_NAME.equals(e.getKey())){
        components.put(HighlightComponent.COMPONENT_NAME,hl);
      }
      break;
    }
  }
  addIfNotPresent(components,HighlightComponent.COMPONENT_NAME,HighlightComponent.class);
  addIfNotPresent(components,QueryComponent.COMPONENT_NAME,QueryComponent.class);
  addIfNotPresent(components,FacetComponent.COMPONENT_NAME,FacetComponent.class);
  addIfNotPresent(components,MoreLikeThisComponent.COMPONENT_NAME,MoreLikeThisComponent.class);
  addIfNotPresent(components,StatsComponent.COMPONENT_NAME,StatsComponent.class);
  addIfNotPresent(components,DebugComponent.COMPONENT_NAME,DebugComponent.class);
  addIfNotPresent(components,RealTimeGetComponent.COMPONENT_NAME,RealTimeGetComponent.class);
  addIfNotPresent(components,ExpandComponent.COMPONENT_NAME,ExpandComponent.class);

  return components;
}
 
开发者ID:europeana,项目名称:search,代码行数:29,代码来源:SolrCore.java

示例3: 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

示例4: 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

示例5: 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

示例6: loadSearchComponents

import org.apache.solr.handler.component.HighlightComponent; //导入依赖的package包/类
/**
 * Register the default search components
 */
private Map<String, SearchComponent> loadSearchComponents()
{
  Map<String, SearchComponent> components = new HashMap<String, SearchComponent>();
  initPlugins(components,SearchComponent.class);
  for (Map.Entry<String, SearchComponent> e : components.entrySet()) {
    SearchComponent c = e.getValue();
    if (c instanceof HighlightComponent) {
      HighlightComponent hl = (HighlightComponent) c;
      if(!HighlightComponent.COMPONENT_NAME.equals(e.getKey())){
        components.put(HighlightComponent.COMPONENT_NAME,hl);
      }
      break;
    }
  }
  addIfNotPresent(components,HighlightComponent.COMPONENT_NAME,HighlightComponent.class);
  addIfNotPresent(components,QueryComponent.COMPONENT_NAME,QueryComponent.class);
  addIfNotPresent(components,FacetComponent.COMPONENT_NAME,FacetComponent.class);
  addIfNotPresent(components,MoreLikeThisComponent.COMPONENT_NAME,MoreLikeThisComponent.class);
  addIfNotPresent(components,StatsComponent.COMPONENT_NAME,StatsComponent.class);
  addIfNotPresent(components,DebugComponent.COMPONENT_NAME,DebugComponent.class);
  addIfNotPresent(components,RealTimeGetComponent.COMPONENT_NAME,RealTimeGetComponent.class);
  return components;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:27,代码来源:SolrCore.java

示例7: 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

示例8: 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

示例9: 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

示例10: loadSearchComponents

import org.apache.solr.handler.component.HighlightComponent; //导入依赖的package包/类
/**
 * Register the default search components
 */
private Map<String, SearchComponent> loadSearchComponents() {
	Map<String, SearchComponent> components = new HashMap<String, SearchComponent>();
	initPlugins(components, SearchComponent.class);
	for(Map.Entry<String, SearchComponent> e : components.entrySet()) {
		SearchComponent c = e.getValue();
		if(c instanceof HighlightComponent) {
			HighlightComponent hl = (HighlightComponent) c;
			if(!HighlightComponent.COMPONENT_NAME.equals(e.getKey())) {
				components.put(HighlightComponent.COMPONENT_NAME, hl);
			}
			break;
		}
	}
	addIfNotPresent(components, HighlightComponent.COMPONENT_NAME, HighlightComponent.class);
	addIfNotPresent(components, QueryComponent.COMPONENT_NAME, QueryComponent.class);
	addIfNotPresent(components, FacetComponent.COMPONENT_NAME, FacetComponent.class);
	addIfNotPresent(components, MoreLikeThisComponent.COMPONENT_NAME, MoreLikeThisComponent.class);
	addIfNotPresent(components, StatsComponent.COMPONENT_NAME, StatsComponent.class);
	addIfNotPresent(components, DebugComponent.COMPONENT_NAME, DebugComponent.class);
	addIfNotPresent(components, RealTimeGetComponent.COMPONENT_NAME, RealTimeGetComponent.class);
	return components;
}
 
开发者ID:netboynb,项目名称:search-core,代码行数:26,代码来源:SolrCore.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<>(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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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