use of org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndexProvider in project jackrabbit-oak by apache.
the class SolrQueryIndexProviderService method activate.
@SuppressWarnings("UnusedDeclaration")
@Activate
protected void activate(ComponentContext componentContext) {
Object value = componentContext.getProperties().get(QUERY_TIME_AGGREGATION);
boolean queryTimeAggregation = PropertiesUtil.toBoolean(value, QUERY_TIME_AGGREGATION_DEFAULT);
if (solrServerProvider != null && oakSolrConfigurationProvider != null) {
QueryIndexProvider solrQueryIndexProvider = new SolrQueryIndexProvider(solrServerProvider, oakSolrConfigurationProvider, nodeAggregator);
log.debug("creating Solr query index provider {} query time aggregation", queryTimeAggregation ? "with" : "without");
if (queryTimeAggregation) {
solrQueryIndexProvider = AggregateIndexProvider.wrap(solrQueryIndexProvider);
}
regs.add(componentContext.getBundleContext().registerService(QueryIndexProvider.class.getName(), solrQueryIndexProvider, null));
}
}
use of org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndexProvider in project jackrabbit-oak by apache.
the class SolrOakRepositoryStub method preCreateRepository.
@Override
protected void preCreateRepository(Jcr jcr) {
String path = getClass().getResource("/").getFile() + "/queryjcrtest";
File f = new File(path);
final SolrServer solrServer;
try {
solrServer = new EmbeddedSolrServerProvider(new EmbeddedSolrServerConfiguration(f.getPath(), "oak")).getSolrServer();
} catch (Exception e) {
throw new RuntimeException();
}
SolrServerProvider solrServerProvider = new SolrServerProvider() {
@Override
public void close() throws IOException {
}
@CheckForNull
@Override
public SolrServer getSolrServer() throws Exception {
return solrServer;
}
@Override
public SolrServer getIndexingSolrServer() throws Exception {
return solrServer;
}
@Override
public SolrServer getSearchingSolrServer() throws Exception {
return solrServer;
}
};
try {
// 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));
}
use of org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndexProvider in project jackrabbit-oak by apache.
the class SolrBaseTest method setUp.
@Before
public void setUp() throws Exception {
store = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
provider = new TestUtils();
server = provider.getSolrServer();
configuration = provider.getConfiguration();
hook = new EditorHook(new IndexUpdateProvider(new SolrIndexEditorProvider(provider, provider)));
Oak oak = new Oak().with(new InitialContent()).with(new OpenSecurityProvider()).with(// synchronous
new SolrIndexInitializer(false)).with(new SolrQueryIndexProvider(provider, provider)).with(new NodeStateSolrServersObserver()).with(new SolrIndexEditorProvider(provider, provider));
repository = oak.createContentRepository();
}
Aggregations