Package org.apache.solr.core

Examples of org.apache.solr.core.CoreContainer$Initializer


      /* create a Solr instance to check document has been indexed as expected */
      URL solrURL = this.getClass().getResource("/org/apache/uima/solrcas/");
      System.setProperty("solr.solr.home", new File(solrURL.toURI()).getAbsolutePath());
      CoreContainer.Initializer initializer = new CoreContainer.Initializer();
      CoreContainer coreContainer = initializer.initialize();
      SolrServer solrServer = new EmbeddedSolrServer(coreContainer, "");

      ModifiableSolrParams solrParams = new ModifiableSolrParams();
      solrParams.add("q", "annotation:Francesco");
      QueryResponse queryResponse = solrServer.query(solrParams);
View Full Code Here


 
      if (solrInstanceTypeParam.equals("embedded")) {
        URI solrURI = getURI(solrPathParam);
        System.setProperty("solr.solr.home", new File(solrURI).getAbsolutePath());
        CoreContainer.Initializer initializer = new CoreContainer.Initializer();
        CoreContainer coreContainer = initializer.initialize();
        solrServer = new EmbeddedSolrServer(coreContainer, "");
      }
    } catch (Exception e){
      throw new SolrServerException(e);
    }
View Full Code Here

                    "Unable to copy default configuration for the manages Solr " +
                    "Directory to the configured path '%s'!",
                     managedSolrDir.getAbsoluteFile()), e);
            }
        }
        server = new CoreContainer(managedSolrDir.getAbsolutePath());
        //File solrXml = new File(managedSolrDir,"solr.xml");
        server.load();
    }   
View Full Code Here

    @Override
    public SolrServer addingService(ServiceReference reference) {
        log.info(" ... in addingService for {} (ref: {})",
            this.reference,reference);
        String coreName;
        CoreContainer server;
        Object service = super.addingService(reference);
        if(service == null){
            log.warn("addingService({}) returned null -> unable to create " +
                "EmbeddedSolrServer for IndexReference {}",reference,this.reference);
        }
View Full Code Here

        //create a clone so that only we control who changes to the properties
        serverProperties = parsedServerProperties.clone();

        File solrCof = new File(solrDir,parsedServerProperties.getSolrXml());
        ClassLoader classLoader = updateContextClassLoader();
        CoreContainer container;
        try {
            log.info("   ... create OSGI enabled SolrCore (conf: {}",solrCof);
            SolrResourceLoader loader = new OsgiSolrResourceLoader(context, solrDir.getAbsolutePath(),
                SolrServerAdapter.class.getClassLoader());
            container = new OsgiCoreContainer(loader, context,solrCof);
        } finally {
            Thread.currentThread().setContextClassLoader(classLoader);
        }
        this.server = container;
        this.registrations = Collections.synchronizedMap(
            new HashMap<String,CoreRegistration>());
        String serverName = serverProperties.getServerName();
        if(serverName == null){
            //set the name to the absolute path of the solr dir
            serverProperties.setServerName(solrDir.getAbsolutePath());
        }
        //now load the cores
        classLoader = updateContextClassLoader();
        try {
            container.load();
            log.info("      - loaded SolrConfig {}",solrCof);
        } finally {
            Thread.currentThread().setContextClassLoader(classLoader);
        }
        //add the currently available cores to the properties
View Full Code Here

        }
        IOUtils.copy(is, new FileOutputStream(solrConfigFile));

        // create the embedded server
        SolrResourceLoader loader = new SolrResourceLoader(solrFolder.getAbsolutePath());
        CoreContainer coreContainer = new CoreContainer(loader);
        //NOTE: with Solr 4.4 we need to call coreContainer.load() otherwise we
        //would be affected by the issue stated at
        //http://mail-archives.apache.org/mod_mbox/lucene-solr-user/201301.mbox/%3CB7B8B36F1A0BE24F842758C318E56E925EB334%40EXCHDB2.na1.ad.group%3E
        //while this was introduced with 4.1 this only affects this code with 4.4
        //as with an API change the methods implicitly calling load() where
        //removed.
        coreContainer.load();
        CoreDescriptor coreDescriptor = new CoreDescriptor(coreContainer, coreId,
                solrCoreFolder.getAbsolutePath());
        SolrCore core = coreContainer.create(coreDescriptor);
