本文整理汇总了Java中org.apache.solr.core.SolrResourceLoader.openResource方法的典型用法代码示例。如果您正苦于以下问题:Java SolrResourceLoader.openResource方法的具体用法?Java SolrResourceLoader.openResource怎么用?Java SolrResourceLoader.openResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.core.SolrResourceLoader
的用法示例。
在下文中一共展示了SolrResourceLoader.openResource方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: inform
import org.apache.solr.core.SolrResourceLoader; //导入方法依赖的package包/类
@Override
public void inform( SolrCore core ) {
if (initParams != null) {
SolrResourceLoader resourceLoader = core.getResourceLoader( );
synonymsFile = (String)initParams.get( "synonyms" );
if (synonymsFile != null) {
Analyzer analyzer = new Analyzer() {
@Override
protected TokenStreamComponents createComponents(String fieldName) {
Tokenizer tokenizer = new KeywordTokenizer();
return new TokenStreamComponents(tokenizer, tokenizer );
}
};
try {
SolrSynonymParser parser = new SolrSynonymParser(true, true, analyzer);
CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder().onMalformedInput(CodingErrorAction.REPORT)
.onUnmappableCharacter(CodingErrorAction.REPORT);
parser.parse(new InputStreamReader( resourceLoader.openResource(synonymsFile), decoder));
this.synonyms = parser.build( );
}
catch ( Exception e ) {
// ???
Log.warn( "Parsing Synonyms Got Exception " + e );
}
}
String stopwordsFile = (String)initParams.get( "stopwords" );
if (stopwordsFile != null) {
this.stopwords = new HashSet<String>( );
try {
BufferedReader br = new BufferedReader( new InputStreamReader( resourceLoader.openResource( stopwordsFile )));
String line = null;
while ((line = br.readLine( )) != null) {
stopwords.add( line.toLowerCase( ) );
}
br.close( );
}
catch ( IOException ioe ) {
Log.warn( "Adding Stopwords Got Exception " + ioe );
}
}
}
core.registerFirstSearcherListener( this );
core.registerNewSearcherListener( this );
}
示例2: inform
import org.apache.solr.core.SolrResourceLoader; //导入方法依赖的package包/类
@Override
public void inform( SolrCore core ) {
if (initParams != null) {
SolrResourceLoader resourceLoader = core.getResourceLoader( );
synonymsFile = (String)initParams.get( "synonyms" );
if (synonymsFile != null) {
Analyzer analyzer = new Analyzer() {
@Override
protected TokenStreamComponents createComponents(String fieldName, Reader reader) {
Tokenizer tokenizer = new KeywordTokenizer( reader );
return new TokenStreamComponents(tokenizer, tokenizer );
}
};
try {
SolrSynonymParser parser = new SolrSynonymParser(true, true, analyzer);
CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder().onMalformedInput(CodingErrorAction.REPORT)
.onUnmappableCharacter(CodingErrorAction.REPORT);
parser.parse(new InputStreamReader( resourceLoader.openResource(synonymsFile), decoder));
this.synonyms = parser.build( );
}
catch ( Exception e ) {
// ???
Log.warn( "Parsing Synonyms Got Exception " + e );
}
}
String stopwordsFile = (String)initParams.get( "stopwords" );
if (stopwordsFile != null) {
this.stopwords = new HashSet<String>( );
try {
BufferedReader br = new BufferedReader( new InputStreamReader( resourceLoader.openResource( stopwordsFile )));
String line = null;
while ((line = br.readLine( )) != null) {
stopwords.add( line.toLowerCase( ) );
}
br.close( );
}
catch ( IOException ioe ) {
Log.warn( "Adding Stopwords Got Exception " + ioe );
}
}
}
core.registerFirstSearcherListener( this );
core.registerNewSearcherListener( this );
}
示例3: openReader
import org.apache.solr.core.SolrResourceLoader; //导入方法依赖的package包/类
public Reader openReader(SolrResourceLoader resourceLoader) throws IOException {
InputStream input = resourceLoader.openResource(fileName);
return org.apache.lucene.util.IOUtils.getDecodingReader
(input, StandardCharsets.UTF_8);
}
示例4: openReader
import org.apache.solr.core.SolrResourceLoader; //导入方法依赖的package包/类
public Reader openReader(SolrResourceLoader resourceLoader) throws IOException {
InputStream input = resourceLoader.openResource(fileName);
return org.apache.lucene.util.IOUtils.getDecodingReader
(input, org.apache.lucene.util.IOUtils.CHARSET_UTF_8);
}