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


Java SolrCore.getSolrConfig方法代码示例

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


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

示例1: DirectSolrConnection

import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
/**
 * Initialize using an explicit SolrCore
 */
public DirectSolrConnection( SolrCore c )
{
  core = c;
  parser = new SolrRequestParsers( c.getSolrConfig() );
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:DirectSolrConnection.java

示例2: create

import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
@Override
public Lookup create(NamedList params, SolrCore core) {
  // mandatory parameter
  Object fieldTypeName = params.get(QUERY_ANALYZER);
  if (fieldTypeName == null) {
    throw new IllegalArgumentException("Error in configuration: " + QUERY_ANALYZER + " parameter is mandatory");
  }
  FieldType ft = core.getLatestSchema().getFieldTypeByName(fieldTypeName.toString());
  if (ft == null) {
    throw new IllegalArgumentException("Error in configuration: " + fieldTypeName.toString() + " is not defined in the schema");
  }
  Analyzer indexAnalyzer = ft.getIndexAnalyzer();
  Analyzer queryAnalyzer = ft.getQueryAnalyzer();
  
  // optional parameters
  
  String indexPath = params.get(INDEX_PATH) != null
  ? params.get(INDEX_PATH).toString()
  : DEFAULT_INDEX_PATH;
  if (new File(indexPath).isAbsolute() == false) {
    indexPath = core.getDataDir() + File.separator + indexPath;
  }
  
  int minPrefixChars = params.get(MIN_PREFIX_CHARS) != null
  ? Integer.parseInt(params.get(MIN_PREFIX_CHARS).toString())
  : AnalyzingInfixSuggester.DEFAULT_MIN_PREFIX_CHARS;

  BlenderType blenderType = getBlenderType(params.get(BLENDER_TYPE));
  
  int numFactor = params.get(NUM_FACTOR) != null
  ? Integer.parseInt(params.get(NUM_FACTOR).toString())
  : BlendedInfixSuggester.DEFAULT_NUM_FACTOR;
  
  try {
    return new BlendedInfixSuggester(core.getSolrConfig().luceneMatchVersion, 
                                     FSDirectory.open(new File(indexPath)),
                                     indexAnalyzer, queryAnalyzer, minPrefixChars,
                                     blenderType, numFactor) {
      @Override
      public List<LookupResult> lookup(CharSequence key, Set<BytesRef> contexts, int num, boolean allTermsRequired, boolean doHighlight) throws IOException {
        List<LookupResult> res = super.lookup(key, contexts, num, allTermsRequired, doHighlight);
        if (doHighlight) {
          List<LookupResult> res2 = new ArrayList<>();
          for(LookupResult hit : res) {
            res2.add(new LookupResult(hit.highlightKey.toString(),
                                      hit.highlightKey,
                                      hit.value,
                                      hit.payload,
                                      hit.contexts));
          }
          res = res2;
        }

        return res;
      }
    };
  } catch (IOException e) {
    throw new RuntimeException();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:61,代码来源:BlendedInfixLookupFactory.java

示例3: create

import org.apache.solr.core.SolrCore; //导入方法依赖的package包/类
@Override
public Lookup create(NamedList params, SolrCore core) {
  // mandatory parameter
  Object fieldTypeName = params.get(QUERY_ANALYZER);
  if (fieldTypeName == null) {
    throw new IllegalArgumentException("Error in configuration: " + QUERY_ANALYZER + " parameter is mandatory");
  }
  FieldType ft = core.getLatestSchema().getFieldTypeByName(fieldTypeName.toString());
  if (ft == null) {
    throw new IllegalArgumentException("Error in configuration: " + fieldTypeName.toString() + " is not defined in the schema");
  }
  Analyzer indexAnalyzer = ft.getIndexAnalyzer();
  Analyzer queryAnalyzer = ft.getQueryAnalyzer();
  
  // optional parameters
  
  String indexPath = params.get(INDEX_PATH) != null
  ? params.get(INDEX_PATH).toString()
  : DEFAULT_INDEX_PATH;
  if (new File(indexPath).isAbsolute() == false) {
    indexPath = core.getDataDir() + File.separator + indexPath;
  }
  
  int minPrefixChars = params.get(MIN_PREFIX_CHARS) != null
  ? Integer.parseInt(params.get(MIN_PREFIX_CHARS).toString())
  : AnalyzingInfixSuggester.DEFAULT_MIN_PREFIX_CHARS;

  try {
    return new AnalyzingInfixSuggester(core.getSolrConfig().luceneMatchVersion, 
                                       FSDirectory.open(new File(indexPath)), indexAnalyzer,
                                       queryAnalyzer, minPrefixChars) {
      @Override
      public List<LookupResult> lookup(CharSequence key, Set<BytesRef> contexts, int num, boolean allTermsRequired, boolean doHighlight) throws IOException {
        List<LookupResult> res = super.lookup(key, contexts, num, allTermsRequired, doHighlight);
        if (doHighlight) {
          List<LookupResult> res2 = new ArrayList<>();
          for(LookupResult hit : res) {
            res2.add(new LookupResult(hit.highlightKey.toString(),
                                      hit.highlightKey,
                                      hit.value,
                                      hit.payload,
                                      hit.contexts));
          }
          res = res2;
        }

        return res;
      }
    };
  } catch (IOException e) {
    throw new RuntimeException();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:54,代码来源:AnalyzingInfixLookupFactory.java


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