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


Java HighlightParams类代码示例

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


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

示例1: testFacetAndHighlight

import org.apache.solr.common.params.HighlightParams; //导入依赖的package包/类
@Test
public void testFacetAndHighlight() {
  assertQ(req(CommonParams.QT, "standardGoodSuggestion", 
      CommonParams.Q, "foo:bobo AND foo:marley",
      SpellingParams.SPELLCHECK_COLLATE, "true", 
      SpellingParams.SPELLCHECK_BUILD, "true", 
      SpellingParams.SPELLCHECK_COUNT, "10", 
      SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true",
      FacetParams.FACET, "true", 
      FacetParams.FACET_FIELD, "foo", 
      FacetParams.FACET_FIELD, "id", 
      FacetParams.FACET_FIELD, "bar", 
      FacetParams.FACET_QUERY, "id:[0 TO 20]", 
      FacetParams.FACET_QUERY, "id:[1 TO 100]", 
      HighlightParams.HIGHLIGHT, "true", 
      HighlightParams.FIELDS, "foo",
      DymReSearcher.COMPONENT_NAME, "true",
      SpellCheckComponent.COMPONENT_NAME, "true")
      ,"//result[@name='spellchecked_response'][@numFound='7']"
      ,"//result[@name='response'][@numFound='0']"
      ,"//arr[@name='extended_spellchecker_suggestions']/str[1][.='foo:bob AND foo:marley']"
      ,"//lst[@name='spellchecked_facet_counts']/lst[@name='facet_fields']/lst[@name='foo']/int[@name='bob'][.='7']"
      ,"//lst[@name='spellchecked_facet_counts']/lst[@name='facet_fields']/lst[@name='foo']/int[@name='marley'][.='7']"
      ,"//lst[@name='spellchecked_highlighting']/lst[@name='2']/arr[@name='foo']/str[1]");
}
 
开发者ID:sematext,项目名称:solr-researcher,代码行数:26,代码来源:TestDymReSearcher.java

示例2: testFacetAndHighlightWithCommonMisspellings

import org.apache.solr.common.params.HighlightParams; //导入依赖的package包/类
@Test
public void testFacetAndHighlightWithCommonMisspellings() {
  assertQ(req(CommonParams.QT, "standardResWithCommonMisspellings", 
      CommonParams.Q, "foo:bobo AND foo:marley",
      SpellingParams.SPELLCHECK_COLLATE, "true", 
      SpellingParams.SPELLCHECK_BUILD, "true", 
      SpellingParams.SPELLCHECK_COUNT, "10", 
      SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true",
      FacetParams.FACET, "true", 
      FacetParams.FACET_FIELD, "foo", 
      FacetParams.FACET_FIELD, "id",
      FacetParams.FACET_FIELD, "bar", 
      FacetParams.FACET_QUERY, "id:[0 TO 20]", 
      FacetParams.FACET_QUERY, "id:[1 TO 100]",
      HighlightParams.HIGHLIGHT, "true", 
      HighlightParams.FIELDS, "foo",
      DymReSearcher.COMPONENT_NAME, "true",
      SpellCheckComponent.COMPONENT_NAME, "true")
      ,"//result[@name='spellchecked_response'][@numFound='3']"
      ,"//result[@name='response'][@numFound='0']"
      ,"//arr[@name='extended_spellchecker_suggestions']/str[1][.='foo:bono AND foo:marley']"
      ,"//lst[@name='spellchecked_facet_counts']/lst[@name='facet_fields']/lst[@name='foo']/int[@name='bob'][.='3']"
      ,"//lst[@name='spellchecked_facet_counts']/lst[@name='facet_fields']/lst[@name='foo']/int[@name='marley'][.='3']"
      ,"//lst[@name='spellchecked_highlighting']/lst[@name='9']/arr[@name='foo']/str[1]"
      );
}
 
开发者ID:sematext,项目名称:solr-researcher,代码行数:27,代码来源:TestDymReSearcher.java

示例3: prepare

