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


Java SolrPluginUtils.split方法代码示例

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


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

示例1: getHighlightFields

import org.apache.solr.util.SolrPluginUtils; //导入方法依赖的package包/类
/**
 * Return a String array of the fields to be highlighted.
 * Falls back to the programatic defaults, or the default search field if the list of fields
 * is not specified in either the handler configuration or the request.
 * @param query The current Query
 * @param request The current SolrQueryRequest
 * @param defaultFields Programmatic default highlight fields, used if nothing is specified in the handler config or the request.
 */
public String[] getHighlightFields(Query query, SolrQueryRequest request, String[] defaultFields) {
  String fields[] = request.getParams().getParams(HighlightParams.FIELDS);

  // if no fields specified in the request, or the handler, fall back to programmatic default, or default search field.
  if(emptyArray(fields)) {
    // use default search field if highlight fieldlist not specified.
    if (emptyArray(defaultFields)) {
      String defaultSearchField = request.getSchema().getDefaultSearchFieldName();
      fields = null == defaultSearchField ? new String[]{} : new String[]{defaultSearchField};
    }
    else {
      fields = defaultFields;
    }
  }
  else if (fields.length == 1) {
    if (fields[0].contains("*")) {
      // create a Java regular expression from the wildcard string
      String fieldRegex = fields[0].replaceAll("\\*", ".*");
      Collection<String> storedHighlightFieldNames = request.getSearcher().getStoredHighlightFieldNames();
      List<String> storedFieldsToHighlight = new ArrayList<>();
      for (String storedFieldName: storedHighlightFieldNames) {
          if (storedFieldName.matches(fieldRegex)) {
            storedFieldsToHighlight.add(storedFieldName);
          }
      }
      fields = storedFieldsToHighlight.toArray(new String[] {});
    } else {
      // if there's a single request/handler value, it may be a space/comma separated list
      fields = SolrPluginUtils.split(fields[0]);
    }
  }

  return fields;
}
 
开发者ID:europeana,项目名称:search,代码行数:43,代码来源:SolrHighlighter.java

示例2: getHighlightFields

import org.apache.solr.util.SolrPluginUtils; //导入方法依赖的package包/类
/**
 * Return a String array of the fields to be highlighted.
 * Falls back to the programatic defaults, or the default search field if the list of fields
 * is not specified in either the handler configuration or the request.
 * @param query The current Query
 * @param request The current SolrQueryRequest
 * @param defaultFields Programmatic default highlight fields, used if nothing is specified in the handler config or the request.
 */
public String[] getHighlightFields(Query query, SolrQueryRequest request, String[] defaultFields) {
  String fields[] = request.getParams().getParams(HighlightParams.FIELDS);

  // if no fields specified in the request, or the handler, fall back to programmatic default, or default search field.
  if(emptyArray(fields)) {
    // use default search field if highlight fieldlist not specified.
    if (emptyArray(defaultFields)) {
      String defaultSearchField = request.getSchema().getDefaultSearchFieldName();
      fields = null == defaultSearchField ? new String[]{} : new String[]{defaultSearchField};
    }
    else {
      fields = defaultFields;
    }
  }
  else if (fields.length == 1) {
    if (fields[0].contains("*")) {
      // create a Java regular expression from the wildcard string
      String fieldRegex = fields[0].replaceAll("\\*", ".*");
      Collection<String> storedHighlightFieldNames = request.getSearcher().getStoredHighlightFieldNames();
      List<String> storedFieldsToHighlight = new ArrayList<String>();
      for (String storedFieldName: storedHighlightFieldNames) {
          if (storedFieldName.matches(fieldRegex)) {
            storedFieldsToHighlight.add(storedFieldName);
          }
      }
      fields = storedFieldsToHighlight.toArray(new String[] {});
    } else {
      // if there's a single request/handler value, it may be a space/comma separated list
      fields = SolrPluginUtils.split(fields[0]);
    }
  }

  return fields;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:43,代码来源:SolrHighlighter.java


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