當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。