import org.apache.solr.common.params.HighlightParams; //导入依赖的package包/类
@Override
public void prepare(ResponseBuilder rb) throws IOException {
  SolrParams params = rb.req.getParams();
  rb.doHighlights = highlighter.isHighlightingEnabled(params);
  if(rb.doHighlights){
    String hlq = params.get(HighlightParams.Q);
    String hlparser = Objects.firstNonNull(params.get(HighlightParams.QPARSER),
                                            params.get(QueryParsing.DEFTYPE, QParserPlugin.DEFAULT_QTYPE));
    if(hlq != null){
      try {
        QParser parser = QParser.getParser(hlq, hlparser, rb.req);
        rb.setHighlightQuery(parser.getHighlightQuery());
      } catch (SyntaxError e) {
        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
      }
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:HighlightComponent.java

示例4: getFragmenter

import org.apache.solr.common.params.HighlightParams; //导入依赖的package包/类
@Override
public Fragmenter getFragmenter(String fieldName, SolrParams params )
{ 
  numRequests++;
  params = SolrParams.wrapDefaults(params, defaults);

  int fragsize  = params.getFieldInt(   fieldName, HighlightParams.FRAGSIZE,  LuceneRegexFragmenter.DEFAULT_FRAGMENT_SIZE );
  int increment = params.getFieldInt(   fieldName, HighlightParams.INCREMENT, LuceneRegexFragmenter.DEFAULT_INCREMENT_GAP );
  float slop    = params.getFieldFloat( fieldName, HighlightParams.SLOP,      LuceneRegexFragmenter.DEFAULT_SLOP );
  int maxchars  = params.getFieldInt(   fieldName, HighlightParams.MAX_RE_CHARS, LuceneRegexFragmenter.DEFAULT_MAX_ANALYZED_CHARS );
  String rawpat = params.getFieldParam( fieldName, HighlightParams.PATTERN,   LuceneRegexFragmenter.DEFAULT_PATTERN_RAW );

  Pattern p = rawpat == defaultPatternRaw ? defaultPattern : Pattern.compile(rawpat);

  if( fragsize <= 0 ) {
    return new NullFragmenter();
  }
  
  return new LuceneRegexFragmenter( fragsize, increment, slop, maxchars, p );
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:RegexFragmenter.java

示例5: getSpanQueryScorer

import org.apache.solr.common.params.HighlightParams; //导入依赖的package包/类
/**
 * Return a {@link org.apache.lucene.search.highlight.QueryScorer} suitable for this Query and field.
 * @param query The current query
 * @param tokenStream document text CachingTokenStream
 * @param fieldName The name of the field
 * @param request The SolrQueryRequest
 */
private QueryScorer getSpanQueryScorer(Query query, String fieldName, TokenStream tokenStream, SolrQueryRequest request) {
  boolean reqFieldMatch = request.getParams().getFieldBool(fieldName, HighlightParams.FIELD_MATCH, false);
  Boolean highlightMultiTerm = request.getParams().getBool(HighlightParams.HIGHLIGHT_MULTI_TERM, true);
  if(highlightMultiTerm == null) {
    highlightMultiTerm = false;
  }
  QueryScorer scorer;
  if (reqFieldMatch) {
    scorer = new QueryScorer(query, fieldName);
  }
  else {
    scorer = new QueryScorer(query, null);
  }
  scorer.setExpandMultiTermQuery(highlightMultiTerm);
  return scorer;
}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:DefaultSolrHighlighter.java

示例6: doHighlightingByFastVectorHighlighter

import org.apache.solr.common.params.HighlightParams; //导入依赖的package包/类
private void doHighlightingByFastVectorHighlighter( FastVectorHighlighter highlighter, FieldQuery fieldQuery,
    SolrQueryRequest req, NamedList docSummaries, int docId, Document doc,
    String fieldName ) throws IOException {
  SolrParams params = req.getParams(); 
  SolrFragmentsBuilder solrFb = getSolrFragmentsBuilder( fieldName, params );
  String[] snippets = highlighter.getBestFragments( fieldQuery, req.getSearcher().getIndexReader(), docId, fieldName,
      params.getFieldInt( fieldName, HighlightParams.FRAGSIZE, 100 ),
      params.getFieldInt( fieldName, HighlightParams.SNIPPETS, 1 ),
      getFragListBuilder( fieldName, params ),
      getFragmentsBuilder( fieldName, params ),
      solrFb.getPreTags( params, fieldName ),
      solrFb.getPostTags( params, fieldName ),
      getEncoder( fieldName, params ) );
  if( snippets != null && snippets.length > 0 )
    docSummaries.add( fieldName, snippets );
  else
    alternateField( docSummaries, params, doc, fieldName );
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:DefaultSolrHighlighter.java

示例7: doHighlighting

import org.apache.solr.common.params.HighlightParams; //导入依赖的package包/类
@Override
public NamedList<Object> doHighlighting(DocList docs, Query query, SolrQueryRequest req, String[] defaultFields) throws IOException {
  final SolrParams params = req.getParams(); 
  
  // if highlighting isnt enabled, then why call doHighlighting?
  if (!isHighlightingEnabled(params))
    return null;

  SolrIndexSearcher searcher = req.getSearcher();
  int[] docIDs = toDocIDs(docs);

  // fetch the unique keys
  String[] keys = getUniqueKeys(searcher, docIDs);

  // query-time parameters
  String[] fieldNames = getHighlightFields(query, req, defaultFields);

  int maxPassages[] = new int[fieldNames.length];
  for (int i = 0; i < fieldNames.length; i++) {
    maxPassages[i] = params.getFieldInt(fieldNames[i], HighlightParams.SNIPPETS, 1);
  }

  PostingsHighlighter highlighter = getHighlighter(req);
  Map<String,String[]> snippets = highlighter.highlightFields(fieldNames, query, searcher, docIDs, maxPassages);
  return encodeSnippets(keys, fieldNames, snippets);
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:PostingsSolrHighlighter.java

示例8: parseBreakIterator

import org.apache.solr.common.params.HighlightParams; //导入依赖的package包/类
/** parse a break iterator type for the specified locale */
protected BreakIterator parseBreakIterator(String type, Locale locale) {
  if (type == null || "SENTENCE".equals(type)) {
    return BreakIterator.getSentenceInstance(locale);
  } else if ("LINE".equals(type)) {
    return BreakIterator.getLineInstance(locale);
  } else if ("WORD".equals(type)) {
    return BreakIterator.getWordInstance(locale);
  } else if ("CHARACTER".equals(type)) {
    return BreakIterator.getCharacterInstance(locale);
  } else if ("WHOLE".equals(type)) {
    return new WholeBreakIterator();
  } else {
    throw new IllegalArgumentException("Unknown " + HighlightParams.BS_TYPE + ": " + type);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:PostingsSolrHighlighter.java

示例9: appendHighlightFormatOptions

import org.apache.solr.common.params.HighlightParams; //导入依赖的package包/类
private void appendHighlightFormatOptions(HighlightOptions options, SolrQueryMethod queryMethod) {
	String formatter = queryMethod.getHighlightFormatter();
	if (formatter != null) {
		options.setFormatter(formatter);
	}
	String highlightPrefix = queryMethod.getHighlightPrefix();
	if (highlightPrefix != null) {
		if (isSimpleHighlightingOption(formatter)) {
			options.setSimplePrefix(highlightPrefix);
		} else {
			options.addHighlightParameter(new HighlightParameter(HighlightParams.TAG_PRE, highlightPrefix));
		}
	}
	String highlightPostfix = queryMethod.getHighlightPostfix();
	if (highlightPostfix != null) {
		if (isSimpleHighlightingOption(formatter)) {
			options.setSimplePostfix(highlightPostfix);
		} else {
			options.addHighlightParameter(new HighlightParameter(HighlightParams.TAG_POST, highlightPostfix));
		}
	}
}
 
开发者ID:yiduwangkai,项目名称:dubbox-solr,代码行数:23,代码来源:AbstractSolrQuery.java

示例10: doHighlighting

import org.apache.solr.common.params.HighlightParams; //导入依赖的package包/类
@Override
public NamedList<Object> doHighlighting(DocList docs, Query query, SolrQueryRequest req, String[] defaultFields) throws IOException {
  SolrParams params = req.getParams(); 
  
  // if highlighting isnt enabled, then why call doHighlighting?
  if (isHighlightingEnabled(params)) {
    SolrIndexSearcher searcher = req.getSearcher();
    TopDocs topDocs = toTopDocs(docs);
    
    // fetch the unique keys
    String[] keys = getUniqueKeys(searcher, topDocs);
    
    // query-time parameters
    String[] fieldNames = getHighlightFields(query, req, defaultFields);
    int numSnippets = params.getInt(HighlightParams.SNIPPETS, 1);
    
    Map<String,String[]> snippets = highlighter.highlightFields(fieldNames, query, searcher, topDocs, numSnippets);
    return encodeSnippets(keys, fieldNames, snippets);
  } else {
    return null;
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:23,代码来源:PostingsSolrHighlighter.java

示例11: processHighlightOptions

import org.apache.solr.common.params.HighlightParams; //导入依赖的package包/类
/**
 * Append highlighting parameters to {@link SolrQuery}
 * 
 * @param solrQuery
 * @param query
 */
protected void processHighlightOptions(SolrQuery solrQuery, HighlightQuery query) {
	if (query.hasHighlightOptions()) {
		HighlightOptions highlightOptions = query.getHighlightOptions();
		solrQuery.setHighlight(true);
		if (!highlightOptions.hasFields()) {
			solrQuery.addHighlightField(HighlightOptions.ALL_FIELDS.getName());
		} else {
			for (Field field : highlightOptions.getFields()) {
				solrQuery.addHighlightField(field.getName());
			}
			for (FieldWithHighlightParameters fieldWithHighlightParameters : highlightOptions
					.getFieldsWithHighlightParameters()) {
				addPerFieldHighlightParameters(solrQuery, fieldWithHighlightParameters);
			}
		}
		for (HighlightParameter option : highlightOptions.getHighlightParameters()) {
			addOptionToSolrQuery(solrQuery, option);
		}
		if (highlightOptions.hasQuery()) {
			solrQuery.add(HighlightParams.Q, getQueryString(highlightOptions.getQuery()));
		}
	}
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:30,代码来源:DefaultQueryParser.java

示例12: testQueryWithNonDefaultHighlightFormatter

import org.apache.solr.common.params.HighlightParams; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testQueryWithNonDefaultHighlightFormatter() {
	ArgumentCaptor<HighlightQuery> captor = ArgumentCaptor.forClass(HighlightQuery.class);

	createQueryForMethod("findAndApplyHighlightingWithNonDefaultFormatter", Pageable.class).execute(
			new Object[] { new PageRequest(0, 10) });

	Mockito.verify(solrOperationsMock, Mockito.times(1)).queryForHighlightPage(captor.capture(),
			(Class<ProductBean>) Matchers.any());

	HighlightOptions capturedOptions = captor.getValue().getHighlightOptions();
	Assert.assertNotNull(capturedOptions);
	Assert.assertNull(capturedOptions.getSimplePrefix());
	Assert.assertNull(capturedOptions.getSimplePrefix());
	Assert.assertNull(capturedOptions.getSimplePostfix());
	Assert.assertEquals("postingshighlighter", capturedOptions.getFormatter());
	Assert.assertEquals("{pre}", capturedOptions.getHighlightParameterValue(HighlightParams.TAG_PRE));
	Assert.assertEquals("{post}", capturedOptions.getHighlightParameterValue(HighlightParams.TAG_POST));
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:21,代码来源:SolrQueryTests.java

示例13: generateHighlighting

import org.apache.solr.common.params.HighlightParams; //导入依赖的package包/类
private HighlightingParams generateHighlighting() {
    HighlightingParams highlightParams = new HighlightingParams();
    highlightParams.addParam(HighlightParams.SIMPLE_PRE, "<highlight>");
    highlightParams.addParam(HighlightParams.SIMPLE_POST, "</highlight>");
    
    HighlightingFieldParams firstFieldHighlightParams = new HighlightingFieldParams("firstContent");
    firstFieldHighlightParams.addHighlightFromField("firstHighlightFrom");
    firstFieldHighlightParams.addHighlightFromField("secondHighlightFrom");
    firstFieldHighlightParams.addParam(HighlightParams.FRAGSIZE, "50");
    firstFieldHighlightParams.addParam(HighlightParams.SNIPPETS, "2");
    highlightParams.addFieldParams(firstFieldHighlightParams);
    
    HighlightingFieldParams secondFieldHighlightParams = new HighlightingFieldParams("secondContent");
    secondFieldHighlightParams.addParam(HighlightParams.FRAGSIZE, "200");
    secondFieldHighlightParams.addParam(HighlightParams.SNIPPETS, "5");
    highlightParams.addFieldParams(secondFieldHighlightParams);
    
    return highlightParams;
}
 
开发者ID:CeON,项目名称:saos,代码行数:20,代码来源:SearchQueryFactoryImplTest.java

示例14: testOriginalAndSpellcheckedFacet

import org.apache.solr.common.params.HighlightParams; //导入依赖的package包/类
@Test
public void testOriginalAndSpellcheckedFacet() {
  assertQ(req(CommonParams.QT, "standardGoodSuggestionAllowSomeOriginalResults", 
      CommonParams.Q, "foo:elvos OR foo:presley",
      SpellingParams.SPELLCHECK_COLLATE, "true", 
      SpellingParams.SPELLCHECK_BUILD, "true", 
      SpellingParams.SPELLCHECK_COUNT, "10", 
      SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true",
      FacetParams.FACET, "true", 
      FacetParams.FACET_FIELD, "foo", 
      FacetParams.FACET_FIELD, "id", 
      FacetParams.FACET_FIELD, "bar", 
      FacetParams.FACET_QUERY, "id:[0 TO 20]", 
      FacetParams.FACET_QUERY, "id:[1 TO 100]", 
      HighlightParams.HIGHLIGHT, "true", 
      HighlightParams.FIELDS, "foo",
      DymReSearcher.COMPONENT_NAME, "true",
      SpellCheckComponent.COMPONENT_NAME, "true")
      ,"//result[@name='spellchecked_response'][@numFound='3']"
      ,"//result[@name='response'][@numFound='1']"
      ,"//arr[@name='extended_spellchecker_suggestions']/str[1][.='foo:elvis OR foo:presley']"
      // check spellchecked facets:
      ,"//lst[@name='spellchecked_facet_counts']/lst[@name='facet_fields']/lst[@name='foo']/int[@name='elvi'][.='3']"
      ,"//lst[@name='spellchecked_facet_counts']/lst[@name='facet_fields']/lst[@name='foo']/int[@name='presley'][.='1']"
      ,"//lst[@name='spellchecked_facet_counts']/lst[@name='facet_fields']/lst[@name='foo']/int[@name='2'][.='1']"
      // check original facets:
      ,"//lst[@name='facet_counts']/lst[@name='facet_fields']/lst[@name='foo']/int[@name='elvi'][.='1']"
      ,"//lst[@name='facet_counts']/lst[@name='facet_fields']/lst[@name='foo']/int[@name='presley'][.='1']"
      );
}
 
开发者ID:sematext,项目名称:solr-researcher,代码行数:31,代码来源:TestDymReSearcher.java

示例15: testHighlighting

import org.apache.solr.common.params.HighlightParams; //导入依赖的package包/类
@Test
public void testHighlighting() {
  assertQ(req(CommonParams.QT, "dismax_relaxer", CommonParams.Q, "bobo marley ",
      QueryRelaxerComponent.COMPONENT_NAME, "true", HighlightParams.HIGHLIGHT, "true", HighlightParams.FIELDS, "foo")
            ,"//result[@name='response'][@numFound='0']"
            ,"//arr[@name='relaxer_suggestions']/lst[1]/str[@name='relaxedQuery'][.='marley']"
            ,"//arr[@name='relaxer_suggestions']/lst[1]/str[@name='relaxedType'][.='query']"
            ,"//arr[@name='relaxer_suggestions']/lst[1]/lst[@name='relaxer_highlighting']/lst[@name='2']/arr[@name='foo']/str[1]"
          );
}
 
开发者ID:sematext,项目名称:solr-researcher,代码行数:11,代码来源:TestQueryRelaxerComponent.java


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