Thank you for the inputs Jorge. Now i am getting the ResourceLoader using SolrCore API.
Before: return new HashSet<String>(new SolrResourceLoader(null). getLines("stopwords.txt")); After: return new HashSet<String>(core.getResourceLoader().getLines( "stopwords.txt")); I am able to load the resource successfully. Thanks, Ramana. On Wed, Sep 10, 2014 at 12:34 PM, Jorge Luis Betancourt Gonzalez < jlbetanco...@uci.cu> wrote: > What are you developing a custom search component? update processor? a > different class for one of the zillion moving parts of Solr? > > If you have access to a SolrCore instance you could use it to get access > of, essentially using the SolrCore instance specific to the current core > will cause the lookup of the file to be local to the conf directory of the > specified core. In a custom UpdateRequestProcessorFactory which implements > the SolrCoreAware interface I’ve the following code: > > @Override > public void inform(SolrCore solrCore) { > SolrResourceLoader loader = solrCore.getResourceLoader(); > > try { > List<String> lines = loader.getLines(patternFile); > > if (false == lines.isEmpty()) { > for (String s : lines) { > this.patterns.add(Pattern.compile(s)); > } > } > } catch (IOException e) { > SolrCore.log.error(String.format("File %s could not be loaded", > patternFile)); > } > > Essentially I ask the actually core (solrCore) to provide a > SolrResourceLoader for it’s conf file, in your case you are just passing it > null, which is causing (I think, haven’t tested) to instantiate a > SolrResourceLoader of the Solr instance (judging for the paths you’ve > placed in your mail) instead of a SolrResourceLoader relative to your > core/collection that is what you want. > > So, bottom line implement the SolrCoreAware interface and use the > SolrResourceLoader provided by this instance, and a little more info could > be helpful as we can’t figure what Solr “part” are you developing. > > Regards, > > On Sep 9, 2014, at 2:37 PM, Ramana OpenSource <ramanaopensou...@gmail.com> > wrote: > > > Hi, > > > > I am trying to load one of the file in conf directory in SOLR, using > below > > code. > > > > return new HashSet<String>(new > > SolrResourceLoader(null).getLines("stopwords.txt")); > > > > The "stopwords.txt" file is available in the location > > "solr\example\solr\collection1\conf". > > > > When i debugged the SolrResourceLoader API, It is looking at the below > > locations to load the file: > > > > ...solr\example\solr\conf\stopwords.txt > > ...solr\example\stopwords.txt > > > > But as the file was not there in any of above location...it failed. > > > > How to load the files in the default conf directory using > > SolrResourceLoader API ? > > > > I am newbie to SOLR. Any help would be appreciated. > > > > Thanks, > > Ramana. > > Concurso "Mi selfie por los 5". Detalles en > http://justiciaparaloscinco.wordpress.com >