Java 类org.apache.lucene.search.suggest.FileDictionary 实例源码

项目:search    文件:FileDictionaryFactory.java   
@Override
public Dictionary create(SolrCore core, SolrIndexSearcher searcher) {
  if (params == null) {
    // should not happen; implies setParams was not called
    throw new IllegalStateException("Value of params not set");
  }

  String sourceLocation = (String)params.get(Suggester.LOCATION);

  if (sourceLocation == null) {
    throw new IllegalArgumentException(Suggester.LOCATION + " parameter is mandatory for using FileDictionary");
  }

  String fieldDelimiter = (params.get(FIELD_DELIMITER) != null)
      ? (String) params.get(FIELD_DELIMITER) : 
      FileDictionary.DEFAULT_FIELD_DELIMITER;

  try {
    return new FileDictionary(new InputStreamReader(
        core.getResourceLoader().openResource(sourceLocation), StandardCharsets.UTF_8), fieldDelimiter);
  } catch (IOException e) {
    throw new RuntimeException();
  }
}
项目:read-open-source-code    文件:FileDictionaryFactory.java   
@Override
public Dictionary create(SolrCore core, SolrIndexSearcher searcher) {
  if (params == null) {
    // should not happen; implies setParams was not called
    throw new IllegalStateException("Value of params not set");
  }

  String sourceLocation = (String)params.get(Suggester.LOCATION);

  if (sourceLocation == null) {
    throw new IllegalArgumentException(Suggester.LOCATION + " parameter is mandatory for using FileDictionary");
  }

  String fieldDelimiter = (params.get(FIELD_DELIMITER) != null)
      ? (String) params.get(FIELD_DELIMITER) : 
      FileDictionary.DEFAULT_FIELD_DELIMITER;

  try {
    return new FileDictionary(new InputStreamReader(
        core.getResourceLoader().openResource(sourceLocation), IOUtils.CHARSET_UTF_8), fieldDelimiter);
  } catch (IOException e) {
    throw new RuntimeException();
  }
}
项目:read-open-source-code    文件:FileDictionaryFactory.java   
@Override
public Dictionary create(SolrCore core, SolrIndexSearcher searcher) {
  if (params == null) {
    // should not happen; implies setParams was not called
    throw new IllegalStateException("Value of params not set");
  }

  String sourceLocation = (String)params.get(Suggester.LOCATION);

  if (sourceLocation == null) {
    throw new IllegalArgumentException(Suggester.LOCATION + " parameter is mandatory for using FileDictionary");
  }

  String fieldDelimiter = (params.get(FIELD_DELIMITER) != null)
      ? (String) params.get(FIELD_DELIMITER) : 
      FileDictionary.DEFAULT_FIELD_DELIMITER;

  try {
    return new FileDictionary(new InputStreamReader(
        core.getResourceLoader().openResource(sourceLocation), StandardCharsets.UTF_8), fieldDelimiter);
  } catch (IOException e) {
    throw new RuntimeException();
  }
}