/** * Constructs a schema using the specified resource name and stream. * If the is stream is null, the resource loader will load the schema resource by name. * @see SolrResourceLoader#openSchema * By default, this follows the normal config path directory searching rules. * @see Config#openResource */ public IndexSchema(SolrConfig solrConfig, String name, InputStream is) { this.solrConfig = solrConfig; if (name == null) name = DEFAULT_SCHEMA_FILE; this.resourceName = name; loader = solrConfig.getResourceLoader(); InputStream lis = is; if (lis == null) lis = loader.openSchema(name); readSchema(lis); if (lis != is) { try { lis.close(); } catch(IOException xio) {} // ignore } loader.inform( loader ); }
SolrResourceLoader loader = new SolrResourceLoader(Paths.get(mySolrHomeDir)); SolrConfig solrConfig = new SolrConfig(loader, "solrconfig.xml", null); InputSource is = new InputSource(loader.openSchema("schema.xml")); is.setSystemId(SystemIdResolver.createSystemIdFromResourceName("schema.xml"));
SolrResourceLoader loader = new SolrResourceLoader(mySolrHomeDir); SolrConfig solrConfig = new SolrConfig(loader, "solrconfig.xml", null); InputSource is = new InputSource(loader.openSchema("schema.xml")); is.setSystemId(SystemIdResolver.createSystemIdFromResourceName("schema.xml"));