• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java HighlightComponent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


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


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


示例18: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ApplicationAdapter类代码示例发布时间:2022-05-22
下一篇:
Java Builder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap