List of usage examples for org.apache.solr.core SolrConfig DEFAULT_CONF_FILE
String DEFAULT_CONF_FILE
To view the source code for org.apache.solr.core SolrConfig DEFAULT_CONF_FILE.
Click Source Link
From source file:com.ngdata.hbaseindexer.util.solr.SolrConfigLoader.java
License:Apache License
/** * Load a {@code SolrConfig} from ZooKeeper. * <p>//from w ww . j a va 2s . co m * The returned SolrConfig will include this instance as its {@code SolrResourceLoader}. */ public SolrConfig loadSolrConfig() throws ParserConfigurationException, IOException, SAXException { return new SolrConfig(this, SolrConfig.DEFAULT_CONF_FILE, null); }
From source file:org.dyndns.andreasbaumann.LuceneAnalyzer.java
License:Open Source License
public static void main(String[] args) throws IOException { CmdLineParser parser = new CmdLineParser(); // default options, well-known, should always be around Option verbose = addHelp(parser.addBooleanOption('v', "verbose"), "print extra verbosity information"); Option help = addHelp(parser.addBooleanOption('h', "help"), "print this help message"); Option version = addHelp(parser.addBooleanOption("version"), "print version information"); Option globals = addHelp(parser.addBooleanOption('g', "globals"), "print global statistics"); Option fields = addHelp(parser.addBooleanOption('f', "fields"), "print field information"); Option terms = addHelp(parser.addBooleanOption('t', "terms"), "print statistics per term"); Option headers = addHelp(parser.addBooleanOption('H', "headers"), "print headers for sections"); Option solr = addHelp(parser.addBooleanOption('s', "solr"), "treat index as a Solr index, indexDir is the Solr base dir"); // read the command line options try {/*from w w w .j a v a2 s .c om*/ parser.parse(args); } catch (OptionException e) { System.err.println(e.getMessage()); printUsage(); System.exit(1); } if ((Boolean) parser.getOptionValue(help, Boolean.FALSE)) { printUsage(); System.exit(0); } if ((Boolean) parser.getOptionValue(version, Boolean.FALSE)) { printVersion(); System.exit(0); } // verbosity as a level, increased with -vvv int verbosity = 0; while (true) { Boolean verboseValue = (Boolean) parser.getOptionValue(verbose); if (verboseValue == null) { break; } else { verbosity++; } } boolean printHeaders = false; if ((Boolean) parser.getOptionValue(headers, Boolean.FALSE)) { printHeaders = true; } boolean isSolr = false; if ((Boolean) parser.getOptionValue(solr, Boolean.FALSE)) { isSolr = true; } // read command line arguments String[] otherArgs = parser.getRemainingArgs(); if (otherArgs.length != 1) { System.err.println("Missing a lucene index directory as first argument"); printUsage(); System.exit(1); } String basePath = otherArgs[0]; String indexPath = otherArgs[0]; if (isSolr) { indexPath += "/data/index"; } File indexDir = new File(indexPath); if (!indexDir.exists()) { System.err.println(indexPath + " doesn't exist"); System.exit(1); } if (!indexDir.isDirectory()) { System.err.println(indexPath + " is not a directory"); System.exit(1); } SolrIndexSearcher solrSearcher = null; Directory luceneDirectory = new SimpleFSDirectory(indexDir); IndexReader indexReader = IndexReader.open(luceneDirectory); if (isSolr) { try { Properties p = System.getProperties(); p.setProperty("solr.solr.home", basePath); CoreContainer cores = new CoreContainer(new SolrResourceLoader(basePath)); SolrConfig solrConfig = new SolrConfig(basePath, SolrConfig.DEFAULT_CONF_FILE, null); CoreDescriptor descrCore = new CoreDescriptor(cores, "", solrConfig.getResourceLoader().getInstanceDir()); IndexSchema solrSchema = new IndexSchema(solrConfig, basePath + "/conf/schema.xml", null); SolrCore solrCore = new SolrCore(basePath, solrSchema); solrSearcher = new SolrIndexSearcher(solrCore, solrSchema, "test", luceneDirectory, true, false); } catch (javax.xml.parsers.ParserConfigurationException e) { System.err.println("Illegal Solr configuration: " + e); System.exit(1); } catch (org.xml.sax.SAXException e) { System.err.println("Illegal Solr configuration: " + e); System.exit(1); } } if ((Boolean) parser.getOptionValue(globals, Boolean.FALSE)) { printGlobalInfo(indexReader, printHeaders, isSolr, solrSearcher); } if ((Boolean) parser.getOptionValue(fields, Boolean.FALSE)) { printFieldInfo(indexReader, printHeaders, isSolr, solrSearcher); } if ((Boolean) parser.getOptionValue(terms, Boolean.FALSE)) { printTerms(indexReader, printHeaders, isSolr, solrSearcher, verbosity == 1, verbosity >= 2); } indexReader.close(); System.exit(0); }
From source file:org.opencastproject.solr.SolrServerFactory.java
License:Educational Community License
/** * Constructor. Prepares solr connection. * /*from w w w. jav a 2 s . c o m*/ * @param solrDir * The directory of the solr instance. * @param dataDir * The directory of the solr index data. */ public static SolrServer newEmbeddedInstance(File solrDir, File dataDir) throws SolrServerException { try { final CoreContainer cc = new CoreContainer(solrDir.getAbsolutePath()); SolrConfig config = new OpencastSolrConfig(solrDir.getAbsolutePath(), SolrConfig.DEFAULT_CONF_FILE, null); IndexSchema schema = new IndexSchema(config, solrDir + "/conf/schema.xml", null); SolrCore core0 = new SolrCore(null, dataDir.getAbsolutePath(), config, schema, null); cc.register("core0", core0, false); return new EmbeddedSolrServerWrapper(cc, "core0"); } catch (Exception e) { throw new SolrServerException(e); } }
From source file:org.opencms.search.solr.CmsSolrConfiguration.java
License:Open Source License
/** * Returns the solr configuration file, default: <code>'conf/solrconfig.xml'</code>.<p> * * @return the solr configuration file/*ww w . j a v a 2s . c om*/ */ public File getSolrConfigFile() { return new File(getHome() + DEFAULT_CONFIGSET_FOLDER + CONF_FOLDER + SolrConfig.DEFAULT_CONF_FILE); }
From source file:org.solbase.SolbaseInitializer.java
License:Apache License
@Override public CoreContainer initialize() throws IOException, ParserConfigurationException, SAXException { CoreContainer cores = new SolbaseCoreContainer( solrConfigFilename == null ? SolrConfig.DEFAULT_CONF_FILE : solrConfigFilename); return cores; }