//        coreContainer.createAndLoad(solrHome, configFile)load();
        coreContainer.register(coreId, core, true);
        return new EmbeddedSolrServer(coreContainer, coreId);
    }
View Full Code Here

        flow.complete();

        // Open up the Solr index, and do some searches.
        System.setProperty("solr.data.dir", out + "/part-00000");

        CoreContainer coreContainer = new CoreContainer(SOLR_HOME_DIR);
        coreContainer.load();
        SolrServer solrServer = new EmbeddedSolrServer(coreContainer, "");

        ModifiableSolrParams params = new ModifiableSolrParams();
        params.set(CommonParams.Q, "turbowriter");
View Full Code Here

       
        System.setProperty(dataDirPropertyName, tmpDataDir.getAbsolutePath());
        System.setProperty("enable.special-handlers", "false"); // All we need is the update request handler
        System.setProperty("enable.cache-warming", "false"); // We certainly don't need to warm the cache
       
        CoreContainer coreContainer = new CoreContainer(tmpSolrHome.getAbsolutePath());
       
        try {
            coreContainer.load();
            Collection<SolrCore> cores = coreContainer.getCores();
            SolrCore core = null;
           
            if (cores.size() == 0) {
                throw new TapException("No Solr cores are available");
            } else if (cores.size() > 1) {
                throw new TapException("Only one Solr core is supported");
            } else {
                core = cores.iterator().next();
            }

            IndexSchema schema = core.getLatestSchema();
            Map<String, SchemaField> solrFields = schema.getFields();
            Set<String> schemeFieldnames = new HashSet<String>();

            for (int i = 0; i < schemeFields.size(); i++) {
                String fieldName = schemeFields.get(i).toString();
                if (!solrFields.containsKey(fieldName)) {
                    throw new TapException("Sink field name doesn't exist in Solr schema: " + fieldName);
                }
               
                schemeFieldnames.add(fieldName);
            }

            for (String solrFieldname : solrFields.keySet()) {
                SchemaField solrField = solrFields.get(solrFieldname);
                if (solrField.isRequired() && !schemeFieldnames.contains(solrFieldname)) {
                    throw new TapException("No sink field name for required Solr field: " + solrFieldname);
                }
            }
        } finally {
            if (coreContainer != null) {
                coreContainer.shutdown();
            }
        }
    }
View Full Code Here

        try {
            System.setProperty(dataDirPropertyName, dataDir);
            System.setProperty("enable.special-handlers", "false"); // All we need is the update request handler
            System.setProperty("enable.cache-warming", "false"); // We certainly don't need to warm the cache
            File solrHome = SolrSchemeUtil.makeTempSolrHome(solrCoreDir);
            _coreContainer = new CoreContainer(solrHome.getAbsolutePath());
            _coreContainer.load();
            _solrServer = new EmbeddedSolrServer(_coreContainer, solrCoreDir.getName());
        } catch (Exception e) {
            if (_coreContainer != null) {
                _coreContainer.shutdown();
View Full Code Here

        delete(baseDir);
        writeIndexGeneration(baseDir);
      }
      createSolrConfig(baseDir);
      String solrDataDir = baseDir.toString();
      solrContainer = new CoreContainer(solrDataDir);
      CoreDescriptor descriptor = new CoreDescriptor(solrContainer, "Eclipse Web Search", solrDataDir); //$NON-NLS-1$
      descriptor.setDataDir(solrDataDir.toString() + File.separatorChar + "data"); //$NON-NLS-1$
      solrCore = solrContainer.create(descriptor);
      solrContainer.register(solrCore, false);
      server = new EmbeddedSolrServer(solrContainer, "Eclipse Web Search"); //$NON-NLS-1$
View Full Code Here

TOP

Related Classes of org.apache.solr.core.CoreContainer$Initializer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.