Search in sources :

Example 1 with EmbeddedSolrServerProvider

use of org.apache.jackrabbit.oak.plugins.index.solr.server.EmbeddedSolrServerProvider in project jackrabbit-oak by apache.

the class SolrServerConfigurationTest method testCreteEmbeddedServerFromConfig.

@Test
public void testCreteEmbeddedServerFromConfig() throws Exception {
    SolrServerConfiguration<EmbeddedSolrServerProvider> embeddedSolrServerSolrServerConfiguration = new EmbeddedSolrServerConfiguration(null, null);
    EmbeddedSolrServerProvider embeddedSolrServerProvider = embeddedSolrServerSolrServerConfiguration.getProvider();
    assertNotNull(embeddedSolrServerProvider);
}
Also used : EmbeddedSolrServerProvider(org.apache.jackrabbit.oak.plugins.index.solr.server.EmbeddedSolrServerProvider) Test(org.junit.Test)

Example 2 with EmbeddedSolrServerProvider

use of org.apache.jackrabbit.oak.plugins.index.solr.server.EmbeddedSolrServerProvider in project jackrabbit-oak by apache.

the class SolrOakRepositoryStub method preCreateRepository.

@Override
protected void preCreateRepository(Jcr jcr) {
    File f = new File("target" + File.separatorChar + "queryjcrtest-" + System.currentTimeMillis());
    final SolrClient solrServer;
    try {
        solrServer = new EmbeddedSolrServerProvider(new EmbeddedSolrServerConfiguration(f.getPath(), "oak")).getSolrServer();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    SolrServerProvider solrServerProvider = new SolrServerProvider() {

        @Override
        public void close() throws IOException {
        }

        @CheckForNull
        @Override
        public SolrClient getSolrServer() throws Exception {
            return solrServer;
        }

        @Override
        public SolrClient getIndexingSolrServer() throws Exception {
            return solrServer;
        }

        @Override
        public SolrClient getSearchingSolrServer() throws Exception {
            return solrServer;
        }
    };
    try {
        assertNotNull(solrServer);
        // safely remove any previous document on the index
        solrServer.deleteByQuery("*:*");
        solrServer.commit();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    OakSolrConfiguration configuration = new DefaultSolrConfiguration() {

        @Nonnull
        @Override
        public CommitPolicy getCommitPolicy() {
            return CommitPolicy.HARD;
        }
    };
    OakSolrConfigurationProvider oakSolrConfigurationProvider = new DefaultSolrConfigurationProvider(configuration);
    jcr.with(new SolrIndexInitializer(false)).with(AggregateIndexProvider.wrap(new SolrQueryIndexProvider(solrServerProvider, oakSolrConfigurationProvider))).with(new NodeStateSolrServersObserver()).with(new SolrIndexEditorProvider(solrServerProvider, oakSolrConfigurationProvider));
}
Also used : EmbeddedSolrServerConfiguration(org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration) DefaultSolrConfigurationProvider(org.apache.jackrabbit.oak.plugins.index.solr.configuration.DefaultSolrConfigurationProvider) OakSolrConfiguration(org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration) SolrIndexInitializer(org.apache.jackrabbit.oak.plugins.index.solr.util.SolrIndexInitializer) IOException(java.io.IOException) RepositoryException(javax.jcr.RepositoryException) OakSolrConfigurationProvider(org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider) SolrClient(org.apache.solr.client.solrj.SolrClient) EmbeddedSolrServerProvider(org.apache.jackrabbit.oak.plugins.index.solr.server.EmbeddedSolrServerProvider) SolrServerProvider(org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider) SolrQueryIndexProvider(org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndexProvider) EmbeddedSolrServerProvider(org.apache.jackrabbit.oak.plugins.index.solr.server.EmbeddedSolrServerProvider) NodeStateSolrServersObserver(org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate.NodeStateSolrServersObserver) DefaultSolrConfiguration(org.apache.jackrabbit.oak.plugins.index.solr.configuration.DefaultSolrConfiguration) File(java.io.File) SolrIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.solr.index.SolrIndexEditorProvider)

Example 3 with EmbeddedSolrServerProvider

use of org.apache.jackrabbit.oak.plugins.index.solr.server.EmbeddedSolrServerProvider 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 4 with EmbeddedSolrServerProvider

use of org.apache.jackrabbit.oak.plugins.index.solr.server.EmbeddedSolrServerProvider 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

EmbeddedSolrServerProvider (org.apache.jackrabbit.oak.plugins.index.solr.server.EmbeddedSolrServerProvider)4 File (java.io.File)3 EmbeddedSolrServerConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration)3 IOException (java.io.IOException)2 SolrClient (org.apache.solr.client.solrj.SolrClient)2 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 StringReader (java.io.StringReader)1 RepositoryException (javax.jcr.RepositoryException)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 NodeStateSolrServersObserver (org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate.NodeStateSolrServersObserver)1 SolrIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.solr.index.SolrIndexEditorProvider)1 SolrQueryIndexProvider (org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndexProvider)1 SolrServerProvider (org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider)1 SolrIndexInitializer (org.apache.jackrabbit.oak.plugins.index.solr.util.SolrIndexInitializer)1 Test (org.junit.Test)1