Search in sources :

Example 6 with EmbeddedSolrServerConfiguration

use of org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration in project jackrabbit-oak by apache.

the class TestUtils method createSolrServer.

public static SolrClient createSolrServer() {
    try {
        File file = new File(TestUtils.class.getResource(SOLR_HOME_PATH).toURI());
        EmbeddedSolrServerConfiguration configuration = new EmbeddedSolrServerConfiguration(file.getAbsolutePath(), "oak");
        EmbeddedSolrServerProvider provider = new EmbeddedSolrServerProvider(configuration);
        return provider.getSolrServer();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : EmbeddedSolrServerConfiguration(org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration) EmbeddedSolrServerProvider(org.apache.jackrabbit.oak.plugins.index.solr.server.EmbeddedSolrServerProvider) File(java.io.File) IOException(java.io.IOException)

Example 7 with EmbeddedSolrServerConfiguration

use of org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration in project jackrabbit-oak by apache.

the class FullTextSolrSearchTest method createEmbeddedSolrServerProvider.

private EmbeddedSolrServerProvider createEmbeddedSolrServerProvider(boolean http) throws Exception {
    String tempDirectoryPath = FileUtils.getTempDirectoryPath();
    File solrHome = new File(tempDirectoryPath, "solr" + System.nanoTime());
    EmbeddedSolrServerConfiguration embeddedSolrServerConfiguration = new EmbeddedSolrServerConfiguration(solrHome.getAbsolutePath(), "oak");
    if (http) {
        embeddedSolrServerConfiguration = embeddedSolrServerConfiguration.withHttpConfiguration("/solr", 8983);
    }
    EmbeddedSolrServerProvider embeddedSolrServerProvider = embeddedSolrServerConfiguration.getProvider();
    SolrClient solrServer = embeddedSolrServerProvider.getSolrServer();
    if (storageEnabled != null && !storageEnabled) {
        // change schema.xml and reload the core
        File schemaXML = new File(solrHome.getAbsolutePath() + "/oak/conf", "schema.xml");
        InputStream inputStream = getClass().getResourceAsStream("/solr/oak/conf/schema.xml");
        String schemaString = IOUtils.toString(inputStream).replace("<dynamicField name=\"*\" type=\"text_general\" indexed=\"true\" stored=\"true\" multiValued=\"true\"/>", "<dynamicField name=\"*\" type=\"text_general\" indexed=\"true\" stored=\"false\" multiValued=\"true\"/>");
        FileOutputStream fileOutputStream = new FileOutputStream(schemaXML);
        IOUtils.copy(new StringReader(schemaString), fileOutputStream);
        fileOutputStream.flush();
        ((EmbeddedSolrServer) solrServer).getCoreContainer().reload("oak");
    }
    return embeddedSolrServerProvider;
}
Also used : EmbeddedSolrServerConfiguration(org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration) SolrClient(org.apache.solr.client.solrj.SolrClient) EmbeddedSolrServerProvider(org.apache.jackrabbit.oak.plugins.index.solr.server.EmbeddedSolrServerProvider) InputStream(java.io.InputStream) FileOutputStream(java.io.FileOutputStream) StringReader(java.io.StringReader) File(java.io.File)

Aggregations

EmbeddedSolrServerConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration)7 File (java.io.File)5 SolrClient (org.apache.solr.client.solrj.SolrClient)4 EmbeddedSolrServerProvider (org.apache.jackrabbit.oak.plugins.index.solr.server.EmbeddedSolrServerProvider)3 IOException (java.io.IOException)2 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 StringReader (java.io.StringReader)1 URI (java.net.URI)1 Nonnull (javax.annotation.Nonnull)1 RepositoryException (javax.jcr.RepositoryException)1 Activate (org.apache.felix.scr.annotations.Activate)1 DefaultSolrConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.DefaultSolrConfiguration)1 DefaultSolrConfigurationProvider (org.apache.jackrabbit.oak.plugins.index.solr.configuration.DefaultSolrConfigurationProvider)1 OakSolrConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration)1 OakSolrConfigurationProvider (org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider)1 RemoteSolrServerConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.RemoteSolrServerConfiguration)1 SolrServerConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfiguration)1 NodeStateSolrServersObserver (org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate.NodeStateSolrServersObserver)1 SolrIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.solr.index.SolrIndexEditorProvider)1