You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2025/05/22 10:14:08 UTC
(jackrabbit-oak) 01/01: OAK-11346: remove oak-solr
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch OAK-11346
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit 9dd1468c02e7c1d5d0dee8957f795d0b2aa04979
Author: Julian Reschke <re...@apache.org>
AuthorDate: Thu May 22 11:13:42 2025 +0100
OAK-11346: remove oak-solr
---
oak-solr-core/pom.xml | 313 -----
.../configuration/DefaultSolrConfiguration.java | 147 --
.../DefaultSolrConfigurationProvider.java | 44 -
.../solr/configuration/OakSolrConfiguration.java | 205 ---
.../OakSolrConfigurationDefaults.java | 48 -
.../OakSolrConfigurationProvider.java | 36 -
.../RemoteSolrServerConfiguration.java | 97 --
.../configuration/SolrServerConfiguration.java | 73 -
.../SolrServerConfigurationDefaults.java | 43 -
.../SolrServerConfigurationProvider.java | 38 -
.../NodeStateSolrServerConfigurationProvider.java | 126 --
.../nodestate/NodeStateSolrServerProvider.java | 93 --
.../nodestate/NodeStateSolrServersObserver.java | 132 --
.../nodestate/OakSolrNodeStateConfiguration.java | 274 ----
.../plugins/index/solr/index/SolrIndexEditor.java | 329 -----
.../index/solr/index/SolrIndexEditorProvider.java | 109 --
.../osgi/NodeStateSolrServersObserverService.java | 106 --
.../osgi/OakSolrConfigurationProviderService.java | 352 -----
.../RemoteSolrServerConfigurationProvider.java | 135 --
.../solr/osgi/SolrIndexEditorProviderService.java | 67 -
.../solr/osgi/SolrQueryIndexProviderService.java | 117 --
.../index/solr/osgi/SolrServerProviderService.java | 199 ---
.../index/solr/query/FilterQueryParser.java | 401 ------
.../plugins/index/solr/query/SolrIndexLookup.java | 89 --
.../plugins/index/solr/query/SolrQueryIndex.java | 834 -----------
.../index/solr/query/SolrQueryIndexProvider.java | 59 -
.../solr/server/DefaultSolrServerProvider.java | 89 --
.../plugins/index/solr/server/OakSolrServer.java | 97 --
.../solr/server/RemoteSolrServerProvider.java | 258 ----
.../index/solr/server/SolrServerProvider.java | 60 -
.../index/solr/server/SolrServerRegistry.java | 98 --
.../index/solr/util/NodeTypeIndexingUtils.java | 66 -
.../index/solr/util/SolrIndexInitializer.java | 112 --
.../oak/plugins/index/solr/util/SolrUtils.java | 70 -
.../src/main/resources/solr/oak/conf/schema.xml | 153 ---
.../main/resources/solr/oak/conf/solrconfig.xml | 353 -----
.../src/main/resources/solr/oak/core.properties | 16 -
oak-solr-core/src/main/resources/solr/solr.xml | 45 -
oak-solr-core/src/main/resources/solr/zoo.cfg | 32 -
.../jackrabbit/oak/jcr/SolrOakRepositoryStub.java | 112 --
.../apache/jackrabbit/oak/jcr/query/FacetTest.java | 259 ----
.../oak/jcr/query/QueryFulltextTest.java | 162 ---
.../jackrabbit/oak/jcr/query/QueryJcrTest.java | 96 --
.../jackrabbit/oak/jcr/query/SpellcheckTest.java | 108 --
.../jackrabbit/oak/jcr/query/SuggestTest.java | 105 --
.../oak/jcr/query/TextExtractionQueryTest.java | 99 --
.../oak/plugins/index/solr/SolrBaseTest.java | 88 --
.../oak/plugins/index/solr/TestUtils.java | 122 --
.../DefaultAnalyzersConfigurationTest.java | 265 ----
.../EmbeddedSolrServerConfiguration.java | 107 --
.../configuration/SolrServerConfigurationTest.java | 47 -
.../OakSolrNodeStateConfigurationTest.java | 88 --
.../index/solr/index/SolrIndexEditorIT.java | 76 -
.../index/solr/index/SolrIndexEditorTest.java | 103 --
.../EmbeddedSolrServerConfigurationProvider.java | 96 --
.../index/solr/query/FilterQueryParserTest.java | 94 --
.../oak/plugins/index/solr/query/SolrIndexIT.java | 701 ----------
.../index/solr/query/SolrIndexLookupTest.java | 103 --
.../index/solr/query/SolrQueryIndexTest.java | 469 -------
.../index/solr/query/SubtreeSolrIndexIT.java | 107 --
.../solr/server/EmbeddedSolrServerProvider.java | 282 ----
.../server/EmbeddedSolrServerProviderTest.java | 60 -
.../solr/server/RemoteSolrServerProviderIT.java | 77 --
.../index/solr/util/NodeTypeIndexingUtilsTest.java | 74 -
oak-solr-core/src/test/resources/logback-test.xml | 39 -
.../org/apache/jackrabbit/oak/jcr/query/test.rtf | 157 ---
.../org/apache/jackrabbit/oak/jcr/query/test.txt | 3 -
.../apache/jackrabbit/oak/query/native_solr.txt | 57 -
.../test/resources/repositoryStubImpl.properties | 533 -------
.../src/test/resources/solr/oak/conf/protwords.txt | 14 -
.../src/test/resources/solr/oak/conf/schema.xml | 169 ---
.../test/resources/solr/oak/conf/solrconfig.xml | 1449 --------------------
.../src/test/resources/solr/oak/conf/stopwords.txt | 14 -
.../src/test/resources/solr/oak/conf/synonyms.txt | 14 -
.../src/test/resources/solr/oak/core.properties | 16 -
oak-solr-core/src/test/resources/solr/solr.xml | 45 -
oak-solr-core/src/test/resources/solr/zoo.cfg | 32 -
oak-solr-osgi/pom.xml | 142 --
pom.xml | 2 -
79 files changed, 12501 deletions(-)
diff --git a/oak-solr-core/pom.xml b/oak-solr-core/pom.xml
deleted file mode 100644
index 4b8fc98a50..0000000000
--- a/oak-solr-core/pom.xml
+++ /dev/null
@@ -1,313 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>oak-parent</artifactId>
- <version>1.81-SNAPSHOT</version>
- <relativePath>../oak-parent/pom.xml</relativePath>
- </parent>
-
- <artifactId>oak-solr-core</artifactId>
- <name>Oak Solr core</name>
- <description>Oak support for Apache Solr indexing and search</description>
- <packaging>bundle</packaging>
-
- <properties>
- <known.issues>
- org.apache.jackrabbit.core.query.FulltextQueryTest#testMultiByte <!-- wildcards with multi byte support -->
- org.apache.jackrabbit.core.query.FnNameQueryTest#testLikeWithPrefix <!-- OAK-328 -->
- org.apache.jackrabbit.core.query.ShareableNodeTest#testName <!-- OAK-118 -->
- org.apache.jackrabbit.core.query.ShareableNodeTest#testPathConstraint <!-- OAK-118 -->
- org.apache.jackrabbit.core.query.SelectClauseTest#testSameNameSiblingSQL <!-- OAK-203 -->
- org.apache.jackrabbit.core.query.ChildAxisQueryTest#testRelationQuery <!-- OAK-203 -->
- org.apache.jackrabbit.core.query.ChildAxisQueryTest#testRelationQueryDeep <!-- OAK-203 -->
- org.apache.jackrabbit.core.query.ChildAxisQueryTest#testMultiRelation <!-- OAK-203 -->
- org.apache.jackrabbit.core.query.ChildAxisQueryTest#testLike <!-- OAK-203 -->
- org.apache.jackrabbit.core.query.ChildAxisQueryTest#testContains <!-- OAK-203 -->
- org.apache.jackrabbit.core.query.ChildAxisQueryTest#testStarNameTest <!-- OAK-203 -->
- org.apache.jackrabbit.core.query.SQL2PathEscapingTest <!-- ? -->
- org.apache.jackrabbit.core.query.UpperLowerCaseQueryTest <!-- ? -->
- org.apache.jackrabbit.core.query.SimpleQueryTest <!-- ? -->
- org.apache.jackrabbit.core.query.XPathAxisTest <!-- ? -->
- org.apache.jackrabbit.core.query.DerefTest <!-- ? -->
- org.apache.jackrabbit.core.query.QueryResultTest <!-- ? -->
- org.apache.jackrabbit.core.query.ExcerptTest#testMoreTextDotsAtEnd <!-- OAK-318 -->
- org.apache.jackrabbit.core.query.ExcerptTest#testMoreTextDotsAtStart <!-- OAK-318 -->
- org.apache.jackrabbit.core.query.ExcerptTest#testMoreTextDotsAtStartAndEnd <!-- OAK-318 -->
- org.apache.jackrabbit.core.query.ExcerptTest#testPunctuationStartsFragment <!-- OAK-318 -->
- org.apache.jackrabbit.core.query.ExcerptTest#testPunctuationStartsFragmentEndsWithDots <!-- OAK-318 -->
- org.apache.jackrabbit.core.query.ExcerptTest#testPreferPhrase <!-- OAK-318 -->
- org.apache.jackrabbit.core.query.ExcerptTest#testQuotedPhrase <!-- OAK-3580 -->
- org.apache.jackrabbit.core.query.ExcerptTest#testEncodeIllegalCharsHighlights <!-- OAK-3580 -->
- org.apache.jackrabbit.core.query.JoinTest#testJoinWithOR3 <!-- OAK-3437 -->
- org.apache.jackrabbit.core.query.JoinTest#testJoinWithOR4 <!-- OAK-3437 -->
- org.apache.jackrabbit.core.query.JoinTest#testJoinWithOR5 <!-- OAK-3437 -->
- org.apache.jackrabbit.oak.jcr.query.SpellcheckTest#testSpellcheckMultipleWords <!-- OAK-3355 -->
- org.apache.jackrabbit.oak.jcr.query.FacetTest <!-- OAK-3809 -->
- </known.issues>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Export-Package>
- !*
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>**/test.rtf</exclude>
- <exclude>**/test.txt</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-
- <dependencies>
- <!-- Added first to ensure older Lucene brought in by oak-jcr does not get selected in Eclipse -->
- <dependency>
- <groupId>org.apache.lucene</groupId>
- <artifactId>lucene-test-framework</artifactId>
- <version>${solr.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.lucene</groupId>
- <artifactId>lucene-core</artifactId>
- <version>${solr.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.lucene</groupId>
- <artifactId>lucene-analyzers-common</artifactId>
- <version>${solr.version}</version>
- <scope>test</scope>
- </dependency>
- <!-- TEST -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>oak-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>oak-query-spi</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>oak-search</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>oak-core</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>oak-segment-tar</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>oak-jcr</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>oak-jcr</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>jackrabbit-jcr-tests</artifactId>
- <version>${jackrabbit.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>jackrabbit-core</artifactId>
- <version>${jackrabbit.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tika</groupId>
- <artifactId>tika-parsers</artifactId>
- <version>${tika.version}</version>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>io.dropwizard.metrics</groupId>
- <artifactId>metrics-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jetbrains</groupId>
- <artifactId>annotations</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.core</artifactId>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.service.component</artifactId>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.service.component.annotations</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>javax.jcr</groupId>
- <artifactId>jcr</artifactId>
- <version>2.0</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>oak-shaded-guava</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>oak-core</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>oak-commons</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>jackrabbit-jcr-commons</artifactId>
- <version>${jackrabbit.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-fileupload</groupId>
- <artifactId>commons-fileupload</artifactId>
- <version>1.5</version>
- <scope>provided</scope>
- </dependency>
-
- <!-- Solr -->
- <dependency>
- <groupId>org.apache.solr</groupId>
- <artifactId>solr-core</artifactId>
- <version>${solr.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.hadoop</groupId>
- <artifactId>hadoop-annotations</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-fileupload</groupId>
- <artifactId>commons-fileupload</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core</artifactId>
- </exclusion>
- </exclusions>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.solr</groupId>
- <artifactId>solr-solrj</artifactId>
- <version>${solr.version}</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tika</groupId>
- <artifactId>tika-core</artifactId>
- <version>${tika.version}</version>
- <scope>provided</scope>
- </dependency>
-
- </dependencies>
-
-</project>
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfiguration.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfiguration.java
deleted file mode 100644
index 5f591bf593..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfiguration.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.configuration;
-
-import java.util.Collection;
-import java.util.Collections;
-import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.spi.query.Filter;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Default {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration}
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class DefaultSolrConfiguration implements OakSolrConfiguration {
-
- private static final Collection<String> ignoredProperties = OakSolrConfigurationDefaults.IGNORED_PROPERTIES;
- private static final Collection<String> usedProperties = Collections.emptyList();
-
- @Override
- public String getFieldNameFor(Type<?> propertyType) {
- return null;
- }
-
- @NotNull
- @Override
- public String getPathField() {
- return OakSolrConfigurationDefaults.PATH_FIELD_NAME;
- }
-
- @Nullable
- @Override
- public String getFieldForPathRestriction(Filter.PathRestriction pathRestriction) {
- String fieldName = null;
- switch (pathRestriction) {
- case ALL_CHILDREN: {
- fieldName = OakSolrConfigurationDefaults.DESC_FIELD_NAME;
- break;
- }
- case DIRECT_CHILDREN: {
- fieldName = OakSolrConfigurationDefaults.CHILD_FIELD_NAME;
- break;
- }
- case EXACT: {
- fieldName = OakSolrConfigurationDefaults.PATH_FIELD_NAME;
- break;
- }
- case PARENT: {
- fieldName = OakSolrConfigurationDefaults.ANC_FIELD_NAME;
- break;
- }
- case NO_RESTRICTION:
- break;
- default:
- break;
-
- }
- return fieldName;
- }
-
- @Override
- public String getFieldForPropertyRestriction(Filter.PropertyRestriction propertyRestriction) {
- return null;
- }
-
- @NotNull
- @Override
- public CommitPolicy getCommitPolicy() {
- return CommitPolicy.SOFT;
- }
-
- @Override
- public String getCatchAllField() {
- return OakSolrConfigurationDefaults.CATCHALL_FIELD;
- }
-
- @Override
- public int getRows() {
- return OakSolrConfigurationDefaults.ROWS;
- }
-
- @Override
- public boolean useForPropertyRestrictions() {
- return OakSolrConfigurationDefaults.PROPERTY_RESTRICTIONS;
- }
-
- @Override
- public boolean useForPrimaryTypes() {
- return OakSolrConfigurationDefaults.PRIMARY_TYPES;
- }
-
- @Override
- public boolean useForPathRestrictions() {
- return OakSolrConfigurationDefaults.PATH_RESTRICTIONS;
- }
-
- @NotNull
- @Override
- public Collection<String> getIgnoredProperties() {
- return ignoredProperties;
- }
-
- @NotNull
- @Override
- public Collection<String> getUsedProperties() {
- return usedProperties;
- }
-
- @Override
- public boolean collapseJcrContentNodes() {
- return OakSolrConfigurationDefaults.COLLAPSE_JCR_CONTENT_NODES;
- }
-
- @Override
- public boolean collapseJcrContentParents() {
- return OakSolrConfigurationDefaults.COLLAPSE_JCR_CONTENT_PARENTS;
- }
-
- @NotNull
- @Override
- public String getCollapsedPathField() {
- return OakSolrConfigurationDefaults.COLLAPSED_PATH_FIELD;
- }
-
- @Override
- public String getPathDepthField() {
- return OakSolrConfigurationDefaults.PATH_DEPTH_FIELD;
- }
-
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfigurationProvider.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfigurationProvider.java
deleted file mode 100644
index 7d8a139deb..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfigurationProvider.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.configuration;
-
-import org.jetbrains.annotations.NotNull;
-
-/**
- * The default {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider}
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class DefaultSolrConfigurationProvider implements OakSolrConfigurationProvider {
-
- private final OakSolrConfiguration defaultConfiguration;
-
- public DefaultSolrConfigurationProvider() {
- defaultConfiguration = new DefaultSolrConfiguration();
- }
-
- public DefaultSolrConfigurationProvider(OakSolrConfiguration configuration) {
- this.defaultConfiguration = configuration;
- }
-
- @NotNull
- @Override
- public OakSolrConfiguration getConfiguration() {
- return defaultConfiguration;
- }
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfiguration.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfiguration.java
deleted file mode 100644
index 992dae7f8f..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfiguration.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.configuration;
-
-import java.util.Collection;
-import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.spi.query.Filter;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * A Solr configuration holding all the possible customizable parameters that
- * can be leveraged for an Oak search index.
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public interface OakSolrConfiguration {
-
- /**
- * Provide a field name to be used for indexing / searching a certain {@link org.apache.jackrabbit.oak.api.Type}
- *
- * @param propertyType the {@link org.apache.jackrabbit.oak.api.Type} to be indexed / searched
- * @return the name of the Solr field to be used for the given {@link org.apache.jackrabbit.oak.api.Type}, or {@code null}
- * if no specific field has been configured to handle the given {@code Type}.
- */
- @Nullable
- String getFieldNameFor(Type<?> propertyType);
-
- /**
- * Provide the field name for indexing / searching paths
- *
- * @return the name of the Solr field to be used for indexing and searching on paths (exact matching).
- */
- @NotNull
- String getPathField();
-
- /**
- * Provide a field name to search over for the given {@link org.apache.jackrabbit.oak.spi.query.Filter.PathRestriction}
- *
- * @param pathRestriction the {@link org.apache.jackrabbit.oak.spi.query.Filter.PathRestriction} used for filtering
- * search results or {@code null} if no specific field has been configured for it.
- * @return the name of the Solr field to be used for the given {@code PathRestriction}.
- */
- @Nullable
- String getFieldForPathRestriction(Filter.PathRestriction pathRestriction);
-
- /**
- * Provide a field name to search over for the given {@link org.apache.jackrabbit.oak.spi.query.Filter.PropertyRestriction}
- *
- * @param propertyRestriction the {@link org.apache.jackrabbit.oak.spi.query.Filter.PropertyRestriction} used for filtering search results
- * @return the name of the Solr field to be used for the given {@code PropertyRestriction} or {@code null} if no specific field
- * has been configured for it.
- */
- @Nullable
- String getFieldForPropertyRestriction(Filter.PropertyRestriction propertyRestriction);
-
- /**
- * Provide the commit policy to be used by a given {@link org.apache.solr.client.solrj.SolrClient}
- *
- * @return a {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration.CommitPolicy}
- */
- @NotNull
- CommitPolicy getCommitPolicy();
-
- /**
- * Provide a field name that is used as the default "catch all" field for searching over all the data
- *
- * @return the name of the Solr field to be used as "catch all" field, or {@code null} if no specific field
- * has been configured for it.
- */
- @Nullable
- String getCatchAllField();
-
- /**
- * Provide the number of documents (rows) to be fetched for each Solr query
- *
- * @return the number of rows to fetch
- */
- int getRows();
-
- /**
- * Define if the Solr index should be used to address property restrictions
- *
- * @return <code>true</code> if {@link org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndex} should be used
- * for {@link org.apache.jackrabbit.oak.spi.query.Filter.PropertyRestriction}s
- */
- boolean useForPropertyRestrictions();
-
- /**
- * Define if the Solr index should be used to filter by primary types
- *
- * @return <code>true</code> if {@link org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndex} should be used
- * for filtering by primary types
- */
- boolean useForPrimaryTypes();
-
- /**
- * Define if the Solr index should be used to filter by path restrictions
- *
- * @return <code>true</code> if {@link org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndex} should be used
- * for filtering by {@link org.apache.jackrabbit.oak.spi.query.Filter.PathRestriction}s
- */
- boolean useForPathRestrictions();
-
- /**
- * Provide the names of the properties that should be neither indexed nor searched by the Solr index
- *
- * @return a {@link java.util.Collection} of property names for properties to be ignored
- */
- @NotNull
- Collection<String> getIgnoredProperties();
-
- /**
- * Provide the names of the properties that should be indexed and searched by the Solr index
- *
- * @return a {@link java.util.Collection} of property names for properties to be ignored
- */
- @NotNull
- Collection<String> getUsedProperties();
-
- /**
- * Make all nodes / documents matching a query that are descendants of a 'jcr:content' node collapse into such a
- * node. That will result in resultsets being tipically much more compact in cases where most / all of the matching
- * nodes match such a hierarchy.
- *
- * @return {@code true} if only the 'jcr:content' node should be returned for all its the matching descendants,
- * {@code false} otherwise
- */
- boolean collapseJcrContentNodes();
-
- /**
- * Make all nodes / documents matching a query having name equals to 'jcr:content' collapse into their respective
- * parent.
- * @return {@code true} if only the parent of 'jcr:content' nodes should be returned,
- * {@code false} otherwise
- */
- boolean collapseJcrContentParents();
-
- /**
- * Provide the name of the field to be used for indexing the collapsed path of each node when {@link #collapseJcrContentNodes()}
- * is set to {@code true}.
- *
- * @return the name of the Solr field to be used for indexing and searching on collapsed paths.
- */
- @NotNull
- String getCollapsedPathField();
-
- /**
- * Provide the name of the field containing information about the depth of a certain path / node
- *
- * @return the name of the Solr field to be used for indexing and searching on path depth.
- */
- String getPathDepthField();
-
- /**
- * Enum for describing Solr commit policy used in a certain instance
- */
- enum CommitPolicy {
- /**
- * for default Solr commit
- */
- HARD,
- /**
- * for Solr soft commit
- */
- SOFT,
- /**
- * if no commits should be sent (relying on auto(soft)commit on the instance itself)
- */
- AUTO
- }
-
- /**
- * Enum to designate the type of the Solr server.
- */
- enum ServerType {
- /**
- * no server
- */
- none,
- /**
- * embedded server
- */
- embedded,
- /**
- * remote server
- */
- remote
- }
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfigurationDefaults.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfigurationDefaults.java
deleted file mode 100644
index a974d4df75..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfigurationDefaults.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.configuration;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-
-/**
- * Defaults for search / indexing configurations options.
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class OakSolrConfigurationDefaults {
-
- public static final String PATH_FIELD_NAME = "path_exact";
- public static final String CHILD_FIELD_NAME = "path_child";
- public static final String DESC_FIELD_NAME = "path_des";
- public static final String ANC_FIELD_NAME = "path_anc";
- public static final String CATCHALL_FIELD = "catch_all";
- public static final int ROWS = 10;
- public static final boolean PROPERTY_RESTRICTIONS = false;
- public static final boolean PATH_RESTRICTIONS = false;
- public static final boolean PRIMARY_TYPES = false;
- public static final Collection<String> IGNORED_PROPERTIES = Collections.unmodifiableCollection(
- Arrays.asList("rep:members", "rep:authorizableId", "jcr:uuid", "rep:principalName", "rep:password"));
- public static final String TYPE_MAPPINGS = "";
- public static final String PROPERTY_MAPPINGS = "";
- public static final boolean COLLAPSE_JCR_CONTENT_NODES = false;
- public static final String COLLAPSED_PATH_FIELD = "path_collapsed";
- public static final String PATH_DEPTH_FIELD = "path_depth";
- public static final boolean COLLAPSE_JCR_CONTENT_PARENTS = true;
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfigurationProvider.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfigurationProvider.java
deleted file mode 100644
index ef67365475..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfigurationProvider.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.configuration;
-
-import org.jetbrains.annotations.NotNull;
-
-/**
- * A provider for {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration}s
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public interface OakSolrConfigurationProvider {
-
- /**
- * Provides a Solr configuration for Oak
- *
- * @return a {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration}
- */
- @NotNull
- OakSolrConfiguration getConfiguration();
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/RemoteSolrServerConfiguration.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/RemoteSolrServerConfiguration.java
deleted file mode 100644
index 1aabea2fa4..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/RemoteSolrServerConfiguration.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.configuration;
-
-import java.util.Arrays;
-
-import org.apache.jackrabbit.oak.plugins.index.solr.server.RemoteSolrServerProvider;
-
-/**
- * {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfiguration} for the {@link org.apache.jackrabbit.oak.plugins.index.solr.server.RemoteSolrServerProvider}
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class RemoteSolrServerConfiguration extends SolrServerConfiguration<RemoteSolrServerProvider> {
-
- private final String solrConfDir;
- private final int socketTimeout;
- private final int connectionTimeout;
- private final String[] solrHttpUrls;
- private final String solrZkHost;
- private final String solrCollection;
- private final int solrShardsNo;
- private final int solrReplicationFactor;
-
- public RemoteSolrServerConfiguration(String solrZkHost, String solrCollection, int solrShardsNo, int solrReplicationFactor,
- String solrConfDir, int socketTimeout, int connectionTimeout, String... solrHttpUrls) {
- this.socketTimeout = socketTimeout;
- this.connectionTimeout = connectionTimeout;
- this.solrHttpUrls = solrHttpUrls;
- this.solrZkHost = solrZkHost;
- this.solrCollection = solrCollection;
- this.solrShardsNo = solrShardsNo;
- this.solrConfDir = solrConfDir;
- this.solrReplicationFactor = solrReplicationFactor;
- }
-
- public String[] getSolrHttpUrls() {
- return solrHttpUrls;
- }
-
- public String getSolrZkHost() {
- return solrZkHost;
- }
-
- public String getSolrCollection() {
- return solrCollection;
- }
-
- public int getSolrShardsNo() {
- return solrShardsNo;
- }
-
- public int getSolrReplicationFactor() {
- return solrReplicationFactor;
- }
-
- public String getSolrConfDir() {
- return solrConfDir;
- }
-
- public int getSocketTimeout() {
- return socketTimeout;
- }
-
- public int getConnectionTimeout() {
- return connectionTimeout;
- }
-
- @Override
- public String toString() {
- return "RemoteSolrServerConfiguration{" +
- "solrConfDir='" + solrConfDir + '\'' +
- ", socketTimeout=" + socketTimeout +
- ", connectionTimeout=" + connectionTimeout +
- ", solrHttpUrls=" + Arrays.toString(solrHttpUrls) +
- ", solrZkHost='" + solrZkHost + '\'' +
- ", solrCollection='" + solrCollection + '\'' +
- ", solrShardsNo=" + solrShardsNo +
- ", solrReplicationFactor=" + solrReplicationFactor +
- '}';
- }
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfiguration.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfiguration.java
deleted file mode 100644
index e6ed213a0f..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfiguration.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.configuration;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-
-import org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider;
-
-/**
- * Configuration parameters for starting a {@link org.apache.solr.client.solrj.SolrClient}
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public abstract class SolrServerConfiguration<S extends SolrServerProvider> {
-
- private final Type type;
- private volatile Constructor<?> constructor;
-
- protected SolrServerConfiguration() {
- Type superclass = getClass().getGenericSuperclass();
- if (superclass instanceof Class) {
- throw new RuntimeException("Missing type parameter.");
- }
- this.type = ((ParameterizedType) superclass).getActualTypeArguments()[0];
- }
-
- public SolrServerConfiguration<S> withHttpConfiguration(String context, Integer httpPort) {
- return this;
- }
-
- public Type getType() {
- return this.type;
- }
-
- public S getProvider()
- throws IllegalAccessException,
- InvocationTargetException, InstantiationException {
- if (constructor == null) {
- Class<?> rawType = type instanceof Class<?>
- ? (Class<?>) type
- : (Class<?>) ((ParameterizedType) type).getRawType();
- Constructor<?>[] constructors = rawType.getConstructors();
- for (Constructor<?> c: constructors) {
- if (c.getParameterTypes().length == 1 && c.getParameterTypes()[0].equals(this.getClass())) {
- constructor = c;
- }
- }
- if (constructor == null) {
- throw new InstantiationException("missing constructor SolrServerProvider(SolrServerConfiguration) for type "+ rawType);
- }
- }
- return (S) constructor.newInstance(this); // TODO : each SolrServerProvider impl. is forced to have a constructor with a SolrServerConfiguration, fix?
- }
-
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationDefaults.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationDefaults.java
deleted file mode 100644
index 2e2f107ab5..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationDefaults.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.configuration;
-
-/**
- * Defaults for Solr server configuration options.
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class SolrServerConfigurationDefaults {
-
- // --> default values for EmbeddedSolrServerConfiguration parameters <--
- public static final String SOLR_HOME_PATH = "solr";
- public static final String CORE_NAME = "oak";
- public static final String HTTP_PORT = "8983";
- public static final String LOCAL_BASE_URL = "http://127.0.0.1";
- public static final String CONTEXT = "/solr";
-
- // --> default values for RemoteSolrServerConfiguration parameters <--
- public static final String COLLECTION = "oak";
- public static final String HTTP_URL = "http://127.0.0.1:8983/solr/oak";
- public static final String ZK_HOST = "127.0.0.1:9983";
- public static final int SHARDS_NO = 2;
- public static final int REPLICATION_FACTOR = 2;
- public static final String CONFIGURATION_DIRECTORY = "";
- public static final int SOCKET_TIMEOUT = 3000;
- public static final int CONNECTION_TIMEOUT = 3000;
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationProvider.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationProvider.java
deleted file mode 100644
index e8bcab00b7..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationProvider.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.configuration;
-
-import org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * {@link org.apache.solr.client.solrj.SolrClient} configuration provider.
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public interface SolrServerConfigurationProvider<S extends SolrServerProvider> {
-
- /**
- * Provide a {@link SolrServerConfiguration} to be used to initialize a specific
- * {@link org.apache.solr.client.solrj.SolrClient} implementation.
- *
- * @return the {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfiguration} holding the configuration parameters
- */
- @NotNull
- SolrServerConfiguration<S> getSolrServerConfiguration();
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/nodestate/NodeStateSolrServerConfigurationProvider.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/nodestate/NodeStateSolrServerConfigurationProvider.java
deleted file mode 100644
index 1ed3929fac..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/nodestate/NodeStateSolrServerConfigurationProvider.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate;
-
-import org.apache.jackrabbit.oak.api.PropertyState;
-import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.RemoteSolrServerConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationDefaults;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.jetbrains.annotations.NotNull;
-
-@Deprecated(forRemoval=true, since="1.74.0")
-public class NodeStateSolrServerConfigurationProvider implements SolrServerConfigurationProvider {
-
- private final NodeState nodeState;
-
- public NodeStateSolrServerConfigurationProvider(NodeState nodeState) {
- this.nodeState = nodeState;
- if (!nodeState.hasProperty(Properties.SERVER_TYPE)) {
- throw new IllegalArgumentException("missing property " + Properties.SERVER_TYPE + " in " + nodeState);
- }
- }
-
- private int getIntValueFor(String propertyName, int defaultValue) {
- long value = defaultValue;
- PropertyState property = nodeState.getProperty(propertyName);
- if (property != null) {
- value = property.getValue(Type.LONG);
- }
- return (int) value;
- }
-
- private String getStringValueFor(String propertyName, String defaultValue) {
- String value = defaultValue;
- PropertyState property = nodeState.getProperty(propertyName);
- if (property != null) {
- value = property.getValue(Type.STRING);
- }
- return value;
- }
-
- @NotNull
- @Override
- public SolrServerConfiguration<SolrServerProvider> getSolrServerConfiguration() {
- String type = getStringValueFor(Properties.SERVER_TYPE, null);
- if ("embedded".equalsIgnoreCase(type)) {
- String solrHomePath = getStringValueFor(Properties.SOLRHOME_PATH, SolrServerConfigurationDefaults.SOLR_HOME_PATH);
- String coreName = getStringValueFor(Properties.CORE_NAME, SolrServerConfigurationDefaults.CORE_NAME);
- String context = getStringValueFor(Properties.CONTEXT, null);
- Integer httpPort = Integer.valueOf(getStringValueFor(Properties.HTTP_PORT, "0"));
-
- if (context != null && httpPort > 0) {
- return createEmbeddedSolrServerConfiguration(solrHomePath, coreName)
- .withHttpConfiguration(context, httpPort);
- } else {
- return createEmbeddedSolrServerConfiguration(solrHomePath, coreName);
- }
- } else if ("remote".equalsIgnoreCase(type)) {
- String solrZkHost = getStringValueFor(Properties.ZK_HOST, null);
- String solrCollection = getStringValueFor(Properties.COLLECTION, SolrServerConfigurationDefaults.COLLECTION);
- int solrReplicationFactor = getIntValueFor(Properties.REPLICATION_FACTOR, SolrServerConfigurationDefaults.REPLICATION_FACTOR);
- String solrConfDir = getStringValueFor(Properties.CONFIGURATION_DIRECTORY, SolrServerConfigurationDefaults.CONFIGURATION_DIRECTORY);
- String solrHttpUrls = getStringValueFor(Properties.HTTP_URL, SolrServerConfigurationDefaults.HTTP_URL);
- int solrShardsNo = getIntValueFor(Properties.SHARDS_NO, SolrServerConfigurationDefaults.SHARDS_NO);
-
- int socketTimeout = getIntValueFor(Properties.SOCKET_TIMEOUT, SolrServerConfigurationDefaults.SOCKET_TIMEOUT);
- int connectionTimeout = getIntValueFor(Properties.CONNECTION_TIMEOUT, SolrServerConfigurationDefaults.CONNECTION_TIMEOUT);
-
- return (SolrServerConfiguration) new RemoteSolrServerConfiguration(solrZkHost, solrCollection, solrShardsNo,
- solrReplicationFactor, solrConfDir, socketTimeout, connectionTimeout, solrHttpUrls);
- } else {
- throw new RuntimeException("unexpected Solr server type: " + type);
- }
- }
-
- @SuppressWarnings({"unchecked" })
- private static SolrServerConfiguration<SolrServerProvider> createEmbeddedSolrServerConfiguration(String solrHomePath, String coreName) {
- try {
- Class<?> c = Class.forName("org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration");
- return (SolrServerConfiguration<SolrServerProvider>) c.getConstructor(String.class, String.class).newInstance(solrHomePath, coreName);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Properties that may be retrieved from the configuration {@link org.apache.jackrabbit.oak.spi.state.NodeState}.
- */
- public final class Properties {
- public static final String SERVER_TYPE = "solrServerType";
-
- // --> embedded solr server properties <--
- public static final String SOLRHOME_PATH = "solrHomePath";
- public static final String CONTEXT = "solrContext";
- public static final String HTTP_PORT = "httpPort";
- public static final String CORE_NAME = "coreName";
-
- // --> remote solr server properties <--
- public static final String ZK_HOST = "zkHost";
- public static final String COLLECTION = "collection";
- public static final String REPLICATION_FACTOR = "replicationFactor";
- public static final String CONFIGURATION_DIRECTORY = "configurationDirectory";
- public static final String HTTP_URL = "httpUrl";
- public static final String SHARDS_NO = "shardsNo";
- public static final String CONNECTION_TIMEOUT = "connectionTimeout";
- public static final String SOCKET_TIMEOUT = "socketTimeout";
- }
-
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/nodestate/NodeStateSolrServerProvider.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/nodestate/NodeStateSolrServerProvider.java
deleted file mode 100644
index 8d73d45956..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/nodestate/NodeStateSolrServerProvider.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate;
-
-import java.io.IOException;
-
-import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
-import org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.solr.client.solrj.SolrClient;
-
-/**
- * {@link org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider} using configuration stored in a repository
- * node named "server" as a child of a {@code oak:queryIndexDefinition} node (e.g. under /../a/b/solrIndex/server)
- * having {@code type = solr}
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class NodeStateSolrServerProvider implements SolrServerProvider {
-
- private final NodeState nodeState;
- private SolrServerProvider provider;
-
- public NodeStateSolrServerProvider(NodeState nodeState) {
- this.nodeState = nodeState;
- }
-
- private void checkProviderInitialization() throws IllegalAccessException, java.lang.reflect.InvocationTargetException, InstantiationException {
- synchronized (nodeState) {
- if (provider == null) {
- this.provider = new NodeStateSolrServerConfigurationProvider(nodeState).getSolrServerConfiguration().getProvider();
- }
- }
- }
-
- @Override
- public SolrClient getSolrServer() throws Exception {
- checkProviderInitialization();
- return provider.getSolrServer();
- }
-
- @Override
- public SolrClient getIndexingSolrServer() throws Exception {
- checkProviderInitialization();
- return provider.getIndexingSolrServer();
- }
-
- @Override
- public SolrClient getSearchingSolrServer() throws Exception {
- checkProviderInitialization();
- return provider.getSearchingSolrServer();
- }
-
- @Override
- public void close() throws IOException {
- try {
- getSolrServer().close();
- } catch (Exception e) {
- // do nothing
- } try {
- getIndexingSolrServer().close();
- } catch (Exception e) {
- // do nothing
- } try {
- getSearchingSolrServer().close();
- } catch (Exception e) {
- // do nothing
- }
- }
-
- @Override
- public String toString() {
- return "NodeStateSolrServerProvider{" +
- "nodeStateChildren=" + IterableUtils.toString(nodeState.getChildNodeNames()) +
- ", provider=" + provider +
- '}';
- }
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/nodestate/NodeStateSolrServersObserver.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/nodestate/NodeStateSolrServersObserver.java
deleted file mode 100644
index 2a2706d8ad..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/nodestate/NodeStateSolrServersObserver.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate;
-
-import org.apache.jackrabbit.oak.api.PropertyState;
-import org.apache.jackrabbit.oak.plugins.index.solr.server.OakSolrServer;
-import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
-import org.apache.jackrabbit.oak.spi.commit.DiffObserver;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
-import org.jetbrains.annotations.NotNull;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-
-/**
- * An {@link org.apache.jackrabbit.oak.spi.commit.Observer} looking for changes on persisted Solr server configuration nodes.
- * If any change is done there, the related {@link org.apache.solr.client.solrj.SolrClient}s are shutdown and unregistered
- * from the {@link org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerRegistry}
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class NodeStateSolrServersObserver extends DiffObserver {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Override
- protected NodeStateDiff getRootDiff(@NotNull NodeState before, @NotNull NodeState after, @NotNull CommitInfo info) {
- return new ChangingSolrServersNodeStateDiff(after);
- }
-
- private void shutdownRegisteredSolrServers(NodeState nodeState) {
- log.debug("shutting down persisted Solr server");
- NodeStateSolrServerConfigurationProvider nodeStateSolrServerConfigurationProvider = new NodeStateSolrServerConfigurationProvider(nodeState);
- OakSolrServer oakSolrServer = new OakSolrServer(nodeStateSolrServerConfigurationProvider);
- try {
- oakSolrServer.close();
- } catch (IOException e) {
- log.error("could not close OakSolrServer {}", oakSolrServer, e);
- }
- log.info("persisted Solr server has been shutdown");
- }
-
- private class ChangingSolrServersNodeStateDiff implements NodeStateDiff {
- private final NodeState nodeState;
- private final String name;
-
- public ChangingSolrServersNodeStateDiff(NodeState after) {
- nodeState = after;
- name = "";
- }
-
- public ChangingSolrServersNodeStateDiff(NodeState nodeState, String name) {
- this.nodeState = nodeState;
- this.name = name;
- }
-
- @Override
- public boolean propertyAdded(PropertyState after) {
- if (isSolrServerNode(name, nodeState)) {
- shutdownRegisteredSolrServers(nodeState);
- }
- return true;
- }
-
- @Override
- public boolean propertyChanged(PropertyState before, PropertyState after) {
- if (isSolrServerNode(name, nodeState)) {
- shutdownRegisteredSolrServers(nodeState);
- }
- return true;
- }
-
- @Override
- public boolean propertyDeleted(PropertyState before) {
- if (isSolrServerNode(name, nodeState)) {
- shutdownRegisteredSolrServers(nodeState);
- }
- return true;
- }
-
- @Override
- public boolean childNodeAdded(String name, NodeState after) {
- return true;
- }
-
- @Override
- public boolean childNodeChanged(String name, NodeState before, NodeState after) {
- if (isSolrServerNode(name, before)) {
- shutdownRegisteredSolrServers(before);
- }
- return after.compareAgainstBaseState(before, new ChangingSolrServersNodeStateDiff(after, this.name + "/" + name));
- }
-
- @Override
- public boolean childNodeDeleted(String name, NodeState before) {
- if (isSolrServerNode(name, before)) { // look if the deleted node was a server node
- shutdownRegisteredSolrServers(before);
- } else { //look among child nodes if there was a server node
- for (String childNodeName : before.getChildNodeNames()) {
- NodeState childNodeState = before.getChildNode(childNodeName);
- if (isSolrServerNode(childNodeName, childNodeState)) {
- shutdownRegisteredSolrServers(childNodeState);
- break;
- }
- }
- }
- return true;
- }
-
- private boolean isSolrServerNode(String name, NodeState nodeState) {
- return "server".equals(name) && nodeState.hasProperty("solrServerType");
- }
-
- }
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/nodestate/OakSolrNodeStateConfiguration.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/nodestate/OakSolrNodeStateConfiguration.java
deleted file mode 100644
index 90b51017d5..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/nodestate/OakSolrNodeStateConfiguration.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.Locale;
-import org.apache.jackrabbit.oak.api.PropertyState;
-import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationDefaults;
-import org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndex;
-import org.apache.jackrabbit.oak.spi.query.Filter;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * An {@link OakSolrConfiguration} specified via a given {@link org.apache.jackrabbit.oak.spi.state.NodeState}.
- * For each of the supported properties a default is provided if either the
- * property doesn't exist in the node or if the value is <code>null</code>
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class OakSolrNodeStateConfiguration implements OakSolrConfiguration {
-
- private final NodeState definition;
-
- public OakSolrNodeStateConfiguration(NodeState definition) {
- this.definition = definition;
- if (!definition.hasProperty("type") || !(SolrQueryIndex.TYPE.equals(definition.getProperty("type").getValue(Type.STRING)))) {
- throw new IllegalArgumentException("missing or wrong 'type' property in " + definition);
- }
- }
-
- @Override
- public String getFieldNameFor(Type<?> propertyType) {
- Iterable<String> typeMappings = getStringValuesFor(Properties.TYPE_MAPPINGS);
- if (typeMappings != null) {
- for (String typeMapping : typeMappings) {
- String[] mapping = typeMapping.split("=");
- if (mapping.length == 2 && mapping[0] != null && mapping[1] != null) {
- Type<?> type = Type.fromString(mapping[0]);
- if (type != null && type.tag() == propertyType.tag()) {
- return mapping[1];
- }
- }
- }
- }
- return null;
- }
-
- @NotNull
- @Override
- public String getPathField() {
- return getStringValueFor(Properties.PATH_FIELD, OakSolrConfigurationDefaults.PATH_FIELD_NAME);
- }
-
- @Nullable
- @Override
- public String getFieldForPathRestriction(Filter.PathRestriction pathRestriction) {
- String fieldName = null;
- switch (pathRestriction) {
- case ALL_CHILDREN: {
- fieldName = getStringValueFor(Properties.DESCENDANTS_FIELD, OakSolrConfigurationDefaults.DESC_FIELD_NAME);
- break;
- }
- case DIRECT_CHILDREN: {
- fieldName = getStringValueFor(Properties.CHILDREN_FIELD, OakSolrConfigurationDefaults.CHILD_FIELD_NAME);
- break;
- }
- case EXACT: {
- fieldName = getStringValueFor(Properties.PATH_FIELD, OakSolrConfigurationDefaults.PATH_FIELD_NAME);
- break;
- }
- case PARENT: {
- fieldName = getStringValueFor(Properties.PARENT_FIELD, OakSolrConfigurationDefaults.ANC_FIELD_NAME);
- break;
- }
- case NO_RESTRICTION:
- break;
- default:
- break;
-
- }
- return fieldName;
- }
-
- @Override
- public String getCatchAllField() {
- return getStringValueFor(Properties.CATCHALL_FIELD, OakSolrConfigurationDefaults.CATCHALL_FIELD);
- }
-
- @Override
- public String getFieldForPropertyRestriction(Filter.PropertyRestriction propertyRestriction) {
- Iterable<String> propertyMappings = getStringValuesFor(Properties.PROPERTY_MAPPINGS);
- if (propertyMappings != null) {
- for (String propertyMapping : propertyMappings) {
- String[] mapping = propertyMapping.split("=");
- if (mapping.length == 2 && mapping[0] != null && mapping[1] != null) {
- if (propertyRestriction.propertyName.equals(mapping[0])) {
- return mapping[1];
- }
- }
- }
- }
- return null;
- }
-
- @NotNull
- @Override
- public CommitPolicy getCommitPolicy() {
- return CommitPolicy.valueOf(getStringValueFor(Properties.COMMIT_POLICY, CommitPolicy.SOFT.toString()).toUpperCase(Locale.ENGLISH));
- }
-
- @Override
- public int getRows() {
- return getIntValueFor(Properties.ROWS, OakSolrConfigurationDefaults.ROWS);
- }
-
- @Override
- public boolean useForPropertyRestrictions() {
- return getBooleanValueFor(Properties.PROPERTY_RESTRICIONS, OakSolrConfigurationDefaults.PROPERTY_RESTRICTIONS);
- }
-
- @Override
- public boolean useForPrimaryTypes() {
- return getBooleanValueFor(Properties.PRIMARY_TYPES, OakSolrConfigurationDefaults.PRIMARY_TYPES);
- }
-
- @Override
- public boolean useForPathRestrictions() {
- return getBooleanValueFor(Properties.PATH_RESTRICTIONS, OakSolrConfigurationDefaults.PATH_RESTRICTIONS);
- }
-
- @NotNull
- @Override
- public Collection<String> getIgnoredProperties() {
- Collection<String> ignoredProperties;
- Iterable<String> ignoredPropertiesValues = getStringValuesFor(Properties.IGNORED_PROPERTIES);
- if (ignoredPropertiesValues != null) {
- ignoredProperties = new LinkedList<String>();
- for (String ignoredProperty : ignoredPropertiesValues) {
- ignoredProperties.add(ignoredProperty);
- }
- } else {
- ignoredProperties = OakSolrConfigurationDefaults.IGNORED_PROPERTIES;
- }
- return ignoredProperties;
- }
-
- @NotNull
- @Override
- public Collection<String> getUsedProperties() {
- Collection<String> usedProperties;
- Iterable<String> usedPropertiesValues = getStringValuesFor(Properties.USED_PROPERTIES);
- if (usedPropertiesValues != null) {
- usedProperties = new LinkedList<String>();
- for (String usedProperty : usedPropertiesValues) {
- usedProperties.add(usedProperty);
- }
- } else {
- usedProperties = Collections.emptyList();
- }
- return usedProperties;
- }
-
- @Override
- public boolean collapseJcrContentNodes() {
- return getBooleanValueFor(Properties.COLLAPSE_JCR_CONTENT_NODES, OakSolrConfigurationDefaults.COLLAPSE_JCR_CONTENT_NODES);
- }
-
- @Override
- public boolean collapseJcrContentParents() {
- return getBooleanValueFor(Properties.COLLAPSE_JCR_CONTENT_PARENTS, OakSolrConfigurationDefaults.COLLAPSE_JCR_CONTENT_PARENTS);
- }
-
- @NotNull
- @Override
- public String getCollapsedPathField() {
- return getStringValueFor(Properties.COLLAPSED_PATH_FIELD, OakSolrConfigurationDefaults.COLLAPSED_PATH_FIELD);
- }
-
- @NotNull
- @Override
- public String getPathDepthField() {
- return getStringValueFor(Properties.DEPTH_FIELD, OakSolrConfigurationDefaults.PATH_DEPTH_FIELD);
- }
-
- private boolean getBooleanValueFor(String propertyName, boolean defaultValue) {
- boolean value = defaultValue;
- PropertyState property = definition.getProperty(propertyName);
- if (property != null) {
- value = property.getValue(Type.BOOLEAN);
- }
- return value;
- }
-
- private int getIntValueFor(String propertyName, int defaultValue) {
- long value = defaultValue;
- PropertyState property = definition.getProperty(propertyName);
- if (property != null) {
- value = property.getValue(Type.LONG);
- }
- return (int) value;
- }
-
- private String getStringValueFor(String propertyName, String defaultValue) {
- String value = defaultValue;
- PropertyState property = definition.getProperty(propertyName);
- if (property != null) {
- value = property.getValue(Type.STRING);
- }
- return value;
- }
-
- private Iterable<String> getStringValuesFor(String propertyName) {
- Iterable<String> values = null;
- PropertyState property = definition.getProperty(propertyName);
- if (property != null && property.isArray()) {
- values = property.getValue(Type.STRINGS);
- }
- return values;
- }
-
- @Override
- public String toString() {
- return "OakSolrNodeStateConfiguration{" +
- "definitionChildren=" + IterableUtils.toString(definition.getChildNodeNames()) +
- '}';
- }
-
- /**
- * Properties that may be retrieved from the configuration {@link org.apache.jackrabbit.oak.spi.state.NodeState}.
- */
- public final class Properties {
- // --> oak solr config properties <--
- public static final String PATH_FIELD = "pathField";
- public static final String COLLAPSED_PATH_FIELD = "pathField";
- public static final String PARENT_FIELD = "parentField";
- public static final String CHILDREN_FIELD = "childrenField";
- public static final String DESCENDANTS_FIELD = "descendantsField";
- public static final String CATCHALL_FIELD = "catchAllField";
- public static final String COMMIT_POLICY = "commitPolicy";
- public static final String ROWS = "rows";
- public static final String PROPERTY_RESTRICIONS = "propertyRestrictions";
- public static final String PRIMARY_TYPES = "primaryTypes";
- public static final String PATH_RESTRICTIONS = "pathRestrictions";
- public static final String IGNORED_PROPERTIES = "ignoredProperties";
- public static final String TYPE_MAPPINGS = "typeMappings";
- public static final String PROPERTY_MAPPINGS = "propertyMappings";
- public static final String USED_PROPERTIES = "usedProperties";
- public static final String COLLAPSE_JCR_CONTENT_NODES = "collapseJcrContentNodes";
- public static final String DEPTH_FIELD= "depthField";
- public static final String COLLAPSE_JCR_CONTENT_PARENTS = "collapseJcrContentParents";
- }
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditor.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditor.java
deleted file mode 100644
index 1ad84f663b..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditor.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.index;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.jackrabbit.JcrConstants;
-import org.apache.jackrabbit.oak.api.Blob;
-import org.apache.jackrabbit.oak.api.CommitFailedException;
-import org.apache.jackrabbit.oak.api.PropertyState;
-import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.commons.PathUtils;
-import org.apache.jackrabbit.oak.plugins.index.IndexEditor;
-import org.apache.jackrabbit.oak.plugins.index.IndexUpdateCallback;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration;
-import org.apache.jackrabbit.oak.spi.commit.Editor;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.solr.client.solrj.SolrClient;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.common.SolrInputDocument;
-import org.apache.tika.exception.WriteLimitReachedException;
-import org.apache.tika.metadata.Metadata;
-import org.apache.tika.parser.AutoDetectParser;
-import org.apache.tika.parser.ParseContext;
-import org.apache.tika.parser.Parser;
-import org.apache.tika.sax.WriteOutContentHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.apache.jackrabbit.JcrConstants.JCR_DATA;
-import static org.apache.jackrabbit.oak.commons.PathUtils.concat;
-import static org.apache.jackrabbit.oak.plugins.index.solr.util.SolrUtils.getSortingField;
-import static org.apache.jackrabbit.oak.plugins.index.solr.util.SolrUtils.partialEscape;
-
-/**
- * Index editor for keeping a Solr index up to date.
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-class SolrIndexEditor implements IndexEditor {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- /**
- * Parent editor, or {@code null} if this is the root editor.
- */
- private final SolrIndexEditor parent;
-
- /**
- * Name of this node, or {@code null} for the root node.
- */
- private final String name;
-
- /**
- * Path of this editor, built lazily in {@link #getPath()}.
- */
- private String path;
-
- private final SolrClient solrServer;
-
- private final OakSolrConfiguration configuration;
-
- private boolean propertiesChanged = false;
-
- private final IndexUpdateCallback updateCallback;
-
- private static final Parser parser = new AutoDetectParser();
-
- SolrIndexEditor(
- SolrClient solrServer,
- OakSolrConfiguration configuration,
- IndexUpdateCallback callback) {
- this.parent = null;
- this.name = null;
- this.path = "/";
- this.solrServer = solrServer;
- this.configuration = configuration;
- this.updateCallback = callback;
- }
-
- private SolrIndexEditor(SolrIndexEditor parent, String name) {
- this.parent = parent;
- this.name = name;
- this.path = null;
- this.solrServer = parent.solrServer;
- this.configuration = parent.configuration;
- this.updateCallback = parent.updateCallback;
- }
-
- String getPath() {
- if (path == null) { // => parent != null
- path = concat(parent.getPath(), name);
- }
- return path;
- }
-
- @Override
- public void enter(NodeState before, NodeState after) {
- }
-
- @Override
- public void leave(NodeState before, NodeState after)
- throws CommitFailedException {
- if (propertiesChanged || !before.exists()) {
- updateCallback.indexUpdate();
- try {
- solrServer.add(docFromState(after));
- } catch (SolrServerException e) {
- throw new CommitFailedException(
- "Solr", 2, "Failed to add a document to Solr", e);
- } catch (IOException e) {
- throw new CommitFailedException(
- "Solr", 6, "Failed to send data to Solr", e);
- }
- }
-
- if (parent == null) {
- try {
- commitByPolicy(solrServer, configuration.getCommitPolicy());
- } catch (SolrServerException e) {
- throw new CommitFailedException(
- "Solr", 3, "Failed to commit changes to Solr", e);
- } catch (IOException e) {
- throw new CommitFailedException(
- "Solr", 6, "Failed to send data to Solr", e);
- }
- }
- }
-
- private void commitByPolicy(SolrClient solrServer, OakSolrConfiguration.CommitPolicy commitPolicy) throws IOException, SolrServerException {
- switch (commitPolicy) {
- case HARD: {
- solrServer.commit();
- break;
- }
- case SOFT: {
- solrServer.commit(false, false, true);
- break;
- }
- case AUTO: {
- break;
- }
- }
- }
-
- @Override
- public void propertyAdded(PropertyState after) {
- propertiesChanged = true;
- }
-
- @Override
- public void propertyChanged(PropertyState before, PropertyState after) {
- propertiesChanged = true;
- }
-
- @Override
- public void propertyDeleted(PropertyState before) {
- propertiesChanged = true;
- }
-
- @Override
- public Editor childNodeAdded(String name, NodeState after) {
- return new SolrIndexEditor(this, name);
- }
-
- @Override
- public Editor childNodeChanged(
- String name, NodeState before, NodeState after) {
- return new SolrIndexEditor(this, name);
- }
-
- @Override
- public Editor childNodeDeleted(String name, NodeState before)
- throws CommitFailedException {
- String path = partialEscape(PathUtils.concat(getPath(), name)).toString();
- try {
- String formattedQuery = String.format(
- "%s:%s*", configuration.getPathField(), path);
- if (log.isDebugEnabled()) {
- log.debug("deleting by query {}", formattedQuery);
- }
- solrServer.deleteByQuery(formattedQuery);
- updateCallback.indexUpdate();
- } catch (SolrServerException e) {
- throw new CommitFailedException(
- "Solr", 5, "Failed to remove documents from Solr", e);
- } catch (IOException e) {
- throw new CommitFailedException(
- "Solr", 6, "Failed to send data to Solr", e);
- }
-
- return null; // no need to recurse down the removed subtree
- }
-
- private SolrInputDocument docFromState(NodeState state) {
- SolrInputDocument inputDocument = new SolrInputDocument();
- String path = getPath();
- inputDocument.addField(configuration.getPathField(), path);
- inputDocument.addField(configuration.getPathDepthField(), PathUtils.getDepth(path));
-
- if (configuration.collapseJcrContentNodes()) {
- int jcrContentIndex = path.lastIndexOf(JcrConstants.JCR_CONTENT);
- if (jcrContentIndex >= 0) {
- int index = jcrContentIndex + JcrConstants.JCR_CONTENT.length();
- String collapsedPath = path.substring(0, index);
- inputDocument.addField(configuration.getCollapsedPathField(), collapsedPath);
- }
- }
-
- for (PropertyState property : state.getProperties()) {
- if ((configuration.getUsedProperties().size() > 0 && configuration.getUsedProperties().contains(property.getName()))
- || !configuration.getIgnoredProperties().contains(property.getName())) {
- // try to get the field to use for this property from configuration
- String fieldName = configuration.getFieldNameFor(property.getType());
- Object fieldValue;
- if (fieldName != null) {
- fieldValue = property.getValue(property.getType());
- } else {
- fieldName = property.getName();
- if (Type.BINARY.tag() == property.getType().tag()) {
- fieldValue = extractTextValues(property, state);
- } else if (property.isArray()) {
- fieldValue = property.getValue(Type.STRINGS);
- } else {
- fieldValue = property.getValue(Type.STRING);
- }
- }
- // add property field
- inputDocument.addField(fieldName, fieldValue);
-
- Object sortValue;
- if (fieldValue instanceof Iterable) {
- Iterable values = (Iterable) fieldValue;
- StringBuilder builder = new StringBuilder();
- String stringValue = null;
- for (Object value : values) {
- builder.append(value);
- if (builder.length() > 1024) {
- stringValue = builder.substring(0, 1024);
- break;
- }
- }
- if (stringValue == null) {
- stringValue = builder.toString();
- }
- sortValue = stringValue;
- } else {
- if (fieldValue.toString().length() > 1024) {
- sortValue = fieldValue.toString().substring(0, 1024);
- } else {
- sortValue = fieldValue;
- }
- }
-
- // add sort field
- inputDocument.addField(getSortingField(property.getType().tag(), property.getName()), sortValue);
- }
- }
- return inputDocument;
- }
-
- private List<String> extractTextValues(
- PropertyState property, NodeState state) {
- List<String> values = new LinkedList<String>();
- Metadata metadata = new Metadata();
- if (JCR_DATA.equals(property.getName())) {
- String type = state.getString(JcrConstants.JCR_MIMETYPE);
- if (type != null) { // not mandatory
- metadata.set(Metadata.CONTENT_TYPE, type);
- }
- String encoding = state.getString(JcrConstants.JCR_ENCODING);
- if (encoding != null) { // not mandatory
- metadata.set(Metadata.CONTENT_ENCODING, encoding);
- }
- }
-
- for (Blob v : property.getValue(Type.BINARIES)) {
- values.add(parseStringValue(v, metadata));
- }
- return values;
- }
-
- private String parseStringValue(Blob v, Metadata metadata) {
- WriteOutContentHandler handler = new WriteOutContentHandler();
- try {
- InputStream stream = v.getNewStream();
- try {
- parser.parse(stream, handler, metadata, new ParseContext());
- } finally {
- stream.close();
- }
- } catch (LinkageError e) {
- // Capture and ignore errors caused by extraction libraries
- // not being present. This is equivalent to disabling
- // selected media types in configuration, so we can simply
- // ignore these errors.
- } catch (Throwable t) {
- // Capture and report any other full text extraction problems.
- // The special STOP exception is used for normal termination.
- if (!WriteLimitReachedException.isWriteLimitReached(t)) {
- log.debug("Failed to extract text from a binary property: "
- + " This is a fairly common case, and nothing to"
- + " worry about. The stack trace is included to"
- + " help improve the text extraction feature.", t);
- return "TextExtractionError";
- }
- }
- return handler.toString();
- }
-
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditorProvider.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditorProvider.java
deleted file mode 100644
index 472e991c89..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditorProvider.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.index;
-
-import org.apache.jackrabbit.oak.api.CommitFailedException;
-import org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider;
-import org.apache.jackrabbit.oak.plugins.index.IndexUpdateCallback;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate.NodeStateSolrServerConfigurationProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate.OakSolrNodeStateConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndex;
-import org.apache.jackrabbit.oak.plugins.index.solr.server.OakSolrServer;
-import org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider;
-import org.apache.jackrabbit.oak.spi.commit.Editor;
-import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.solr.client.solrj.SolrClient;
-import org.jetbrains.annotations.NotNull;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Solr based {@link IndexEditorProvider}
- *
- * @see SolrIndexEditor
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class SolrIndexEditorProvider implements IndexEditorProvider {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private final SolrServerProvider solrServerProvider;
-
- private final OakSolrConfigurationProvider oakSolrConfigurationProvider;
-
- public SolrIndexEditorProvider(
- @NotNull SolrServerProvider solrServerProvider,
- @NotNull OakSolrConfigurationProvider oakSolrConfigurationProvider) {
- this.solrServerProvider = solrServerProvider;
- this.oakSolrConfigurationProvider = oakSolrConfigurationProvider;
- }
-
- @Override
- public Editor getIndexEditor(
- @NotNull String type, @NotNull NodeBuilder definition, @NotNull NodeState root, @NotNull IndexUpdateCallback callback)
- throws CommitFailedException {
- SolrIndexEditor editor = null;
- if (SolrQueryIndex.TYPE.equals(type)) {
- try {
- // if index definition contains a persisted configuration, use that
- if (isPersistedConfiguration(definition)) {
- NodeState nodeState = definition.getNodeState();
- OakSolrConfiguration configuration = new OakSolrNodeStateConfiguration(nodeState);
- SolrServerConfigurationProvider configurationProvider = new NodeStateSolrServerConfigurationProvider(definition.getChildNode("server").getNodeState());
- SolrClient solrServer = new OakSolrServer(configurationProvider);
- editor = getEditor(configuration, solrServer, callback);
- } else { // otherwise use the default configuration providers (e.g. defined via code or OSGi)
- OakSolrConfiguration configuration = oakSolrConfigurationProvider.getConfiguration();
- editor = getEditor(configuration, solrServerProvider.getIndexingSolrServer(), callback);
- }
- } catch (Exception e) {
- log.warn("could not get Solr index editor from {}", definition.getNodeState(), e);
- }
- }
- return editor;
- }
-
- private boolean isPersistedConfiguration(NodeBuilder definition) {
- return definition.hasChildNode("server");
- }
-
- private SolrIndexEditor getEditor(OakSolrConfiguration configuration, SolrClient solrServer,
- IndexUpdateCallback callback) {
- SolrIndexEditor editor = null;
- try {
- if (solrServer != null) {
- editor = new SolrIndexEditor(solrServer, configuration, callback);
- } else {
- if (log.isWarnEnabled()) {
- log.warn("no SolrServer provided, cannot perform indexing");
- }
- }
- } catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error("unable to create SolrIndexEditor", e);
- }
- }
- return editor;
- }
-
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/NodeStateSolrServersObserverService.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/NodeStateSolrServersObserverService.java
deleted file mode 100644
index 5dea6ef28d..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/NodeStateSolrServersObserverService.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.osgi;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.component.ComponentContext;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.metatype.annotations.Designate;
-import org.osgi.service.metatype.annotations.AttributeDefinition;
-import org.osgi.service.metatype.annotations.ObjectClassDefinition;
-
-import org.apache.jackrabbit.oak.osgi.OsgiWhiteboard;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate.NodeStateSolrServersObserver;
-import org.apache.jackrabbit.oak.spi.commit.BackgroundObserver;
-import org.apache.jackrabbit.oak.spi.commit.Observer;
-import org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard;
-import org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardExecutor;
-
-/**
- * An OSGi service for {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate.NodeStateSolrServersObserver}.
- * This allows correct cleanup of any persisted Solr server configurations once they get changed or deleted.
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Component(
- immediate = true
-)
-@Designate(
- ocd = NodeStateSolrServersObserverService.Configuration.class
-)
-@Deprecated(forRemoval=true, since="1.74.0")
-public class NodeStateSolrServersObserverService {
-
- @ObjectClassDefinition(
- id ="org.apache.jackrabbit.oak.plugins.index.solr.osgi.NodeStateSolrServersObserverService",
- name = "Apache Jackrabbit Oak Solr persisted configuration observer"
- )
- @interface Configuration {
- @AttributeDefinition(
- name = "enabled",
- description = "enable persisted configuration observer"
- )
- boolean enabled() default false;
- }
-
- private final NodeStateSolrServersObserver nodeStateSolrServersObserver = new NodeStateSolrServersObserver();
-
- private WhiteboardExecutor executor;
-
- private BackgroundObserver backgroundObserver;
-
- private List<ServiceRegistration> regs = new ArrayList<ServiceRegistration>();
-
- @Activate
- protected void activate(ComponentContext componentContext, Configuration configuration) throws Exception {
-
- boolean enabled = configuration.enabled();
-
- if (enabled) {
- BundleContext bundleContext = componentContext.getBundleContext();
- Whiteboard whiteboard = new OsgiWhiteboard(bundleContext);
- executor = new WhiteboardExecutor();
- executor.start(whiteboard);
-
- backgroundObserver = new BackgroundObserver(nodeStateSolrServersObserver, executor, 5);
- regs.add(bundleContext.registerService(Observer.class.getName(), backgroundObserver, null));
- }
- }
-
- @Deactivate
- protected void deactivate() throws Exception {
-
- for (ServiceRegistration reg : regs) {
- reg.unregister();
- }
-
- if (backgroundObserver != null) {
- backgroundObserver.close();
- }
-
- if (executor != null) {
- executor.stop();
- }
-
- }
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/OakSolrConfigurationProviderService.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/OakSolrConfigurationProviderService.java
deleted file mode 100644
index d389a56009..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/OakSolrConfigurationProviderService.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.osgi;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.metatype.annotations.Designate;
-import org.osgi.service.metatype.annotations.AttributeDefinition;
-import org.osgi.service.metatype.annotations.ObjectClassDefinition;
-import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationDefaults;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider;
-import org.apache.jackrabbit.oak.spi.query.Filter;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.osgi.service.metatype.annotations.Option;
-
-/**
- * OSGi service for {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider}
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Component(
- immediate = true,
- service = { OakSolrConfigurationProvider.class }
-)
-@Designate(
- ocd = OakSolrConfigurationProviderService.Configuration.class
-)
-@Deprecated(forRemoval=true, since="1.74.0")
-public class OakSolrConfigurationProviderService implements OakSolrConfigurationProvider {
-
- @ObjectClassDefinition(
- id = "org.apache.jackrabbit.oak.plugins.index.solr.osgi.OakSolrConfigurationProviderService",
- name = "Apache Jackrabbit Oak Solr indexing / search configuration" )
- @interface Configuration {
- @AttributeDefinition(
- name = "field for descendants search"
- )
- String path_desc_field() default OakSolrConfigurationDefaults.DESC_FIELD_NAME;
-
- @AttributeDefinition(
- name = "field for children search"
- )
- String path_child_field() default OakSolrConfigurationDefaults.CHILD_FIELD_NAME;
-
- @AttributeDefinition(
- name = "field for parent search"
- )
- String path_parent_field() default OakSolrConfigurationDefaults.ANC_FIELD_NAME;
-
- @AttributeDefinition(
- name = "field for path search"
- )
- String path_exact_field() default OakSolrConfigurationDefaults.PATH_FIELD_NAME;
-
- @AttributeDefinition(
- name = "catch all field"
- )
- String catch_all_field() default OakSolrConfigurationDefaults.CATCHALL_FIELD;
-
- @AttributeDefinition(
- name = "field for collapsing jcr:content paths"
- )
- String collapsed_path_field() default OakSolrConfigurationDefaults.COLLAPSED_PATH_FIELD;
-
- @AttributeDefinition(
- name = "field for path depth"
- )
- String path_depth_field() default OakSolrConfigurationDefaults.PATH_DEPTH_FIELD;
-
- @AttributeDefinition(
- name = "Property commit.policy",
- options = {
- @Option(value = "HARD",
- label = "Hard commit"
- ),
- @Option(value = "SOFT",
- label = "Soft commit"
- ),
- @Option(value = "AUTO",
- label = "Auto commit"
- )}
- )
- OakSolrConfiguration.CommitPolicy commit_policy() default OakSolrConfiguration.CommitPolicy.SOFT;
-
- @AttributeDefinition(
- name = "rows"
- )
- int rows() default OakSolrConfigurationDefaults.ROWS;
-
- @AttributeDefinition(
- name = "path restrictions"
- )
- boolean path_restrictions() default OakSolrConfigurationDefaults.PATH_RESTRICTIONS;
-
- @AttributeDefinition(
- name = "property restrictions"
- )
- boolean property_restrictions() default OakSolrConfigurationDefaults.PROPERTY_RESTRICTIONS;
-
- @AttributeDefinition(
- name = "primary types restrictions"
- )
- boolean primarytypes_restrictions() default OakSolrConfigurationDefaults.PRIMARY_TYPES;
-
- @AttributeDefinition(
- name = "ignored properties"
- )
- String[] ignored_properties() default {"rep:members", "rep:authorizableId", "jcr:uuid", "rep:principalName", "rep:password"};
-
- @AttributeDefinition(
- name = "used properties"
- )
- String[] used_properties();
-
- @AttributeDefinition(
- name = "mappings from Oak Types to Solr fields",
- description = "each item should be in the form TypeString=FieldName (e.g. STRING=text_general)",
- cardinality = 13
- )
- String[] type_mappings() default OakSolrConfigurationDefaults.TYPE_MAPPINGS;
-
- @AttributeDefinition(
- name = "mappings from JCR property names to Solr fields",
- description = "each item should be in the form PropertyName=FieldName (e.g. jcr:title=text_en)"
- )
- String[] property_mappings() default OakSolrConfigurationDefaults.PROPERTY_MAPPINGS;
-
- @AttributeDefinition(
- name = "collapse jcr:content nodes"
- )
- boolean collapse_jcrcontent_nodes() default OakSolrConfigurationDefaults.COLLAPSE_JCR_CONTENT_NODES;
-
- @AttributeDefinition(
- name = "collapse jcr:content parents"
- )
- boolean collapse_jcrcontent_parents() default OakSolrConfigurationDefaults.COLLAPSE_JCR_CONTENT_PARENTS;
- }
-
- private String pathChildrenFieldName;
- private String pathParentFieldName;
- private String pathDescendantsFieldName;
- private String pathExactFieldName;
- private String collapsedPathField;
- private String catchAllField;
- private OakSolrConfiguration.CommitPolicy commitPolicy;
- private int rows;
- private boolean useForPathRestrictions;
- private boolean useForPropertyRestrictions;
- private boolean useForPrimaryTypes;
- private String[] ignoredProperties;
- private String[] usedProperties;
- private String[] typeMappings;
- private String[] propertyMappings;
- private boolean collapseJcrContentNodes;
- private boolean collapseJcrContentParents;
- private String depthField;
-
- private OakSolrConfiguration oakSolrConfiguration;
-
- @Activate
- protected void activate(Configuration configuration) {
- pathChildrenFieldName = configuration.path_child_field();
- pathParentFieldName = configuration.path_parent_field();
- pathExactFieldName = configuration.path_exact_field();
- collapsedPathField = configuration.collapsed_path_field();
- pathDescendantsFieldName = configuration.path_desc_field();
- catchAllField = configuration.catch_all_field();
- depthField = configuration.path_depth_field();
- rows = configuration.rows();
- commitPolicy = configuration.commit_policy();
- useForPathRestrictions = configuration.path_restrictions();
- useForPropertyRestrictions = configuration.property_restrictions();
- useForPrimaryTypes = configuration.primarytypes_restrictions();
- typeMappings = configuration.type_mappings();
- ignoredProperties = configuration.ignored_properties();
- usedProperties = configuration.used_properties();
- propertyMappings = configuration.property_mappings();
- collapseJcrContentNodes = configuration.collapse_jcrcontent_nodes();
- collapseJcrContentParents = configuration.collapse_jcrcontent_parents();
- }
-
- @Deactivate
- protected void deactivate() {
- oakSolrConfiguration = null;
- }
-
- @NotNull
- @Override
- public OakSolrConfiguration getConfiguration() {
- if (oakSolrConfiguration == null) {
- oakSolrConfiguration = new OakSolrConfiguration() {
-
- @Override
- public String getFieldNameFor(Type<?> propertyType) {
- for (String typeMapping : typeMappings) {
- String[] mapping = typeMapping.split("=");
- if (mapping.length == 2 && mapping[0] != null && mapping[1] != null) {
- Type<?> type = Type.fromString(mapping[0]);
- if (type != null && type.tag() == propertyType.tag()) {
- return mapping[1];
- }
- }
- }
- return null;
- }
-
- @Override
- public String getFieldForPropertyRestriction(Filter.PropertyRestriction propertyRestriction) {
- for (String propertyMapping : propertyMappings) {
- String[] mapping = propertyMapping.split("=");
- if (mapping.length == 2 && mapping[0] != null && mapping[1] != null) {
- if (mapping[0].equals(propertyRestriction.propertyName)) {
- return mapping[1];
- }
- }
- }
- return null;
- }
-
- @NotNull
- @Override
- public String getPathField() {
- return pathExactFieldName;
- }
-
- @Nullable
- @Override
- public String getFieldForPathRestriction(Filter.PathRestriction pathRestriction) {
- String fieldName = null;
- switch (pathRestriction) {
- case ALL_CHILDREN: {
- fieldName = pathDescendantsFieldName;
- break;
- }
- case DIRECT_CHILDREN: {
- fieldName = pathChildrenFieldName;
- break;
- }
- case EXACT: {
- fieldName = pathExactFieldName;
- break;
- }
- case PARENT: {
- fieldName = pathParentFieldName;
- break;
- }
- case NO_RESTRICTION:
- break;
- default:
- break;
-
- }
- return fieldName;
- }
-
- @NotNull
- @Override
- public CommitPolicy getCommitPolicy() {
- return commitPolicy;
- }
-
- @Override
- public String getCatchAllField() {
- return catchAllField;
- }
-
- @Override
- public int getRows() {
- return rows;
- }
-
- @Override
- public boolean useForPropertyRestrictions() {
- return useForPropertyRestrictions;
- }
-
- @Override
- public boolean useForPrimaryTypes() {
- return useForPrimaryTypes;
- }
-
- @Override
- public boolean useForPathRestrictions() {
- return useForPathRestrictions;
- }
-
- @NotNull
- @Override
- public Collection<String> getIgnoredProperties() {
- if (ignoredProperties != null && ignoredProperties.length > 0 && ignoredProperties[0].length() > 0) {
- return Arrays.asList(ignoredProperties);
- } else {
- return Collections.emptyList();
- }
- }
-
- @NotNull
- @Override
- public Collection<String> getUsedProperties() {
- if (usedProperties != null && usedProperties.length > 0 && usedProperties[0].length() > 0) {
- return Arrays.asList(usedProperties);
- } else {
- return Collections.emptyList();
- }
- }
-
- @Override
- public boolean collapseJcrContentNodes() {
- return collapseJcrContentNodes;
- }
-
- @Override
- public boolean collapseJcrContentParents() {
- return collapseJcrContentParents;
- }
-
- @NotNull
- @Override
- public String getCollapsedPathField() {
- return collapsedPathField;
- }
-
- @Override
- public String getPathDepthField() {
- return depthField;
- }
- };
- }
- return oakSolrConfiguration;
- }
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/RemoteSolrServerConfigurationProvider.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/RemoteSolrServerConfigurationProvider.java
deleted file mode 100644
index 57bd587e8c..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/RemoteSolrServerConfigurationProvider.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.osgi;
-
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.metatype.annotations.Designate;
-import org.osgi.service.metatype.annotations.AttributeDefinition;
-import org.osgi.service.metatype.annotations.ObjectClassDefinition;
-
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.RemoteSolrServerConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationDefaults;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.server.RemoteSolrServerProvider;
-
-import org.jetbrains.annotations.NotNull;
-
-/**
- * {@link org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider} for remote Solr installations.
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Component(
- immediate = true,
- service = { SolrServerConfigurationProvider.class }
-)
-@Designate(
- ocd = RemoteSolrServerConfigurationProvider.Configuration.class
-)
-@Deprecated(forRemoval=true, since="1.74.0")
-public class RemoteSolrServerConfigurationProvider implements SolrServerConfigurationProvider<RemoteSolrServerProvider> {
-
- @ObjectClassDefinition(
- id = "org.apache.jackrabbit.oak.plugins.index.solr.osgi.RemoteSolrServerConfigurationProvider",
- name = "Apache Jackrabbit Oak Solr remote server configuration"
- )
- @interface Configuration {
- @AttributeDefinition(
- name = "Solr HTTP URL"
- )
- String solr_http_url() default SolrServerConfigurationDefaults.HTTP_URL;
-
- @AttributeDefinition(
- name = "ZooKeeper host"
- )
- String solr_zk_host() default SolrServerConfigurationDefaults.ZK_HOST;
-
- @AttributeDefinition(
- name = "Solr collection"
- )
- String solr_collection() default SolrServerConfigurationDefaults.COLLECTION;
-
- @AttributeDefinition(
- name = "Socket timeout (ms)"
- )
- int solr_socket_timeout() default SolrServerConfigurationDefaults.SOCKET_TIMEOUT;
-
- @AttributeDefinition(
- name = "Connection timeout (ms)"
- )
- int solr_connection_timeout() default SolrServerConfigurationDefaults.CONNECTION_TIMEOUT;
-
- @AttributeDefinition(
- name = "No. of collection shards"
- )
- int solr_shards_no() default SolrServerConfigurationDefaults.SHARDS_NO;
-
- @AttributeDefinition(
- name = "Replication factor"
- )
- int solr_replication_factor() default SolrServerConfigurationDefaults.REPLICATION_FACTOR;
-
- @AttributeDefinition(
- name = "Solr configuration directory"
- )
- String solr_conf_dir() default SolrServerConfigurationDefaults.CONFIGURATION_DIRECTORY;
-
- String name() default "remote";
- }
-
- private String solrHttpUrl;
- private String solrZkHost;
- private String solrCollection;
- private Integer solrShardsNo;
- private Integer solrReplicationFactor;
- private String solrConfDir;
- private RemoteSolrServerConfiguration remoteSolrServerConfiguration;
-
- @Activate
- protected void activate(Configuration configuration) throws Exception {
- solrHttpUrl = configuration.solr_http_url();
- solrZkHost = configuration.solr_zk_host();
- solrCollection = configuration.solr_collection();
- solrShardsNo = configuration.solr_shards_no();
- solrReplicationFactor = configuration.solr_replication_factor();
- solrConfDir = configuration.solr_conf_dir();
- int socketTimeout = configuration.solr_socket_timeout();
- int connectionTimeout = configuration.solr_connection_timeout();
- remoteSolrServerConfiguration = new RemoteSolrServerConfiguration(solrZkHost, solrCollection, solrShardsNo,
- solrReplicationFactor, solrConfDir, socketTimeout, connectionTimeout, solrHttpUrl);
- }
-
- @Deactivate
- protected void deactivate() throws Exception {
- solrHttpUrl = null;
- solrZkHost = null;
- solrCollection = null;
- solrShardsNo = 0;
- solrReplicationFactor = 0;
- solrConfDir = null;
- }
-
-
- @NotNull
- @Override
- public SolrServerConfiguration<RemoteSolrServerProvider> getSolrServerConfiguration() {
- return remoteSolrServerConfiguration;
- }
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrIndexEditorProviderService.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrIndexEditorProviderService.java
deleted file mode 100644
index 732bf1b873..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrIndexEditorProviderService.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.osgi;
-
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Reference;
-
-import org.apache.jackrabbit.oak.api.CommitFailedException;
-import org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider;
-import org.apache.jackrabbit.oak.plugins.index.IndexUpdateCallback;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.index.SolrIndexEditorProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider;
-import org.apache.jackrabbit.oak.spi.commit.Editor;
-import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Osgi Service that provides Solr based {@link org.apache.jackrabbit.oak.plugins.index.IndexEditor}s
- *
- * @see org.apache.jackrabbit.oak.plugins.index.solr.index.SolrIndexEditorProvider
- * @see org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Component(
- immediate = true,
- service = { IndexEditorProvider.class }
-)
-@Deprecated(forRemoval=true, since="1.74.0")
-public class SolrIndexEditorProviderService implements IndexEditorProvider {
-
- @Reference
- private SolrServerProvider solrServerProvider;
-
- @Reference
- private OakSolrConfigurationProvider oakSolrConfigurationProvider;
-
- @Override
- @Nullable
- public Editor getIndexEditor(@NotNull String type, @NotNull NodeBuilder definition,
- @NotNull NodeState root, @NotNull IndexUpdateCallback callback) throws CommitFailedException {
- if (solrServerProvider != null && oakSolrConfigurationProvider != null) {
- return new SolrIndexEditorProvider(solrServerProvider,
- oakSolrConfigurationProvider).getIndexEditor(type, definition, root, callback);
- } else {
- return null;
- }
- }
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrQueryIndexProviderService.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrQueryIndexProviderService.java
deleted file mode 100644
index 10b54f6443..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrQueryIndexProviderService.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.osgi;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.component.ComponentContext;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.osgi.service.component.annotations.ReferencePolicy;
-import org.osgi.service.component.annotations.ReferencePolicyOption;
-import org.osgi.service.metatype.annotations.Designate;
-import org.osgi.service.metatype.annotations.ObjectClassDefinition;
-import org.osgi.service.metatype.annotations.AttributeDefinition;
-import org.apache.jackrabbit.oak.commons.PropertiesUtil;
-import org.apache.jackrabbit.oak.plugins.index.aggregate.AggregateIndexProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndexProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider;
-import org.apache.jackrabbit.oak.spi.query.QueryIndex;
-import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Osgi Service that provides Solr based {@link org.apache.jackrabbit.oak.spi.query.QueryIndex}es
- *
- * @see org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndexProvider
- * @see QueryIndexProvider
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Component(
- immediate = true
-)
-@Designate(
- ocd = SolrQueryIndexProviderService.Configuration.class
-)
-@Deprecated(forRemoval=true, since="1.74.0")
-public class SolrQueryIndexProviderService {
-
- @ObjectClassDefinition(
- id = "org.apache.jackrabbit.oak.plugins.index.solr.osgi.SolrQueryIndexProviderService",
- name = "Apache Jackrabbit Oak Solr Query index provider configuration"
- )
- @interface Configuration {
- @AttributeDefinition(
- name ="query time aggregation",
- description = "enable query time aggregation for Solr index"
- )
- boolean query_aggregation() default QUERY_TIME_AGGREGATION_DEFAULT;
- }
-
- private static final boolean QUERY_TIME_AGGREGATION_DEFAULT = true;
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private final List<ServiceRegistration> regs = new ArrayList<>();
-
- @Reference
- private SolrServerProvider solrServerProvider;
-
- @Reference
- private OakSolrConfigurationProvider oakSolrConfigurationProvider;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY,
- policyOption = ReferencePolicyOption.GREEDY,
- policy = ReferencePolicy.DYNAMIC
- )
- private volatile QueryIndex.NodeAggregator nodeAggregator;
-
- @SuppressWarnings("UnusedDeclaration")
- @Activate
- protected void activate(ComponentContext componentContext, Configuration configuration) {
- boolean queryTimeAggregation = configuration.query_aggregation();
- 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));
- }
- }
-
- @SuppressWarnings("UnusedDeclaration")
- @Deactivate
- protected void deactivate() {
-
- for (ServiceRegistration registration : regs) {
- registration.unregister();
- }
- }
-
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrServerProviderService.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrServerProviderService.java
deleted file mode 100644
index 169fc6ed0f..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrServerProviderService.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.osgi;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.osgi.service.component.annotations.ReferencePolicy;
-import org.osgi.service.metatype.annotations.Designate;
-import org.osgi.service.metatype.annotations.ObjectClassDefinition;
-import org.osgi.service.metatype.annotations.AttributeDefinition;
-import org.osgi.service.metatype.annotations.Option;
-
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.server.OakSolrServer;
-import org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider;
-
-import org.apache.solr.client.solrj.SolrClient;
-
-import org.jetbrains.annotations.Nullable;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * OSGi service for {@link org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider}
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Component(
- immediate = true,
- service = { SolrServerProvider.class },
- reference = {
- @Reference(
- name = "solrServerConfigurationProvider",
- service = SolrServerConfigurationProvider.class,
- cardinality = ReferenceCardinality.AT_LEAST_ONE,
- policy = ReferencePolicy.DYNAMIC,
- bind = "bindSolrServerConfigurationProvider",
- unbind = "unbindSolrServerConfigurationProvider",
- updated = "updatedSolrServerConfigurationProvider"
- )
- }
-)
-@Designate(
- ocd = SolrServerProviderService.Configuration.class
-)
-@Deprecated(forRemoval=true, since="1.74.0")
-public class SolrServerProviderService implements SolrServerProvider {
-
- @ObjectClassDefinition(
- id = "org.apache.jackrabbit.oak.plugins.index.solr.osgi.SolrServerProviderService",
- name = "Apache Jackrabbit Oak Solr server provider"
- )
- @interface Configuration {
- @AttributeDefinition(
- name = "Property server.type",
- options = {
- @Option(value = "none",
- label = "None"
- ),
- @Option(value = "embedded",
- label = "Embedded Solr"
- ),
- @Option(value = "remote",
- label = "Remote Solr"
- )}
- )
- OakSolrConfiguration.ServerType server_type() default OakSolrConfiguration.ServerType.none;
- }
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private final Map<String, SolrServerConfigurationProvider> solrServerConfigurationProviders = new HashMap<String, SolrServerConfigurationProvider>();
-
- private String serverType;
-
- private SolrClient cachedSolrServer;
-
- @Activate
- protected void activate(Configuration configuration) throws Exception {
- serverType = configuration.server_type().toString();
- }
-
- @Deactivate
- protected void deactivate() throws Exception {
- solrServerConfigurationProviders.clear();
- close();
- }
-
- @Override
- public void close() throws IOException {
- if (cachedSolrServer != null) {
- try {
- cachedSolrServer.close();
- } catch (Exception e) {
- log.error("could not correctly shutdown Solr {} server {}", serverType, cachedSolrServer);
- } finally {
- cachedSolrServer = null;
- }
- }
- }
-
- protected void bindSolrServerConfigurationProvider(final SolrServerConfigurationProvider solrServerConfigurationProvider, Map<String, Object> properties) {
- synchronized (solrServerConfigurationProviders) {
- String name = String.valueOf(properties.get("name"));
- solrServerConfigurationProviders.put(name, solrServerConfigurationProvider);
- try {
- close();
- } catch (IOException e) {
- // do nothing
- }
- }
- }
-
- protected void unbindSolrServerConfigurationProvider(final SolrServerConfigurationProvider solrServerConfigurationProvider, Map<String, Object> properties) {
- synchronized (solrServerConfigurationProviders) {
- String name = String.valueOf(properties.get("name"));
- solrServerConfigurationProviders.remove(name);
- try {
- close();
- } catch (IOException e) {
- // do nothing
- }
- }
- }
-
- protected void updatedSolrServerConfigurationProvider(final SolrServerConfigurationProvider solrServerConfigurationProvider, Map<String, Object> properties) {
- synchronized (solrServerConfigurationProviders) {
- String name = String.valueOf(properties.get("name"));
- solrServerConfigurationProviders.put(name, solrServerConfigurationProvider);
- try {
- close();
- } catch (IOException e) {
- // do nothing
- }
- }
- }
-
- @Nullable
- @Override
- public SolrClient getSolrServer() throws Exception {
- synchronized (solrServerConfigurationProviders) {
- if (cachedSolrServer == null) {
- cachedSolrServer = getServer();
- }
- return cachedSolrServer;
- }
- }
-
- @Nullable
- @Override
- public SolrClient getIndexingSolrServer() throws Exception {
- return getSolrServer();
- }
-
- @Nullable
- @Override
- public SolrClient getSearchingSolrServer() throws Exception {
- return getSolrServer();
- }
-
- private SolrClient getServer() {
- SolrClient solrServer = null;
- if (serverType != null && !"none".equals(serverType)) {
- SolrServerConfigurationProvider solrServerConfigurationProvider = solrServerConfigurationProviders.get(serverType);
- if (solrServerConfigurationProvider != null) {
- try {
- solrServer = new OakSolrServer(solrServerConfigurationProvider);
- log.info("created new SolrServer {}", solrServer);
- } catch (Exception e) {
- log.error("could not get a SolrServerProvider of type {}", serverType, e);
- }
- }
- }
- return solrServer;
- }
-
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/FilterQueryParser.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/FilterQueryParser.java
deleted file mode 100644
index 6b0bba6afb..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/FilterQueryParser.java
+++ /dev/null
@@ -1,401 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.query;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.jackrabbit.JcrConstants;
-import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration;
-import org.apache.jackrabbit.oak.spi.query.fulltext.FullTextAnd;
-import org.apache.jackrabbit.oak.spi.query.fulltext.FullTextContains;
-import org.apache.jackrabbit.oak.spi.query.fulltext.FullTextExpression;
-import org.apache.jackrabbit.oak.spi.query.fulltext.FullTextOr;
-import org.apache.jackrabbit.oak.spi.query.fulltext.FullTextTerm;
-import org.apache.jackrabbit.oak.spi.query.fulltext.FullTextVisitor;
-import org.apache.jackrabbit.oak.spi.query.Filter;
-import org.apache.jackrabbit.oak.spi.query.QueryConstants;
-import org.apache.jackrabbit.oak.spi.query.QueryIndex;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.apache.jackrabbit.oak.commons.PathUtils.getName;
-import static org.apache.jackrabbit.oak.plugins.index.solr.util.SolrUtils.getSortingField;
-import static org.apache.jackrabbit.oak.plugins.index.solr.util.SolrUtils.partialEscape;
-
-/**
- * the {@link FilterQueryParser} can parse {@link org.apache.jackrabbit.oak.spi.query.Filter}s
- * and transform them into {@link org.apache.solr.client.solrj.SolrQuery}s and / or Solr query {@code String}s.
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-class FilterQueryParser {
-
- private static final Logger log = LoggerFactory.getLogger(FilterQueryParser.class);
-
- static SolrQuery getQuery(Filter filter, QueryIndex.IndexPlan plan, OakSolrConfiguration configuration) {
-
- SolrQuery solrQuery = new SolrQuery();
- setDefaults(solrQuery, configuration);
-
- StringBuilder queryBuilder = new StringBuilder();
-
- FullTextExpression ft = filter.getFullTextConstraint();
- if (ft != null) {
- queryBuilder.append(parseFullTextExpression(ft, configuration));
- queryBuilder.append(' ');
- } else if (filter.getFulltextConditions() != null) {
- Collection<String> fulltextConditions = filter.getFulltextConditions();
- for (String fulltextCondition : fulltextConditions) {
- queryBuilder.append(fulltextCondition).append(" ");
- }
- }
-
- if (plan != null && plan.getSortOrder() != null) {
- List<QueryIndex.OrderEntry> sortOrder = plan.getSortOrder();
- for (QueryIndex.OrderEntry orderEntry : sortOrder) {
- SolrQuery.ORDER order;
- if (QueryIndex.OrderEntry.Order.ASCENDING.equals(orderEntry.getOrder())) {
- order = SolrQuery.ORDER.asc;
- } else {
- order = SolrQuery.ORDER.desc;
- }
- String sortingField;
- if (JcrConstants.JCR_PATH.equals(orderEntry.getPropertyName())) {
- sortingField = partialEscape(configuration.getPathField()).toString();
- } else if (JcrConstants.JCR_SCORE.equals(orderEntry.getPropertyName())) {
- sortingField = "score";
- } else {
- if (orderEntry.getPropertyName().indexOf('/') >= 0) {
- log.warn("cannot sort on relative properties, ignoring {} clause", orderEntry);
- continue; // sorting by relative properties not supported until index time aggregation is supported
- }
- sortingField = partialEscape(getSortingField(orderEntry.getPropertyType().tag(), orderEntry.getPropertyName())).toString();
- }
- solrQuery.addOrUpdateSort(sortingField, order);
- }
- }
-
- Collection<Filter.PropertyRestriction> propertyRestrictions = filter.getPropertyRestrictions();
- if (propertyRestrictions != null && !propertyRestrictions.isEmpty()) {
- for (Filter.PropertyRestriction pr : propertyRestrictions) {
- if (pr.isNullRestriction()) {
- // can not use full "x is null"
- continue;
- }
- // facets
- if (QueryConstants.REP_FACET.equals(pr.propertyName)) {
- solrQuery.setFacetMinCount(1);
- solrQuery.setFacet(true);
- String value = pr.first.getValue(Type.STRING);
- solrQuery.addFacetField(value.substring(QueryConstants.REP_FACET.length() + 1, value.length() - 1) + "_facet");
- }
-
- // native query support
- if (SolrQueryIndex.NATIVE_SOLR_QUERY.equals(pr.propertyName) || SolrQueryIndex.NATIVE_LUCENE_QUERY.equals(pr.propertyName)) {
- String nativeQueryString = String.valueOf(pr.first.getValue(pr.first.getType()));
- if (isSupportedHttpRequest(nativeQueryString)) {
- // pass through the native HTTP Solr request
- String requestHandlerString = nativeQueryString.substring(0, nativeQueryString.indexOf('?'));
- if (!"select".equals(requestHandlerString)) {
- if (requestHandlerString.charAt(0) != '/') {
- requestHandlerString = "/" + requestHandlerString;
- }
- solrQuery.setRequestHandler(requestHandlerString);
- }
- String parameterString = nativeQueryString.substring(nativeQueryString.indexOf('?') + 1);
- for (String param : parameterString.split("&")) {
- String[] kv = param.split("=");
- if (kv.length != 2) {
- throw new RuntimeException("Unparsable native HTTP Solr query");
- } else {
- // more like this
- if ("/mlt".equals(requestHandlerString)) {
- if ("stream.body".equals(kv[0])) {
- kv[0] = "q";
- String mltFlString = "mlt.fl=";
- int mltFlIndex = parameterString.indexOf(mltFlString);
- if (mltFlIndex > -1) {
- int beginIndex = mltFlIndex + mltFlString.length();
- int endIndex = parameterString.indexOf('&', beginIndex);
- String fields;
- if (endIndex > beginIndex) {
- fields = parameterString.substring(beginIndex, endIndex);
- } else {
- fields = parameterString.substring(beginIndex);
- }
- kv[1] = "_query_:\"{!dismax qf=" + fields + " q.op=OR}" + kv[1] + "\"";
- }
- }
- if ("mlt.fl".equals(kv[0]) && ":path".equals(kv[1])) {
- // rep:similar passes the path of the node to find similar documents for in the :path
- // but needs its indexed content to find similar documents
- kv[1] = configuration.getCatchAllField();
- }
- }
- if ("/spellcheck".equals(requestHandlerString)) {
- if ("term".equals(kv[0])) {
- kv[0] = "spellcheck.q";
- }
- solrQuery.setParam("spellcheck", true);
- }
- if ("/suggest".equals(requestHandlerString)) {
- if ("term".equals(kv[0])) {
- kv[0] = "suggest.q";
- }
- solrQuery.setParam("suggest", true);
- }
- solrQuery.setParam(kv[0], kv[1]);
- }
- }
- return solrQuery;
- } else {
- queryBuilder.append(nativeQueryString);
- }
- } else {
- if (SolrQueryIndex.isIgnoredProperty(pr, configuration)) {
- continue;
- }
-
- String first = null;
- if (pr.first != null) {
- first = partialEscape(String.valueOf(pr.first.getValue(pr.first.getType()))).toString();
- }
- String last = null;
- if (pr.last != null) {
- last = partialEscape(String.valueOf(pr.last.getValue(pr.last.getType()))).toString();
- }
-
- String prField = configuration.getFieldForPropertyRestriction(pr);
- CharSequence fieldName = partialEscape(prField != null ?
- prField : pr.propertyName);
- if ("jcr\\:path".equals(fieldName.toString())) {
- queryBuilder.append(configuration.getPathField());
- queryBuilder.append(':');
- queryBuilder.append(first);
- } else {
- if (pr.first != null && pr.last != null && pr.first.equals(pr.last)) {
- queryBuilder.append(fieldName).append(':');
- queryBuilder.append(first);
- } else if (pr.first == null && pr.last == null) {
- if (!queryBuilder.toString().contains(fieldName + ":")) {
- queryBuilder.append(fieldName).append(':');
- queryBuilder.append('*');
- }
- } else if ((pr.first != null && pr.last == null) || (pr.last != null && pr.first == null) || (!pr.first.equals(pr.last))) {
- // TODO : need to check if this works for all field types (most likely not!)
- queryBuilder.append(fieldName).append(':');
- queryBuilder.append(createRangeQuery(first, last, pr.firstIncluding, pr.lastIncluding));
- } else if (pr.isLike) {
- // TODO : the current parameter substitution is not expected to work well
- queryBuilder.append(fieldName).append(':');
- queryBuilder.append(partialEscape(String.valueOf(pr.first.getValue(pr.first.getType())).replace('%', '*').replace('_', '?')));
- } else {
- throw new RuntimeException("[unexpected!] not handled case");
- }
- }
- }
- queryBuilder.append(" ");
- }
- }
-
- if (configuration.useForPrimaryTypes()) {
- String[] pts = filter.getPrimaryTypes().toArray(new String[filter.getPrimaryTypes().size()]);
- StringBuilder ptQueryBuilder = new StringBuilder();
- for (int i = 0; i < pts.length; i++) {
- String pt = pts[i];
- if (i == 0) {
- ptQueryBuilder.append("(");
- }
- if (i > 0 && i < pts.length) {
- ptQueryBuilder.append("OR ");
- }
- ptQueryBuilder.append("jcr\\:primaryType").append(':').append(partialEscape(pt)).append(" ");
- if (i == pts.length - 1) {
- ptQueryBuilder.append(")");
- ptQueryBuilder.append(' ');
- }
- }
- solrQuery.addFilterQuery(ptQueryBuilder.toString());
- }
-
- if (filter.getQueryStatement() != null && filter.getQueryStatement().contains(QueryConstants.REP_EXCERPT)) {
- if (!solrQuery.getHighlight()) {
- // enable highlighting
- solrQuery.setHighlight(true);
- // defaults
- solrQuery.set("hl.fl", "*");
- solrQuery.set("hl.encoder", "html");
- solrQuery.set("hl.mergeContiguous", true);
- solrQuery.setHighlightSimplePre("<strong>");
- solrQuery.setHighlightSimplePost("</strong>");
- }
- }
-
- if (configuration.useForPathRestrictions()) {
- Filter.PathRestriction pathRestriction = filter.getPathRestriction();
- if (pathRestriction != null) {
- String path = purgePath(filter, plan.getPathPrefix());
- String fieldName = configuration.getFieldForPathRestriction(pathRestriction);
- if (fieldName != null) {
- if (pathRestriction.equals(Filter.PathRestriction.ALL_CHILDREN)) {
- solrQuery.addFilterQuery(fieldName + ':' + path);
- } else {
- queryBuilder.append(fieldName);
- queryBuilder.append(':');
- queryBuilder.append(path);
- }
- }
- }
- }
-
- if (configuration.collapseJcrContentNodes()) {
- solrQuery.addFilterQuery("{!collapse field=" + configuration.getCollapsedPathField() + " min=" +
- configuration.getPathDepthField() + " hint=top_fc nullPolicy=expand}");
- }
-
- if (queryBuilder.length() == 0) {
- queryBuilder.append("*:*");
- }
- String escapedQuery = queryBuilder.toString();
- solrQuery.setQuery(escapedQuery);
-
- if (log.isDebugEnabled()) {
- log.debug("JCR query {} has been converted to Solr query {}",
- filter.getQueryStatement(), solrQuery.toString());
- }
-
- return solrQuery;
- }
-
- private static String parseFullTextExpression(FullTextExpression ft, final OakSolrConfiguration configuration) {
- final StringBuilder fullTextString = new StringBuilder();
- ft.accept(new FullTextVisitor() {
-
- @Override
- public boolean visit(FullTextOr or) {
- fullTextString.append('(');
- for (int i = 0; i < or.list.size(); i++) {
- FullTextExpression e = or.list.get(i);
- if (e.toString().contains("\"OR\"")) {
- continue;
- }
- if (i > 0 && i < or.list.size()) {
- fullTextString.append(" OR ");
- }
- String orTerm = parseFullTextExpression(e, configuration);
- fullTextString.append(orTerm);
- }
- fullTextString.append(')');
- fullTextString.append(' ');
- return true;
- }
-
- @Override
- public boolean visit(FullTextContains contains) {
- return contains.getBase().accept(this);
- }
-
- @Override
- public boolean visit(FullTextAnd and) {
- fullTextString.append('(');
- for (int i = 0; i < and.list.size(); i++) {
- FullTextExpression e = and.list.get(i);
- if (e.toString().contains("\"AND\"")) {
- continue;
- }
- if (i > 0 && i < and.list.size()) {
- fullTextString.append(" AND ");
- }
- String andTerm = parseFullTextExpression(e, configuration);
- fullTextString.append(andTerm);
- }
- fullTextString.append(')');
- fullTextString.append(' ');
- return true;
- }
-
- @Override
- public boolean visit(FullTextTerm term) {
- if (term.isNot()) {
- fullTextString.append('-');
- }
- String p = term.getPropertyName();
- if (p != null && p.indexOf('/') >= 0) {
- p = getName(p);
- }
- if (p == null || "*".equals(p)) {
- p = configuration.getCatchAllField();
- }
- fullTextString.append(partialEscape(p));
- fullTextString.append(':');
- String termText = term.getText();
- if (termText.indexOf(' ') > 0) {
- fullTextString.append('"');
- }
- fullTextString.append(termText.replace("/", "\\/").replace(":", "\\:"));
- if (termText.indexOf(' ') > 0) {
- fullTextString.append('"');
- }
- String boost = term.getBoost();
- if (boost != null) {
- fullTextString.append('^');
- fullTextString.append(boost);
- }
- fullTextString.append(' ');
- return true;
- }
- });
- return fullTextString.toString();
- }
-
- private static boolean isSupportedHttpRequest(String nativeQueryString) {
- // the query string starts with ${supported-handler.selector}?
- return nativeQueryString.matches("(suggest|spellcheck|mlt|query|select|get)\\\\?.*");
- }
-
- private static void setDefaults(SolrQuery solrQuery, OakSolrConfiguration configuration) {
- solrQuery.setParam("q.op", "AND");
- solrQuery.setParam("fl", configuration.getPathField() + " score");
- String catchAllField = configuration.getCatchAllField();
- if (catchAllField != null && catchAllField.length() > 0) {
- solrQuery.setParam("df", catchAllField);
- }
-
- solrQuery.setParam("rows", String.valueOf(configuration.getRows()));
- }
-
- private static String createRangeQuery(String first, String last, boolean firstIncluding, boolean lastIncluding) {
- // TODO : handle inclusion / exclusion of bounds
- return "[" + (first != null ? first : "*") + " TO " + (last != null ? last : "*") + "]";
- }
-
- private static String purgePath(Filter filter, String pathPrefix) {
- String path = filter.getPath();
- if (pathPrefix != null && pathPrefix.length() > 1 && path.startsWith(pathPrefix)) {
- path = path.substring(pathPrefix.length());
- if (path.length() == 0) {
- path = "/";
- }
- }
- return partialEscape(path).toString();
- }
-
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexLookup.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexLookup.java
deleted file mode 100644
index 7827501b80..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexLookup.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.jackrabbit.oak.plugins.index.solr.query;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.jackrabbit.oak.commons.PathUtils;
-import org.apache.jackrabbit.oak.spi.query.Filter;
-import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NAME;
-import static org.apache.jackrabbit.oak.plugins.index.solr.util.SolrIndexInitializer.isSolrIndexNode;
-
-/**
- * Lookup for Solr indexes to be used for a given {@link Filter}.
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-class SolrIndexLookup {
-
- private static final Logger log = LoggerFactory.getLogger(SolrIndexLookup.class);
-
- private final NodeState root;
-
- SolrIndexLookup(NodeState root) {
- this.root = root;
- }
-
- Collection<String> collectIndexNodePaths(Filter filter) {
- return collectIndexNodePaths(filter, true);
- }
-
- private Collection<String> collectIndexNodePaths(Filter filter, boolean recurse) {
- Set<String> paths = new HashSet<>();
-
- collectIndexNodePaths(root, "/", paths);
-
- if (recurse) {
- StringBuilder sb = new StringBuilder();
- NodeState nodeState = root;
- for (String element : PathUtils.elements(filter.getPath())) {
- nodeState = nodeState.getChildNode(element);
- collectIndexNodePaths(nodeState,
- sb.append("/").append(element).toString(),
- paths);
- }
- }
-
- return paths;
- }
-
- private static void collectIndexNodePaths(NodeState nodeState, String parentPath, Collection<String> paths) {
- NodeState state = nodeState.getChildNode(INDEX_DEFINITIONS_NAME);
- for (ChildNodeEntry entry : state.getChildNodeEntries()) {
- if (isSolrIndexNode(entry.getNodeState())) {
- String indexNodePath = createIndexNodePath(parentPath, entry.getName());
- log.debug("found Solr index node at {}", indexNodePath);
- paths.add(indexNodePath);
- }
- }
- }
-
- private static String createIndexNodePath(String parentPath, String name) {
- return PathUtils.concat(parentPath, INDEX_DEFINITIONS_NAME, name);
- }
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java
deleted file mode 100644
index 3de97d4653..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java
+++ /dev/null
@@ -1,834 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.query;
-
-import java.io.IOException;
-import java.util.*;
-
-import org.apache.jackrabbit.guava.common.collect.AbstractIterator;
-import org.apache.jackrabbit.JcrConstants;
-import org.apache.jackrabbit.oak.api.PropertyValue;
-import org.apache.jackrabbit.oak.api.Result.SizePrecision;
-import org.apache.jackrabbit.oak.commons.PathUtils;
-import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
-import org.apache.jackrabbit.oak.commons.json.JsopBuilder;
-import org.apache.jackrabbit.oak.commons.json.JsopWriter;
-import org.apache.jackrabbit.oak.plugins.index.cursor.PathCursor;
-import org.apache.jackrabbit.oak.plugins.index.search.FieldNames;
-import org.apache.jackrabbit.oak.plugins.index.search.util.LMSEstimator;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate.NodeStateSolrServerConfigurationProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate.OakSolrNodeStateConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.server.OakSolrServer;
-import org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider;
-import org.apache.jackrabbit.oak.spi.query.fulltext.FullTextExpression;
-import org.apache.jackrabbit.oak.spi.query.fulltext.FullTextTerm;
-import org.apache.jackrabbit.oak.spi.query.fulltext.FullTextVisitor;
-import org.apache.jackrabbit.oak.spi.query.Cursor;
-import org.apache.jackrabbit.oak.spi.query.Filter;
-import org.apache.jackrabbit.oak.spi.query.IndexRow;
-import org.apache.jackrabbit.oak.plugins.memory.PropertyValues;
-import org.apache.jackrabbit.oak.spi.query.QueryConstants;
-import org.apache.jackrabbit.oak.spi.query.QueryIndex;
-import org.apache.jackrabbit.oak.spi.query.QueryIndex.FulltextQueryIndex;
-import org.apache.jackrabbit.oak.spi.query.QueryLimits;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.solr.client.solrj.SolrClient;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.response.FacetField;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.client.solrj.response.SpellCheckResponse;
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrDocumentList;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.SimpleOrderedMap;
-import org.jetbrains.annotations.Nullable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.apache.jackrabbit.oak.commons.PathUtils.*;
-import static org.apache.jackrabbit.oak.plugins.index.solr.util.SolrIndexInitializer.isSolrIndexNode;
-
-/**
- * A Solr based {@link QueryIndex}
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class SolrQueryIndex implements FulltextQueryIndex, QueryIndex.AdvanceFulltextQueryIndex {
-
- public static final String TYPE = "solr";
-
- static final String NATIVE_SOLR_QUERY = "native*solr";
-
- static final String NATIVE_LUCENE_QUERY = "native*lucene";
-
- private static double MIN_COST = 2.3;
-
- private final Logger log = LoggerFactory.getLogger(SolrQueryIndex.class);
-
- private final NodeAggregator aggregator;
- private final OakSolrConfigurationProvider fallbackOakSolrConfigurationProvider;
- private final SolrServerProvider fallbackSolrServerProvider;
-
- private static final Map<String, LMSEstimator> estimators = new WeakHashMap<String, LMSEstimator>();
-
- public SolrQueryIndex(NodeAggregator aggregator, OakSolrConfigurationProvider oakSolrConfigurationProvider, SolrServerProvider solrServerProvider) {
- this.aggregator = aggregator;
- this.fallbackOakSolrConfigurationProvider = oakSolrConfigurationProvider;
- this.fallbackSolrServerProvider = solrServerProvider;
- }
-
- @Override
- public double getMinimumCost() {
- return MIN_COST;
- }
-
- @Override
- public String getIndexName() {
- return "solr";
- }
-
- @Override
- public double getCost(Filter filter, NodeState root) {
- throw new UnsupportedOperationException("Not supported as implementing AdvancedQueryIndex");
- }
-
- int getMatchingFilterRestrictions(Filter filter, OakSolrConfiguration configuration) {
- int match = 0;
-
- // full text expressions OR full text conditions defined
- if (filter.getFullTextConstraint() != null || (filter.getFulltextConditions() != null
- && filter.getFulltextConditions().size() > 0)) {
- match++; // full text queries have usually a significant recall
- }
-
- // property restriction OR native language property restriction defined AND property restriction handled
- if (filter.getPropertyRestrictions() != null
- && filter.getPropertyRestrictions().size() > 0
- && (filter.getPropertyRestriction(NATIVE_SOLR_QUERY) != null
- || filter.getPropertyRestriction(NATIVE_LUCENE_QUERY) != null
- || configuration.useForPropertyRestrictions())
- && !hasIgnoredProperties(filter.getPropertyRestrictions(), configuration)) {
- match++;
- }
-
- // path restriction defined AND path restrictions handled
- if (filter.getPathRestriction() != null &&
- !Filter.PathRestriction.NO_RESTRICTION.equals(filter.getPathRestriction())
- && configuration.useForPathRestrictions()) {
- if (match > 0) {
- match++;
- }
- }
-
- // primary type restriction defined AND primary type restriction handled
- if (filter.getPrimaryTypes().size() > 0 && configuration.useForPrimaryTypes()) {
- if (match > 0) {
- match++;
- }
- }
- log.debug("{}Â matched restrictions for filter {} and configuration {}", match, filter, configuration);
-
- return match;
- }
-
- private static boolean hasIgnoredProperties(Collection<Filter.PropertyRestriction> propertyRestrictions, OakSolrConfiguration configuration) {
- for (Filter.PropertyRestriction pr : propertyRestrictions) {
- if (isIgnoredProperty(pr, configuration)) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public String getPlan(Filter filter, NodeState nodeState) {
- throw new UnsupportedOperationException("Not supported as implementing AdvancedQueryIndex");
- }
-
- /**
- * Get the set of relative paths of a full-text condition. For example, for
- * the condition "contains(a/b, 'hello') and contains(c/d, 'world'), the set
- * { "a", "c" } is returned. If there are no relative properties, then one
- * entry is returned (the empty string). If there is no expression, then an
- * empty set is returned.
- *
- * @param ft the full-text expression
- * @return the set of relative paths (possibly empty)
- */
- private static Set<String> getRelativePaths(FullTextExpression ft) {
- final HashSet<String> relPaths = new HashSet<String>();
- ft.accept(new FullTextVisitor.FullTextVisitorBase() {
-
- @Override
- public boolean visit(FullTextTerm term) {
- String p = term.getPropertyName();
- if (p == null) {
- relPaths.add("");
- } else if (p.startsWith("../") || p.startsWith("./")) {
- throw new IllegalArgumentException("Relative parent is not supported:" + p);
- } else if (getDepth(p) > 1) {
- String parent = getParentPath(p);
- relPaths.add(parent);
- } else {
- relPaths.add("");
- }
- return true;
- }
- });
- return relPaths;
- }
-
- @Override
- public Cursor query(final IndexPlan plan, final NodeState root) {
- Cursor cursor;
- try {
-
- Filter filter = plan.getFilter();
- final Set<String> relPaths = filter.getFullTextConstraint() != null ? getRelativePaths(filter.getFullTextConstraint())
- : Collections.<String>emptySet();
- final String parent = relPaths.size() == 0 ? "" : relPaths.iterator().next();
-
- final int parentDepth = getDepth(parent);
- String path = plan.getPlanName();
-
- OakSolrConfiguration configuration = getConfiguration(path, root);
- SolrClient solrServer = getServer(path, root);
- LMSEstimator estimator = getEstimator(path);
-
- AbstractIterator<SolrResultRow> iterator = getIterator(filter, plan, parent, parentDepth, configuration,
- solrServer, estimator);
-
- cursor = new SolrRowCursor(iterator, plan, filter.getQueryLimits(), estimator, solrServer, configuration);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- return cursor;
- }
-
- private synchronized LMSEstimator getEstimator(String path) {
- estimators.putIfAbsent(path, new LMSEstimator());
- return estimators.get(path);
- }
-
- private SolrClient getServer(String path, NodeState root) {
-
- NodeState node = root;
- for (String name : PathUtils.elements(path)) {
- node = node.getChildNode(name);
- }
-
- try {
- if (isSolrIndexNode(node)) {
- if (node.hasChildNode("server")) {
- SolrServerConfigurationProvider solrServerConfigurationProvider = new NodeStateSolrServerConfigurationProvider(
- node.getChildNode("server"));
- return new OakSolrServer(solrServerConfigurationProvider);
- } else {
- return fallbackSolrServerProvider.getSearchingSolrServer();
- }
- } else if (node.exists()) {
- log.warn("Cannot open Solr Index at path {} as the index is not of type 'solr'", path);
- }
- } catch (Exception e) {
- log.error("Could not access the Solr index at " + path, e);
- }
-
- return null;
- }
-
- private AbstractIterator<SolrResultRow> getIterator(final Filter filter, final IndexPlan plan,
- final String parent, final int parentDepth,
- final OakSolrConfiguration configuration, final SolrClient solrServer,
- final LMSEstimator estimator) {
- return new AbstractIterator<SolrResultRow>() {
- public Collection<FacetField> facetFields = new LinkedList<FacetField>();
- private final Set<String> seenPaths = new HashSet<>();
- private final Deque<SolrResultRow> queue = new ArrayDeque<>();
- private int offset = 0;
- private boolean noDocs = false;
- private long numFound = 0;
-
- @Override
- protected SolrResultRow computeNext() {
- if (!queue.isEmpty() || loadDocs()) {
- return queue.remove();
- }
- return endOfData();
- }
-
- private SolrResultRow convertToRow(SolrDocument doc) {
- String path = String.valueOf(doc.getFieldValue(configuration.getPathField()));
- if ("".equals(path)) {
- path = "/";
- }
- if (!parent.isEmpty()) {
- path = getAncestorPath(path, parentDepth);
- // avoid duplicate entries
- if (seenPaths.contains(path)) {
- return null;
- }
- seenPaths.add(path);
- }
-
- float score = 0f;
- Object scoreObj = doc.get("score");
- if (scoreObj != null) {
- score = (Float) scoreObj;
- }
- return new SolrResultRow(path, score, doc, facetFields);
-
- }
-
- /**
- * Loads the Solr documents in batches
- * @return true if any document is loaded
- */
- private boolean loadDocs() {
-
- if (noDocs) {
- return false;
- }
-
- try {
- if (log.isDebugEnabled()) {
- log.debug("converting filter {}", filter);
- }
- SolrQuery query = FilterQueryParser.getQuery(filter, plan, configuration);
- if (numFound > 0) {
- long rows = configuration.getRows();
- long maxQueries = numFound / 2;
- if (maxQueries > configuration.getRows()) {
- // adjust the rows to avoid making more than 3 Solr requests for this particular query
- rows = maxQueries;
- query.setParam("rows", String.valueOf(rows));
- }
- long newOffset = configuration.getRows() + offset * rows;
- if (newOffset >= numFound) {
- return false;
- }
- query.setParam("start", String.valueOf(newOffset));
- offset++;
- }
- if (log.isDebugEnabled()) {
- log.debug("sending query {}", query);
- }
- QueryResponse queryResponse = solrServer.query(query);
-
- if (log.isDebugEnabled()) {
- log.debug("getting response {}", queryResponse.getHeader());
- }
-
- SolrDocumentList docs = queryResponse.getResults();
-
- if (docs != null) {
-
- numFound = docs.getNumFound();
-
- estimator.update(filter, numFound);
-
- Map<String, Map<String, List<String>>> highlighting = queryResponse.getHighlighting();
- for (SolrDocument doc : docs) {
- // handle highlight
- if (highlighting != null) {
- Object pathObject = doc.getFieldValue(configuration.getPathField());
- if (pathObject != null && highlighting.get(String.valueOf(pathObject)) != null) {
- Map<String, List<String>> value = highlighting.get(String.valueOf(pathObject));
- for (Map.Entry<String, List<String>> entry : value.entrySet()) {
- // all highlighted values end up in 'rep:excerpt', regardless of field match
- for (String v : entry.getValue()) {
- doc.addField(QueryConstants.REP_EXCERPT, v);
- }
- }
- }
- }
- SolrResultRow row = convertToRow(doc);
- if (row != null) {
- queue.add(row);
- }
- }
- }
-
- // get facets
- List<FacetField> returnedFieldFacet = queryResponse.getFacetFields();
- if (returnedFieldFacet != null) {
- facetFields.addAll(returnedFieldFacet);
- }
-
- // filter facets on doc paths
- if (!facetFields.isEmpty() && docs != null) {
- for (SolrDocument doc : docs) {
- String path = String.valueOf(doc.getFieldValue(configuration.getPathField()));
- // if facet path doesn't exist for the calling user, filter the facet for this doc
- for (FacetField ff : facetFields) {
- if (!filter.isAccessible(path + "/" + ff.getName())) {
- filterFacet(doc, ff);
- }
- }
- }
- }
-
- // handle spellcheck
- SpellCheckResponse spellCheckResponse = queryResponse.getSpellCheckResponse();
- if (spellCheckResponse != null && spellCheckResponse.getSuggestions() != null &&
- spellCheckResponse.getSuggestions().size() > 0) {
- putSpellChecks(spellCheckResponse, queue, filter, configuration, solrServer);
- noDocs = true;
- }
-
- // handle suggest
- NamedList<Object> response = queryResponse.getResponse();
- Map suggest = (Map) response.get("suggest");
- if (suggest != null) {
- Set<Map.Entry<String, Object>> suggestEntries = suggest.entrySet();
- if (!suggestEntries.isEmpty()) {
- putSuggestions(suggestEntries, queue, filter, configuration, solrServer);
- noDocs = true;
- }
- }
-
- } catch (Exception e) {
- if (log.isWarnEnabled()) {
- log.warn("query via {} failed.", solrServer, e);
- }
- }
-
- return !queue.isEmpty();
- }
-
- };
- }
-
- private void filterFacet(SolrDocument doc, FacetField facetField) {
- // facet filtering by value requires that the facet values match the stored values
- // a *_facet field must exist, stored (or /w docValues) to be used for faceting and at filtering time
- if (doc.getFieldNames().contains(facetField.getName())) {
- // decrease facet value
- Collection<Object> docFieldValues = doc.getFieldValues(facetField.getName());
- if (docFieldValues != null) {
- for (Object docFieldValue : docFieldValues) {
- String valueString = String.valueOf(docFieldValue);
- List<FacetField.Count> toRemove = new LinkedList<FacetField.Count>();
- for (FacetField.Count count : facetField.getValues()) {
- long existingCount = count.getCount();
- if (valueString.equals(count.getName())) {
- if (existingCount > 1) {
- // decrease the count
- count.setCount(existingCount - 1);
- } else {
- // remove the entire entry
- toRemove.add(count);
- }
- }
- }
- for (FacetField.Count f : toRemove) {
- assert facetField.getValues().remove(f);
- }
- }
- }
- }
- }
-
- private void putSpellChecks(SpellCheckResponse spellCheckResponse,
- final Deque<SolrResultRow> queue,
- Filter filter, OakSolrConfiguration configuration, SolrClient solrServer) throws IOException, SolrServerException {
- List<SpellCheckResponse.Suggestion> suggestions = spellCheckResponse.getSuggestions();
- Collection<String> alternatives = new ArrayList<String>(suggestions.size());
- for (SpellCheckResponse.Suggestion suggestion : suggestions) {
- alternatives.addAll(suggestion.getAlternatives());
- }
-
- // ACL filter spellcheck results
- for (String alternative : alternatives) {
- SolrQuery solrQuery = new SolrQuery();
- solrQuery.setParam("q", alternative);
- solrQuery.setParam("df", configuration.getCatchAllField());
- solrQuery.setParam("q.op", "AND");
- solrQuery.setParam("rows", "100");
- QueryResponse suggestQueryResponse = solrServer.query(solrQuery);
- SolrDocumentList results = suggestQueryResponse.getResults();
- if (results != null && results.getNumFound() > 0) {
- for (SolrDocument doc : results) {
- if (filter.isAccessible(String.valueOf(doc.getFieldValue(configuration.getPathField())))) {
- queue.add(new SolrResultRow(alternative));
- break;
- }
- }
- }
- }
- }
-
- private void putSuggestions(Set<Map.Entry<String, Object>> suggestEntries, final Deque<SolrResultRow> queue,
- Filter filter, OakSolrConfiguration configuration, SolrClient solrServer) throws IOException, SolrServerException {
- Collection<SimpleOrderedMap<Object>> retrievedSuggestions = new HashSet<SimpleOrderedMap<Object>>();
- for (Map.Entry<String, Object> suggester : suggestEntries) {
- SimpleOrderedMap<Object> suggestionResponses = ((SimpleOrderedMap) suggester.getValue());
- for (Map.Entry<String, Object> suggestionResponse : suggestionResponses) {
- SimpleOrderedMap<Object> suggestionResults = ((SimpleOrderedMap) suggestionResponse.getValue());
- for (Map.Entry<String, Object> suggestionResult : suggestionResults) {
- if ("suggestions".equals(suggestionResult.getKey())) {
- ArrayList<SimpleOrderedMap<Object>> suggestions = ((ArrayList<SimpleOrderedMap<Object>>) suggestionResult.getValue());
- if (!suggestions.isEmpty()) {
- for (SimpleOrderedMap<Object> suggestion : suggestions) {
- retrievedSuggestions.add(suggestion);
- }
- }
- }
- }
- }
- }
-
- // ACL filter suggestions
- for (SimpleOrderedMap<Object> suggestion : retrievedSuggestions) {
- SolrQuery solrQuery = new SolrQuery();
- solrQuery.setParam("q", String.valueOf(suggestion.get("term")));
- solrQuery.setParam("df", configuration.getCatchAllField());
- solrQuery.setParam("q.op", "AND");
- solrQuery.setParam("rows", "100");
- QueryResponse suggestQueryResponse = solrServer.query(solrQuery);
- SolrDocumentList results = suggestQueryResponse.getResults();
- if (results != null && results.getNumFound() > 0) {
- for (SolrDocument doc : results) {
- if (filter.isAccessible(String.valueOf(doc.getFieldValue(configuration.getPathField())))) {
- queue.add(new SolrResultRow(suggestion.get("term").toString(),
- Double.parseDouble(suggestion.get("weight").toString())));
- break;
- }
- }
- }
- }
- }
-
- static boolean isIgnoredProperty(Filter.PropertyRestriction property, OakSolrConfiguration configuration) {
- if (NATIVE_LUCENE_QUERY.equals(property.propertyName) || NATIVE_SOLR_QUERY.equals(property.propertyName)) {
- return false;
- } else return (!configuration.useForPropertyRestrictions() // Solr index not used for properties
- || (configuration.getUsedProperties().size() > 0 && !configuration.getUsedProperties().contains(property.propertyName)) // not explicitly contained in the used properties
- || property.propertyName.contains("/") // no child-level property restrictions
- || QueryConstants.REP_EXCERPT.equals(property.propertyName) // rep:excerpt is not handled at the property level
- || QueryConstants.OAK_SCORE_EXPLANATION.equals(property.propertyName) // score explain is not handled at the property level
- || QueryConstants.REP_FACET.equals(property.propertyName) // rep:facet is not handled at the property level
- || QueryConstants.RESTRICTION_LOCAL_NAME.equals(property.propertyName)
- || property.propertyName.startsWith(QueryConstants.FUNCTION_RESTRICTION_PREFIX)
- || configuration.getIgnoredProperties().contains(property.propertyName));
- }
-
- @Override
- public List<IndexPlan> getPlans(Filter filter, List<OrderEntry> sortOrder, NodeState rootState) {
-
- Collection<String> indexPaths = new SolrIndexLookup(rootState).collectIndexNodePaths(filter);
- List<IndexPlan> plans = new ArrayList<>(indexPaths.size());
-
- log.debug("looking for plans for paths : {}", indexPaths);
- for (String path : indexPaths) {
- OakSolrConfiguration configuration = getConfiguration(path, rootState);
- SolrClient solrServer = getServer(path, rootState);
- log.debug("building plan for server {} and configuration {}", solrServer, configuration);
- // only provide the plan if both valid configuration and server exist
- if (configuration != null && solrServer != null) {
- LMSEstimator estimator = getEstimator(path);
- IndexPlan plan = getIndexPlan(filter, configuration, estimator, sortOrder, path);
- if (plan != null) {
- plans.add(plan);
- }
- }
- }
- return plans;
- }
-
- private OakSolrConfiguration getConfiguration(String path, NodeState rootState) {
- NodeState node = rootState;
- for (String name : PathUtils.elements(path)) {
- node = node.getChildNode(name);
- }
-
- try {
- if (isSolrIndexNode(node)) {
- if (node.hasChildNode("server")) {
- return new OakSolrNodeStateConfiguration(node);
- } else {
- return fallbackOakSolrConfigurationProvider.getConfiguration();
- }
- } else if (node.exists()) {
- log.warn("Cannot open Solr Index at path {} as the index is not of type 'solr'", path);
- }
- } catch (Exception e) {
- log.error("Could not access the Solr index at " + path, e);
- }
-
- return null;
- }
-
- private IndexPlan getIndexPlan(Filter filter, OakSolrConfiguration configuration, LMSEstimator estimator,
- List<OrderEntry> sortOrder, String path) {
- if (getMatchingFilterRestrictions(filter, configuration) > 0) {
-
- // we can't order by functions
- // so remove those entries from the plan's sort order
- ArrayList<OrderEntry> sortOrder2 = new ArrayList<>();
- if (sortOrder != null) {
- for (OrderEntry e : sortOrder) {
- if (!e.getPropertyName().startsWith(FieldNames.FUNCTION_PREFIX)) {
- sortOrder2.add(e);
- }
- }
- }
-
- IndexPlan indexPlan = planBuilder(filter)
- .setEstimatedEntryCount(estimator.estimate(filter))
- .setSortOrder(sortOrder2)
- .setPlanName(path)
- .setPathPrefix(getPathPrefix(path))
- .build();
- log.debug("index plan {}", indexPlan);
- return indexPlan;
- } else {
- return null;
- }
- }
-
- private String getPathPrefix(String indexPath) {
- // 2 = /oak:index/<index name>
- String parentPath = PathUtils.getAncestorPath(indexPath, 2);
- return PathUtils.denotesRoot(parentPath) ? "" : parentPath;
- }
-
- private IndexPlan.Builder planBuilder(Filter filter) {
- return new IndexPlan.Builder()
- .setCostPerExecution(1.5) // disk I/O + network I/O
- .setCostPerEntry(0.3) // with properly configured SolrCaches ~70% of the doc fetches should hit them
- .setFilter(filter)
- .setFulltextIndex(true)
- .setIncludesNodeData(true) // we currently include node data
- .setDelayed(true); //Solr is most usually async
- }
-
- @Override
- public String getPlanDescription(IndexPlan plan, NodeState root) {
- return plan.toString();
- }
-
- @Override
- public Cursor query(Filter filter, NodeState rootState) {
- throw new UnsupportedOperationException("Not supported as implementing AdvancedQueryIndex");
- }
-
- static class SolrResultRow {
- final String path;
- final double score;
- final SolrDocument doc;
- final Collection<FacetField> facetFields;
- final String suggestion;
-
- private SolrResultRow(String path, double score, SolrDocument doc, String suggestion, Collection<FacetField> facetFields) {
- this.path = path;
- this.score = score;
- this.doc = doc;
- this.suggestion = suggestion;
- this.facetFields = facetFields;
- }
-
- SolrResultRow(String suggestion, double score) {
- this("/", score, null, suggestion, null);
- }
-
- SolrResultRow(String suggestion) {
- this("/", 1.0, null, suggestion, null);
- }
-
- SolrResultRow(String path, float score, SolrDocument doc, Collection<FacetField> facetFields) {
- this(path, score, doc, null, facetFields);
- }
-
- @Override
- public String toString() {
- return String.format("%s (%1.2f)", path, score);
- }
- }
-
- /**
- * A cursor over Solr results. The result includes the path and the jcr:score pseudo-property as returned by Solr,
- * plus, eventually, the returned stored values if {@link org.apache.solr.common.SolrDocument} is included in the
- * {@link org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndex.SolrResultRow}.
- */
- private class SolrRowCursor implements Cursor {
-
- private final Cursor pathCursor;
- private final IndexPlan plan;
- private final LMSEstimator estimator;
- private final SolrClient solrServer;
- private final OakSolrConfiguration configuration;
-
- SolrResultRow currentRow;
-
- SolrRowCursor(final Iterator<SolrResultRow> it, IndexPlan plan, QueryLimits settings,
- LMSEstimator estimator, SolrClient solrServer, OakSolrConfiguration configuration) {
- this.estimator = estimator;
- this.solrServer = solrServer;
- this.configuration = configuration;
- Iterator<String> pathIterator = new Iterator<String>() {
-
- @Override
- public boolean hasNext() {
- return it.hasNext();
- }
-
- @Override
- public String next() {
- currentRow = it.next();
- String path = currentRow.path;
- if (configuration.collapseJcrContentParents() && path.endsWith(JcrConstants.JCR_CONTENT)) {
- return PathUtils.getParentPath(path);
- } else {
- return path;
- }
- }
-
- @Override
- public void remove() {
- it.remove();
- }
-
- };
- this.plan = plan;
- this.pathCursor = new PathCursor(pathIterator, false, settings);
- }
-
-
- @Override
- public boolean hasNext() {
- return pathCursor.hasNext();
- }
-
- @Override
- public void remove() {
- pathCursor.remove();
- }
-
- @Override
- public IndexRow next() {
- final IndexRow pathRow = pathCursor.next();
- return new IndexRow() {
-
- @Override
- public boolean isVirtualRow() {
- return currentRow.doc == null;
- }
-
- @Override
- public String getPath() {
- String sub = pathRow.getPath();
- if (isVirtualRow()) {
- return sub;
- } else if (PathUtils.isAbsolute(sub)) {
- return plan.getPathPrefix() + sub;
- } else {
- return PathUtils.concat(plan.getPathPrefix(), sub);
- }
- }
-
- @Override
- public PropertyValue getValue(String columnName) {
- // overlay the score
- if (QueryConstants.JCR_SCORE.equals(columnName)) {
- return PropertyValues.newDouble(currentRow.score);
- }
- if (columnName.startsWith(QueryConstants.REP_FACET)) {
- String facetFieldName = columnName.substring(QueryConstants.REP_FACET.length() + 1, columnName.length() - 1);
- FacetField facetField = null;
- for (FacetField ff : currentRow.facetFields) {
- if (ff.getName().equals(facetFieldName + "_facet")) {
- facetField = ff;
- break;
- }
- }
- if (facetField != null) {
- JsopWriter writer = new JsopBuilder();
- writer.object();
- for (FacetField.Count count : facetField.getValues()) {
- writer.key(count.getName()).value(count.getCount());
- }
- writer.endObject();
- return PropertyValues.newString(writer.toString());
- } else {
- return null;
- }
- }
- if (QueryConstants.REP_SPELLCHECK.equals(columnName) || QueryConstants.REP_SUGGEST.equals(columnName)) {
- return PropertyValues.newString(currentRow.suggestion);
- }
- Collection<Object> fieldValues = currentRow.doc.getFieldValues(columnName);
- String value;
- if (fieldValues != null && fieldValues.size() > 0) {
- if (fieldValues.size() > 1) {
- value = IterableUtils.toString(fieldValues);
- } else {
- Object fieldValue = currentRow.doc.getFieldValue(columnName);
- if (fieldValue != null) {
- value = fieldValue.toString();
- } else {
- return null;
- }
- }
- } else {
- value = IterableUtils.toString(Collections.emptyList());
- }
- return PropertyValues.newString(value);
- }
-
- };
- }
-
-
- @Override
- public long getSize(SizePrecision precision, long max) {
- long estimate = -1;
- switch (precision) {
- case EXACT:
- // query solr
- SolrQuery countQuery = FilterQueryParser.getQuery(plan.getFilter(), plan, this.configuration);
- countQuery.setRows(0);
- try {
- estimate = this.solrServer.query(countQuery).getResults().getNumFound();
- } catch (IOException | SolrServerException e) {
- log.warn("could not perform count query {}", countQuery);
- }
- break;
- case APPROXIMATION:
- // estimate result size
- estimate = this.estimator.estimate(plan.getFilter());
- break;
- case FAST_APPROXIMATION:
- // use already computed index plan's estimate
- estimate = plan.getEstimatedEntryCount();
- break;
- }
- return Math.min(estimate, max);
- }
- }
-
- @Override
- @Nullable
- public NodeAggregator getNodeAggregator() {
- return aggregator;
- }
-
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndexProvider.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndexProvider.java
deleted file mode 100644
index ea4fb228a1..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndexProvider.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.query;
-
-import java.util.List;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider;
-import org.apache.jackrabbit.oak.spi.query.QueryIndex;
-import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * {@link QueryIndexProvider} for {@link SolrQueryIndex}
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class SolrQueryIndexProvider implements QueryIndexProvider {
-
- private final SolrServerProvider solrServerProvider;
-
- private final OakSolrConfigurationProvider oakSolrConfigurationProvider;
-
- private final QueryIndex.NodeAggregator aggregator;
-
- public SolrQueryIndexProvider(@NotNull SolrServerProvider solrServerProvider, @NotNull OakSolrConfigurationProvider oakSolrConfigurationProvider,
- @Nullable QueryIndex.NodeAggregator nodeAggregator) {
- this.oakSolrConfigurationProvider = oakSolrConfigurationProvider;
- this.solrServerProvider = solrServerProvider;
- this.aggregator = nodeAggregator;
- }
-
- public SolrQueryIndexProvider(@NotNull SolrServerProvider solrServerProvider, @NotNull OakSolrConfigurationProvider oakSolrConfigurationProvider) {
- this(solrServerProvider, oakSolrConfigurationProvider, null);
- }
-
- @NotNull
- @Override
- public List<? extends QueryIndex> getQueryIndexes(NodeState nodeState) {
- return List.of(new SolrQueryIndex(aggregator, oakSolrConfigurationProvider, solrServerProvider));
- }
-
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/DefaultSolrServerProvider.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/DefaultSolrServerProvider.java
deleted file mode 100644
index 5940bad275..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/DefaultSolrServerProvider.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.server;
-
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationDefaults;
-import org.apache.solr.client.solrj.SolrClient;
-import org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient;
-import org.apache.solr.client.solrj.impl.HttpSolrClient;
-import org.jetbrains.annotations.Nullable;
-
-@Deprecated(forRemoval=true, since="1.74.0")
-public class DefaultSolrServerProvider implements SolrServerProvider {
-
- private SolrClient solrServer;
- private SolrClient indexingSolrServer;
-
- @Nullable
- @Override
- public SolrClient getSolrServer() throws Exception {
- if (solrServer == null) {
- solrServer = new HttpSolrClient.Builder()
- .withBaseSolrUrl(SolrServerConfigurationDefaults.LOCAL_BASE_URL + ':' +
- SolrServerConfigurationDefaults.HTTP_PORT + SolrServerConfigurationDefaults.CONTEXT)
- .build();
- }
- return solrServer;
- }
-
- @Nullable
- @Override
- public SolrClient getIndexingSolrServer() throws Exception {
- if (indexingSolrServer == null) {
- indexingSolrServer = new ConcurrentUpdateSolrClient.Builder(
- SolrServerConfigurationDefaults.LOCAL_BASE_URL + ':' +
- SolrServerConfigurationDefaults.HTTP_PORT + SolrServerConfigurationDefaults.CONTEXT)
- .withQueueSize(1000).withThreadCount(4).build();
- }
- return indexingSolrServer;
- }
-
- @Nullable
- @Override
- public SolrClient getSearchingSolrServer() throws Exception {
- return getSolrServer();
- }
-
- private String getUrl() {
- return SolrServerConfigurationDefaults.LOCAL_BASE_URL + ':' +
- SolrServerConfigurationDefaults.HTTP_PORT + SolrServerConfigurationDefaults.CONTEXT +
- '/' + SolrServerConfigurationDefaults.CORE_NAME;
- }
-
- @Override
- public void close() {
- try {
- SolrClient solrServer = getSolrServer();
- if (solrServer != null) {
- solrServer.close();
- }
- } catch (Exception e) {
- // do nothing
- } try {
- SolrClient indexingSolrServer = getIndexingSolrServer();
- if (indexingSolrServer != null) {
- indexingSolrServer.close();
- }
- } catch (Exception e) {
- // do nothing
- } try {
- getSearchingSolrServer().close();
- } catch (Exception e) {
- // do nothing
- }
- }
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/OakSolrServer.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/OakSolrServer.java
deleted file mode 100644
index 7e628d9bd2..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/OakSolrServer.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.server;
-
-import java.io.IOException;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationProvider;
-import org.apache.solr.client.solrj.SolrClient;
-import org.apache.solr.client.solrj.SolrRequest;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.common.util.NamedList;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * An Oak {@link org.apache.solr.client.solrj.SolrClient}, caching a {@link org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider}
- * for dispatching requests to indexing or searching specialized {@link org.apache.solr.client.solrj.SolrClient}s.
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class OakSolrServer extends SolrClient {
-
- private final SolrServerConfiguration solrServerConfiguration;
- private final SolrServerProvider solrServerProvider;
-
- public OakSolrServer(@NotNull SolrServerConfigurationProvider solrServerConfigurationProvider) {
- this.solrServerConfiguration = solrServerConfigurationProvider.getSolrServerConfiguration();
- try {
- this.solrServerProvider = solrServerConfiguration.getProvider();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public NamedList<Object> request(SolrRequest request, String collection) throws SolrServerException, IOException {
- try {
-
- SolrClient server = getServer(request);
- return server.request(request);
-
- } catch (Exception e) {
- throw new SolrServerException(e);
- }
- }
-
- private synchronized SolrClient getServer(SolrRequest request) throws Exception {
- boolean isIndex = request.getPath().contains("/update");
- SolrServerRegistry.Strategy strategy = isIndex ? SolrServerRegistry.Strategy.INDEXING : SolrServerRegistry.Strategy.SEARCHING;
- SolrClient solrServer = SolrServerRegistry.get(solrServerConfiguration, strategy);
- if (solrServer == null) {
- if (solrServerConfiguration.getClass().getName().indexOf("EmbeddedSolrServerConfiguration") >= 0) {
- solrServer = solrServerProvider.getSolrServer();
- // the same Solr server has to be used for both
- SolrServerRegistry.register(solrServerConfiguration, solrServer, SolrServerRegistry.Strategy.INDEXING);
- SolrServerRegistry.register(solrServerConfiguration, solrServer, SolrServerRegistry.Strategy.SEARCHING);
- } else {
- solrServer = isIndex ? solrServerProvider.getIndexingSolrServer() : solrServerProvider.getSearchingSolrServer();
- SolrServerRegistry.register(solrServerConfiguration, solrServer, strategy);
- }
- }
- return solrServer;
- }
-
- @Override
- public String toString() {
- return "OakSolrServer{" +
- "solrServerConfiguration=" + solrServerConfiguration +
- ", solrServerProvider=" + solrServerProvider +
- '}';
- }
-
- @Override
- public void close() throws IOException {
- try {
- solrServerProvider.close();
- SolrServerRegistry.unregister(solrServerConfiguration, SolrServerRegistry.Strategy.INDEXING);
- SolrServerRegistry.unregister(solrServerConfiguration, SolrServerRegistry.Strategy.SEARCHING);
- } catch (IOException e) {
- // do nothing
- }
- }
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/RemoteSolrServerProvider.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/RemoteSolrServerProvider.java
deleted file mode 100644
index 84a24cd3d2..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/RemoteSolrServerProvider.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.server;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Arrays;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationDefaults;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.RemoteSolrServerConfiguration;
-import org.apache.solr.client.solrj.SolrClient;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.impl.CloudSolrClient;
-import org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient;
-import org.apache.solr.client.solrj.impl.HttpSolrClient;
-import org.apache.solr.client.solrj.request.CollectionAdminRequest;
-import org.apache.solr.client.solrj.response.CollectionAdminResponse;
-import org.apache.solr.client.solrj.response.SolrPingResponse;
-import org.apache.solr.common.cloud.SolrZkClient;
-import org.apache.solr.common.cloud.ZkStateReader;
-import org.jetbrains.annotations.Nullable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * {@link org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider} for remote Solr installations.
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class RemoteSolrServerProvider implements SolrServerProvider {
-
- private final Logger log = LoggerFactory.getLogger(RemoteSolrServerProvider.class);
-
- private final RemoteSolrServerConfiguration remoteSolrServerConfiguration;
-
- public RemoteSolrServerProvider(RemoteSolrServerConfiguration remoteSolrServerConfiguration) {
- this.remoteSolrServerConfiguration = remoteSolrServerConfiguration;
- }
-
- @Nullable
- @Override
- public SolrClient getSolrServer() throws Exception {
-
- SolrClient solrServer = null;
- if (remoteSolrServerConfiguration.getSolrZkHost() != null && remoteSolrServerConfiguration.getSolrZkHost().length() > 0) {
- try {
- solrServer = initializeWithCloudSolrServer();
- } catch (Exception e) {
- log.warn("unable to initialize SolrCloud client for {}", remoteSolrServerConfiguration.getSolrZkHost(), e);
- }
- }
- if (solrServer == null && remoteSolrServerConfiguration.getSolrHttpUrls() != null && remoteSolrServerConfiguration.getSolrHttpUrls().length == 1
- && remoteSolrServerConfiguration.getSolrHttpUrls()[0] != null && remoteSolrServerConfiguration.getSolrHttpUrls()[0].length() > 0) {
- try {
- solrServer = initializeWithExistingHttpServer();
- } catch (Exception e1) {
- log.warn("unable to initialize Solr HTTP client for {}", remoteSolrServerConfiguration.getSolrHttpUrls(), e1);
- }
- }
- if (solrServer == null) {
- throw new IOException("could not connect to any remote Solr server");
- }
-
- return solrServer;
- }
-
- @Nullable
- @Override
- public SolrClient getIndexingSolrServer() throws Exception {
- SolrClient server = getSolrServer();
-
- if (server instanceof HttpSolrClient) {
- String url = ((HttpSolrClient) server).getBaseURL();
- ConcurrentUpdateSolrClient s1 = new ConcurrentUpdateSolrClient.Builder(
- url).withQueueSize(1000).withThreadCount(Runtime.getRuntime().availableProcessors()).build();
- s1.setConnectionTimeout(remoteSolrServerConfiguration.getConnectionTimeout());
- s1.setSoTimeout(remoteSolrServerConfiguration.getSocketTimeout());
- server = s1;
- }
- return server;
- }
-
- @Nullable
- @Override
- public SolrClient getSearchingSolrServer() throws Exception {
- return getSolrServer();
- }
-
- private SolrClient initializeWithExistingHttpServer() throws IOException, SolrServerException {
- // try basic Solr HTTP client
- HttpSolrClient httpSolrServer = new HttpSolrClient.Builder(remoteSolrServerConfiguration.getSolrHttpUrls()[0]).build();
- httpSolrServer.setConnectionTimeout(remoteSolrServerConfiguration.getConnectionTimeout());
- httpSolrServer.setSoTimeout(remoteSolrServerConfiguration.getSocketTimeout());
- SolrPingResponse ping = httpSolrServer.ping();
- if (ping != null && 0 == ping.getStatus()) {
- return httpSolrServer;
- } else {
- httpSolrServer.close();
- throw new IOException("the found HTTP Solr server is not alive");
- }
-
- }
-
- private SolrClient initializeWithCloudSolrServer() throws IOException {
- // try SolrCloud client
- CloudSolrClient cloudSolrServer = new CloudSolrClient.Builder().withZkHost(Arrays.asList(
- remoteSolrServerConfiguration.getSolrZkHost().split(","))).build();
- cloudSolrServer.setZkConnectTimeout(remoteSolrServerConfiguration.getConnectionTimeout());
- cloudSolrServer.setSoTimeout(remoteSolrServerConfiguration.getSocketTimeout());
-
- cloudSolrServer.setIdField(OakSolrConfigurationDefaults.PATH_FIELD_NAME);
-
- if (connectToZK(cloudSolrServer)) {
- log.debug("CloudSolrServer connected");
- cloudSolrServer.setDefaultCollection("collection1"); // workaround for first request when the needed collection may not exist
-
- // create specified collection if it doesn't exists
- try {
- createCollectionIfNeeded(cloudSolrServer);
- } catch (Throwable t) {
- if (log.isWarnEnabled()) {
- log.warn("could not create the collection on {}", remoteSolrServerConfiguration.getSolrZkHost(), t);
- }
- }
- cloudSolrServer.setDefaultCollection(remoteSolrServerConfiguration.getSolrCollection());
-
- log.debug("waiting for CloudSolrServer to come alive");
- // SolrCloud may need some time to sync on collection creation (to spread it over the shards / replicas)
- int i = 0;
- while (i < 3) {
- try {
- SolrPingResponse ping = cloudSolrServer.ping();
- if (ping != null && 0 == ping.getStatus()) {
- return cloudSolrServer;
- } else {
- cloudSolrServer.close();
- throw new IOException("the found SolrCloud server is not alive");
- }
- } catch (Exception e) {
- // wait a bit
- try {
- if (log.isDebugEnabled()) {
- log.debug("server is not alive yet, wait a bit", e);
- }
- Thread.sleep(3000);
- } catch (InterruptedException e1) {
- // do nothing
- }
- }
- i++;
- }
- cloudSolrServer.close();
- throw new IOException("the found SolrCloud server is not alive");
- } else {
- cloudSolrServer.close();
- throw new IOException("could not connect to Zookeeper hosted at " + remoteSolrServerConfiguration.getSolrZkHost());
- }
-
- }
-
- private boolean connectToZK(CloudSolrClient cloudSolrServer) {
- log.debug("connecting to {}", cloudSolrServer.getZkHost());
- boolean connected = false;
- for (int i = 0; i < 3; i++) {
- try {
- cloudSolrServer.connect();
- connected = true;
- break;
- } catch (Exception e) {
- log.warn("could not connect to ZK", e);
- try {
- Thread.sleep(3000);
- } catch (InterruptedException e1) {
- // do nothing
- }
- }
- }
- return connected;
- }
-
- private void createCollectionIfNeeded(CloudSolrClient cloudSolrServer) throws SolrServerException {
- String solrCollection = remoteSolrServerConfiguration.getSolrCollection();
- ZkStateReader zkStateReader = cloudSolrServer.getZkStateReader();
- SolrZkClient zkClient = zkStateReader.getZkClient();
- log.debug("creating {} collection if needed", solrCollection);
- try {
- if (zkClient.isConnected() && !zkClient.exists("/configs/" + solrCollection, true)) {
- String solrConfDir = remoteSolrServerConfiguration.getSolrConfDir();
- Path dir;
- if (solrConfDir != null && solrConfDir.length() > 0) {
- log.info("uploading config from {}", solrConfDir);
- dir = Paths.get(solrConfDir);
- } else {
- Path tempDirectory = Files.createTempDirectory("oak-solr-conf");
-
- copy("schema", tempDirectory);
- copy("solrconfig", tempDirectory);
-
- log.info("uploading config from {}", tempDirectory);
- dir = tempDirectory;
- }
- log.debug("uploading config from {}", dir);
- zkClient.upConfig(dir, solrCollection);
-
- log.debug("creating collection {}", solrCollection);
-
- CollectionAdminRequest.Create req = CollectionAdminRequest.Create.createCollection(solrCollection,
- remoteSolrServerConfiguration.getSolrShardsNo(),remoteSolrServerConfiguration.getSolrReplicationFactor());
- CollectionAdminResponse response = req.process(cloudSolrServer);
-
- log.info("collection creation response {}", response);
-
- cloudSolrServer.request(req);
- }
- } catch (Exception e) {
- log.warn("could not create collection {}", solrCollection);
- throw new SolrServerException(e);
- }
- }
-
- private void copy(String name, Path tempDirectory) throws IOException {
- InputStream inputStream = getClass().getResourceAsStream("/solr/oak/conf/" + name + ".xml");
- File dir = tempDirectory.toFile();
- File newFile = new File(dir, name+".xml");
- assert newFile.createNewFile();
- FileOutputStream outputStream = new FileOutputStream(newFile);
- IOUtils.copy(inputStream, outputStream);
- inputStream.close();
- outputStream.flush();
- outputStream.close();
- }
-
- @Override
- public void close() throws IOException {
- // do nothing
- }
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/SolrServerProvider.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/SolrServerProvider.java
deleted file mode 100644
index 16c785d87a..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/SolrServerProvider.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.server;
-
-import java.io.Closeable;
-import org.apache.solr.client.solrj.SolrClient;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Provider of {@link org.apache.solr.client.solrj.SolrClient}s instances
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public interface SolrServerProvider extends Closeable {
-
- /**
- * provides an already initialized {@link org.apache.solr.client.solrj.SolrClient} to be used for either searching or
- * indexing, or both.
- *
- * @return a {@link org.apache.solr.client.solrj.SolrClient} instance
- * @throws Exception if anything goes wrong while initializing the {@link org.apache.solr.client.solrj.SolrClient}
- */
- @Nullable
- SolrClient getSolrServer() throws Exception;
-
- /**
- * provides an already initialized {@link org.apache.solr.client.solrj.SolrClient} specifically configured to be
- * used for indexing.
- *
- * @return a {@link org.apache.solr.client.solrj.SolrClient} instance
- * @throws Exception if anything goes wrong while initializing the {@link org.apache.solr.client.solrj.SolrClient}
- */
- @Nullable
- SolrClient getIndexingSolrServer() throws Exception;
-
- /**
- * provides an already initialized {@link org.apache.solr.client.solrj.SolrClient} specifically configured to be
- * used for searching.
- *
- * @return a {@link org.apache.solr.client.solrj.SolrClient} instance
- * @throws Exception if anything goes wrong while initializing the {@link org.apache.solr.client.solrj.SolrClient}
- */
- @Nullable
- SolrClient getSearchingSolrServer() throws Exception;
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/SolrServerRegistry.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/SolrServerRegistry.java
deleted file mode 100644
index 4e0547a16c..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/SolrServerRegistry.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.server;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfiguration;
-import org.apache.solr.client.solrj.SolrClient;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * A registry for {@link org.apache.solr.client.solrj.SolrClient}s
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class SolrServerRegistry {
-
- private static final Map<String, SolrClient> searchingServerRegistry = new HashMap<String, SolrClient>();
- private static final Map<String, SolrClient> indexingServerRegistry = new HashMap<String, SolrClient>();
-
- public static void register(@NotNull SolrServerConfiguration configuration, @NotNull SolrClient solrServer,
- @NotNull Strategy strategy) {
- switch (strategy) {
- case INDEXING:
- synchronized (indexingServerRegistry) {
- indexingServerRegistry.put(configuration.toString(), solrServer);
- }
- break;
- case SEARCHING:
- synchronized (searchingServerRegistry) {
- searchingServerRegistry.put(configuration.toString(), solrServer);
- }
- break;
- }
- }
-
- @Nullable
- public static SolrClient get(@NotNull SolrServerConfiguration configuration, @NotNull Strategy strategy) {
- switch (strategy) {
- case INDEXING:
- synchronized (indexingServerRegistry) {
- return indexingServerRegistry.get(configuration.toString());
- }
- case SEARCHING:
- synchronized (searchingServerRegistry) {
- return searchingServerRegistry.get(configuration.toString());
- }
- }
- return null;
- }
-
- public static void unregister(SolrServerConfiguration configuration, @NotNull Strategy strategy) {
- switch (strategy) {
- case INDEXING:
- synchronized (indexingServerRegistry) {
- SolrClient removed = indexingServerRegistry.remove(configuration.toString());
- try {
- removed.close();
- } catch (Exception e) {
- // ignore
- }
- }
- break;
- case SEARCHING:
- synchronized (searchingServerRegistry) {
- SolrClient removed = searchingServerRegistry.remove(configuration.toString());
- try {
- removed.close();
- } catch (Exception e) {
- // ignore
- }
- }
- break;
- }
- }
-
- public enum Strategy {
- INDEXING,
- SEARCHING
- }
-
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/util/NodeTypeIndexingUtils.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/util/NodeTypeIndexingUtils.java
deleted file mode 100644
index 14732f408a..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/util/NodeTypeIndexingUtils.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.util;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.StringWriter;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.nodetype.NodeTypeIterator;
-
-/**
- * Utility class for generating a Solr synonyms file for expanding {@link javax.jcr.nodetype.NodeType}s
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class NodeTypeIndexingUtils {
-
- public static File createPrimaryTypeSynonymsFile(String path, Session session) throws Exception {
- File file = new File(path);
-
- StringWriter stringWriter = new StringWriter();
- NodeTypeIterator allNodeTypes = session.getWorkspace().getNodeTypeManager().getAllNodeTypes();
- while (allNodeTypes.hasNext()) {
- NodeType nodeType = allNodeTypes.nextNodeType();
- NodeType[] superTypes = nodeType.getSupertypes();
- if (superTypes != null && superTypes.length > 0) {
- stringWriter.append(nodeType.getName()).append(" => ");
- for (int i = 0; i < superTypes.length; i++) {
- stringWriter.append(superTypes[i].getName());
- if (i < superTypes.length - 1) {
- stringWriter.append(',');
- }
- stringWriter.append(' ');
- }
- stringWriter.append('\n');
- }
- }
- FileOutputStream fileOutputStream = new FileOutputStream(file);
- fileOutputStream.write(stringWriter.toString().getBytes("UTF-8"));
- fileOutputStream.flush();
- fileOutputStream.close();
-
- if (file.exists() || file.createNewFile()) {
- return file;
- } else {
- throw new IOException("primary types synonyms file could not be created");
- }
- }
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/util/SolrIndexInitializer.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/util/SolrIndexInitializer.java
deleted file mode 100644
index 43784f9618..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/util/SolrIndexInitializer.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.util;
-
-import org.apache.jackrabbit.JcrConstants;
-import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.plugins.index.IndexConstants;
-import org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndex;
-import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
-import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.jetbrains.annotations.NotNull;
-
-import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.TYPE_PROPERTY_NAME;
-
-/**
- * A {@link org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer} for Solr index
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class SolrIndexInitializer implements RepositoryInitializer {
-
- private static final String SOLR_IDX = "solr";
- private static final String ASYNC = "async";
-
- private final String async;
- private final String name;
- private final boolean reindex;
-
- /**
- * build Solr index definition with defaults (name = solr, reindex enabled, asynchronous):
- */
- public SolrIndexInitializer() {
- this.name = SOLR_IDX;
- this.async = ASYNC;
- this.reindex = true;
- }
-
- /**
- * build Solr index definition with a specific node name and defaults (reindex enabled, asynchronous):
- *
- * @param name the name of the node holding the Solr index definition
- */
- public SolrIndexInitializer(String name) {
- this.name = name;
- this.async = ASYNC;
- this.reindex = true;
- }
-
- /**
- * build Solr index definition by specifying if it should be async or not
- *
- * @param async if <code>true</code> for the index to be asynchronous, <code>false</code> to make
- * it synchronous
- */
- public SolrIndexInitializer(boolean async) {
- this.name = SOLR_IDX;
- this.async = async ? ASYNC : null;
- this.reindex = true;
- }
-
- /**
- * build Solr index definition by specifying all the configurable parameters
- *
- * @param async if <code>true</code> for the index to be asynchronous, <code>false</code> to make
- * it synchronous
- * @param name the name of the node holding the Solr index definition
- * @param reindex <code>true</code> if the reindexing should be enabled
- */
- public SolrIndexInitializer(boolean async, String name, boolean reindex) {
- this.name = name;
- this.async = async ? ASYNC : null;
- this.reindex = reindex;
- }
-
- @Override
- public void initialize(@NotNull NodeBuilder builder) {
- if (builder.hasChildNode(IndexConstants.INDEX_DEFINITIONS_NAME)
- && !builder.getChildNode(IndexConstants.INDEX_DEFINITIONS_NAME).hasChildNode(SOLR_IDX)) {
- NodeBuilder indexDefinitionsNode = builder.getChildNode(IndexConstants.INDEX_DEFINITIONS_NAME);
- if (!indexDefinitionsNode.hasChildNode(name)) {
- NodeBuilder solrIndexDefinitionNode = indexDefinitionsNode.child(name);
- solrIndexDefinitionNode.setProperty(JcrConstants.JCR_PRIMARYTYPE, IndexConstants.INDEX_DEFINITIONS_NODE_TYPE, Type.NAME)
- .setProperty(IndexConstants.TYPE_PROPERTY_NAME, SOLR_IDX)
- .setProperty(IndexConstants.REINDEX_PROPERTY_NAME, reindex);
- if (async != null) {
- solrIndexDefinitionNode.setProperty(IndexConstants.ASYNC_PROPERTY_NAME, async);
- }
- }
-
- }
- }
-
- public static boolean isSolrIndexNode(NodeState node) {
- return SolrQueryIndex.TYPE.equals(node.getString(TYPE_PROPERTY_NAME));
- }
-}
diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/util/SolrUtils.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/util/SolrUtils.java
deleted file mode 100644
index dcc5ab5c3d..0000000000
--- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/util/SolrUtils.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.util;
-
-import javax.jcr.PropertyType;
-
-/**
- * Solr utility class
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class SolrUtils {
-
- /**
- * Escape a char sequence in order to make it usable within a Solr query
- *
- * @param s the String to escape
- * @return an escaped String
- */
- public static CharSequence partialEscape(CharSequence s) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < s.length(); i++) {
- char c = s.charAt(i);
- if (c == '\\' || c == '!' || c == '(' || c == ')' ||
- c == ':' || c == '^' || c == '[' || c == ']' || c == '/' ||
- c == '{' || c == '}' || c == '~' || c == '*' || c == '?' ||
- c == '-' || c == ' ') {
- sb.append('\\');
- }
- sb.append(c);
- }
- return sb;
- }
-
- /**
- * Get the name of the field to be used for sorting a certain property
- *
- * @param tag the {@code Type#tag} of the given property
- * @param propertyName the name of the given property
- * @return the name of the Solr field to be used for sorting on the given property
- */
- public static String getSortingField(int tag, String propertyName) {
- switch (tag) {
- case PropertyType.BINARY:
- return propertyName + "_binary_sort";
- case PropertyType.DOUBLE:
- return propertyName + "_double_sort";
- case PropertyType.DECIMAL:
- return propertyName + "_double_sort";
- default:
- return propertyName + "_string_sort";
- }
- }
-
-}
diff --git a/oak-solr-core/src/main/resources/solr/oak/conf/schema.xml b/oak-solr-core/src/main/resources/solr/oak/conf/schema.xml
deleted file mode 100644
index b467f1040b..0000000000
--- a/oak-solr-core/src/main/resources/solr/oak/conf/schema.xml
+++ /dev/null
@@ -1,153 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<schema name="minimal" version="1.6">
-
- <types>
- <fieldType name="string" class="solr.StrField"/>
- <fieldType name="descendent_path" class="solr.TextField">
- <analyzer type="index">
- <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/"/>
- <filter class="solr.PatternCaptureGroupFilterFactory" pattern="((/).*)" preserve_original="false"/>
- <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
- </analyzer>
- <analyzer type="query">
- <tokenizer class="solr.KeywordTokenizerFactory"/>
- </analyzer>
- </fieldType>
- <fieldType name="children_path" class="solr.TextField">
- <analyzer type="index">
- <tokenizer class="solr.KeywordTokenizerFactory"/>
- <filter class="solr.ReverseStringFilterFactory"/>
- <filter class="solr.LengthFilterFactory" min="2" max="2147483647"/>
- <filter class="solr.PatternReplaceFilterFactory" pattern="([^\/]+)(\/)" replacement="$2"
- replace="first"/>
- <filter class="solr.PatternReplaceFilterFactory" pattern="(\/)(.+)" replacement="$2" replace="first"/>
- <filter class="solr.ReverseStringFilterFactory"/>
- </analyzer>
- <analyzer type="query">
- <tokenizer class="solr.KeywordTokenizerFactory"/>
- </analyzer>
- </fieldType>
- <fieldType name="parent_path" class="solr.TextField">
- <analyzer type="index">
- <tokenizer class="solr.KeywordTokenizerFactory"/>
- </analyzer>
- <analyzer type="query">
- <tokenizer class="solr.KeywordTokenizerFactory"/>
- <filter class="solr.ReverseStringFilterFactory"/>
- <filter class="solr.PatternReplaceFilterFactory" pattern="[^\/]+\/" replacement="" replace="first"/>
- <filter class="solr.ReverseStringFilterFactory"/>
- </analyzer>
- </fieldType>
- <fieldType name="text_keepcase" class="solr.TextField" positionIncrementGap="100">
- <analyzer type="index">
- <tokenizer class="solr.StandardTokenizerFactory"/>
- </analyzer>
- <analyzer type="query">
- <tokenizer class="solr.StandardTokenizerFactory"/>
- </analyzer>
- </fieldType>
- <fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
- <analyzer type="index">
- <tokenizer class="solr.StandardTokenizerFactory" />
- <filter class="solr.LowerCaseFilterFactory"/>
- </analyzer>
- <analyzer type="query">
- <tokenizer class="solr.StandardTokenizerFactory" />
- <filter class="solr.LowerCaseFilterFactory"/>
- </analyzer>
- </fieldType>
- <fieldType name="textSpell" class="solr.TextField" positionIncrementGap="100" >
- <analyzer>
- <tokenizer class="solr.StandardTokenizerFactory"/>
- <filter class="solr.LowerCaseFilterFactory"/>
- <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
- </analyzer>
- </fieldType>
- <fieldtype name="spellcheck" class="solr.TextField">
- <analyzer type="index">
- <tokenizer class="solr.StandardTokenizerFactory"/>
- <filter class="solr.LowerCaseFilterFactory"/>
- <filter class="solr.ShingleFilterFactory" minShingleSize="2" maxShingleSize="3"
- outputUnigrams="true" outputUnigramsIfNoShingles="true" tokenSeparator=" " fillerToken="*"/>
- </analyzer>
- <analyzer type="query">
- <tokenizer class="solr.KeywordTokenizerFactory"/>
- <filter class="solr.LowerCaseFilterFactory"/>
- </analyzer>
- </fieldtype>
-
- <fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>
-
- <fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>
- <fieldType name="float" class="solr.TrieFloatField" precisionStep="0" positionIncrementGap="0"/>
- <fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
- <fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" positionIncrementGap="0"/>
-
- <fieldType name="tint" class="solr.TrieIntField" precisionStep="8" positionIncrementGap="0"/>
- <fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" positionIncrementGap="0"/>
- <fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" positionIncrementGap="0"/>
- <fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" positionIncrementGap="0"/>
- <fieldType name="date" class="solr.TrieDateField" precisionStep="0" positionIncrementGap="0"/>
-
- <fieldType name="tdate" class="solr.TrieDateField" precisionStep="6" positionIncrementGap="0"/>
-
- <fieldtype name="binary" class="solr.BinaryField"/>
-
- <fieldtype name="ignored" stored="false" indexed="false" multiValued="true" class="solr.StrField"/>
- </types>
-
- <fields>
- <field name="path_exact" type="string" indexed="true" stored="true"/>
- <field name="path_child" type="children_path" indexed="true" stored="false"/>
- <field name="path_anc" type="parent_path" indexed="true" stored="false"/>
- <field name="path_des" type="descendent_path" indexed="true" stored="false"/>
- <field name="catch_all" type="text_general" indexed="true" stored="false" multiValued="true" termVectors="true"/> <!-- term vectors used for rep:similar -->
- <field name=":path" type="string" indexed="true" stored="false" />
- <field name=":indexed" type="tdate" indexed="true" stored="false" default="NOW" docValues="true"/>
- <field name=":suggest-weight" type="tint" indexed="false" stored="false" default="1" docValues="true"/>
- <field name=":suggest" type="string" indexed="true" stored="true" multiValued="true" />
- <field name=":spellcheck" type="spellcheck" indexed="true" stored="false" multiValued="true" />
- <field name="path_collapsed" type="string" indexed="true" stored="false" docValues="true"/>
- <field name="path_depth" type="tint" indexed="true" stored="false"/>
- <field name="_version_" type="long" indexed="true" stored="true"/>
-
- <!-- facet fields -->
- <dynamicField name="*_facet" type="string" indexed="false" stored="false" docValues="true" multiValued="true"/>
-
- <!-- sorting dynamic fields -->
- <dynamicField name="*_double_sort" type="tdouble" indexed="false" stored="false" multiValued="false" docValues="true"/>
- <dynamicField name="*_string_sort" type="string" indexed="false" stored="false" multiValued="false" docValues="true"/>
- <dynamicField name="*_binary_sort" type="string" indexed="true" stored="false" multiValued="false" omitNorms="true"/>
-
- <dynamicField name="*" type="text_general" indexed="true" stored="false" multiValued="true"/>
- </fields>
-
- <uniqueKey>path_exact</uniqueKey>
- <copyField source="path_exact" dest="path_anc"/>
- <copyField source="path_exact" dest="path_des"/>
- <copyField source="path_exact" dest="path_child"/>
- <copyField source="path_exact" dest=":path"/>
- <copyField source="*" dest="catch_all"/>
- <copyField source="jcr:primaryType" dest="jcr:primaryType_facet"/>
- <copyField source="jcr:title" dest=":spellcheck"/>
- <copyField source="jcr:description" dest=":spellcheck"/>
- <copyField source="jcr:title" dest=":suggest"/>
- <copyField source="jcr:description" dest=":suggest"/>
-
-</schema>
diff --git a/oak-solr-core/src/main/resources/solr/oak/conf/solrconfig.xml b/oak-solr-core/src/main/resources/solr/oak/conf/solrconfig.xml
deleted file mode 100644
index 25f2c2b2b2..0000000000
--- a/oak-solr-core/src/main/resources/solr/oak/conf/solrconfig.xml
+++ /dev/null
@@ -1,353 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<config>
-
- <luceneMatchVersion>6.6.6</luceneMatchVersion>
-
- <dataDir>${solr.data.dir:}</dataDir>
-
- <directoryFactory name="DirectoryFactory"
- class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}">
-
- </directoryFactory>
-
- <codecFactory class="solr.SchemaCodecFactory"/>
-
- <schemaFactory class="ClassicIndexSchemaFactory"/>
-
- <indexConfig>
-
- <lockType>${solr.lock.type:native}</lockType>
-
- <infoStream>false</infoStream>
- </indexConfig>
-
- <jmx />
-
- <updateHandler class="solr.DirectUpdateHandler2">
-
- <updateLog>
- <str name="dir">${solr.ulog.dir:}</str>
- </updateLog>
-
- <autoCommit>
- <maxTime>${solr.autoCommit.maxTime:15000}</maxTime>
- <openSearcher>false</openSearcher>
- </autoCommit>
-
- <autoSoftCommit>
- <maxTime>${solr.autoSoftCommit.maxTime:-1}</maxTime>
- </autoSoftCommit>
-
- </updateHandler>
-
-
- <query>
-
- <maxBooleanClauses>1024</maxBooleanClauses>
-
-
- <filterCache class="solr.FastLRUCache"
- size="4096"
- initialSize="1024"
- autowarmCount="512"/>
-
- <queryResultCache class="solr.FastLRUCache"
- size="40960"
- initialSize="4096"
- autowarmCount="2048"/>
-
- <documentCache class="solr.LRUCache"
- size="40960"
- initialSize="1024"
- autowarmCount="0"/>
-
- <cache name="perSegFilter"
- class="solr.search.LRUCache"
- size="10"
- initialSize="0"
- autowarmCount="10"
- regenerator="solr.NoOpRegenerator" />
-
-
- <fieldValueCache class="solr.FastLRUCache"
- size="4096"
- autowarmCount="1024"
- showItems="32" />
-
- <enableLazyFieldLoading>true</enableLazyFieldLoading>
-
- <queryResultWindowSize>20</queryResultWindowSize>
-
- <queryResultMaxDocsCached>200</queryResultMaxDocsCached>
-
- <useColdSearcher>false</useColdSearcher>
-
- <maxWarmingSearchers>2</maxWarmingSearchers>
-
- </query>
-
-
- <requestDispatcher handleSelect="false" >
-
- <requestParsers enableRemoteStreaming="true"
- multipartUploadLimitInKB="2048000"
- formdataUploadLimitInKB="2048"
- addHttpRequestToContext="false"/>
-
- <httpCaching never304="true" />
-
- </requestDispatcher>
-
- <requestHandler name="/select" class="solr.SearchHandler">
- <lst name="defaults">
- <str name="echoParams">none</str>
- <str name="wt">json</str>
- <int name="rows">10</int>
- <str name="df">catch_all</str>
- </lst>
-
- <arr name="last-components">
- </arr>
- </requestHandler>
-
- <!-- A request handler that returns indented JSON by default -->
- <requestHandler name="/query" class="solr.SearchHandler">
- <lst name="defaults">
- <str name="echoParams">explicit</str>
- <str name="wt">json</str>
- <str name="indent">true</str>
- <str name="df">text</str>
- </lst>
- </requestHandler>
-
-
- <requestHandler name="/get" class="solr.RealTimeGetHandler">
- <lst name="defaults">
- <str name="omitHeader">true</str>
- <str name="wt">json</str>
- <str name="indent">true</str>
- </lst>
- </requestHandler>
-
- <requestHandler name="/analysis/field"
- startup="lazy"
- class="solr.FieldAnalysisRequestHandler" />
-
- <requestHandler name="/mlt" class="solr.MoreLikeThisHandler">
- </requestHandler>
-
- <requestHandler name="/analysis/document"
- class="solr.DocumentAnalysisRequestHandler"
- startup="lazy" />
-
-<!-- <requestHandler name="/admin/"-->
-<!-- class="solr.admin.AdminHandlers" />-->
-
- <requestHandler name="/admin/ping" class="solr.PingRequestHandler">
- <lst name="invariants">
- <str name="q">solrpingquery</str>
- </lst>
- <lst name="defaults">
- <str name="echoParams">all</str>
- </lst>
- </requestHandler>
-
-
- <searchComponent name="suggest" class="solr.SuggestComponent">
- <lst name="suggester">
- <str name="name">default</str>
- <str name="lookupImpl">FuzzyLookupFactory</str>
- <str name="dictionaryImpl">DocumentDictionaryFactory</str>
- <str name="field">:suggest</str>
- <str name="weightField">:suggest-weight</str>
- <str name="suggestAnalyzerFieldType">string</str>
- <str name="buildOnStartup">true</str>
- </lst>
- </searchComponent>
-
- <requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy">
- <lst name="defaults">
- <str name="suggest">true</str>
- <str name="suggest.count">10</str>
- </lst>
- <arr name="components">
- <str>suggest</str>
- </arr>
- </requestHandler>
-
-
- <searchComponent name="spellcheck" class="solr.SpellCheckComponent">
-
- <str name="queryAnalyzerFieldType">spellcheck</str>
-
- <!-- a spellchecker built from a field of the main index -->
- <lst name="spellchecker">
- <str name="name">default</str>
- <str name="field">:spellcheck</str>
- <str name="classname">solr.DirectSolrSpellChecker</str>
- <str name="distanceMeasure">internal</str>
- <!-- minimum accuracy needed to be considered a valid spellcheck suggestion -->
- <float name="accuracy">0.5</float>
- <!-- the maximum #edits we consider when enumerating terms: can be 1 or 2 -->
- <int name="maxEdits">2</int>
- <!-- the minimum shared prefix when enumerating terms -->
- <int name="minPrefix">1</int>
- <!-- maximum number of inspections per result. -->
- <int name="maxInspections">5</int>
- <!-- minimum length of a query term to be considered for correction -->
- <int name="minQueryLength">4</int>
- <!-- maximum threshold of documents a query term can appear to be considered for correction -->
- <float name="maxQueryFrequency">0.01</float>
- </lst>
-
- </searchComponent>
-
- <requestHandler name="/spellcheck" class="solr.SearchHandler" startup="lazy">
- <lst name="defaults">
- <str name="spellcheck.dictionary">default</str>
- <str name="spellcheck">on</str>
- <str name="spellcheck.extendedResults">true</str>
- <str name="spellcheck.count">10</str>
- <str name="spellcheck.alternativeTermCount">5</str>
- <str name="spellcheck.maxResultsForSuggest">5</str>
- <str name="spellcheck.collate">true</str>
- <str name="spellcheck.collateExtendedResults">true</str>
- <str name="spellcheck.maxCollationTries">10</str>
- <str name="spellcheck.maxCollations">5</str>
- </lst>
- <arr name="last-components">
- <str>spellcheck</str>
- </arr>
- </requestHandler>
-
-
- <searchComponent class="solr.HighlightComponent" name="highlight">
- <highlighting>
- <!-- Configure the standard fragmenter -->
- <!-- This could most likely be commented out in the "default" case -->
- <fragmenter name="gap"
- default="true"
- class="solr.highlight.GapFragmenter">
- <lst name="defaults">
- <int name="hl.fragsize">100</int>
- </lst>
- </fragmenter>
-
- <!-- A regular-expression-based fragmenter
- (for sentence extraction)
- -->
- <fragmenter name="regex"
- class="solr.highlight.RegexFragmenter">
- <lst name="defaults">
- <!-- slightly smaller fragsizes work better because of slop -->
- <int name="hl.fragsize">70</int>
- <!-- allow 50% slop on fragment sizes -->
- <float name="hl.regex.slop">0.5</float>
- <!-- a basic sentence pattern -->
- <str name="hl.regex.pattern">[-\w
- ,/\n\"']{20,200}
- </str>
- </lst>
- </fragmenter>
-
- <!-- Configure the standard formatter -->
- <formatter name="html"
- default="true"
- class="solr.highlight.HtmlFormatter">
- <lst name="defaults">
- <str name="hl.simple.pre"><![CDATA[<em>]]></str>
- <str name="hl.simple.post"><![CDATA[</em>]]></str>
- </lst>
- </formatter>
-
- <!-- Configure the standard encoder -->
- <encoder name="html"
- class="solr.highlight.HtmlEncoder"/>
-
- <!-- Configure the standard fragListBuilder -->
- <fragListBuilder name="simple"
- class="solr.highlight.SimpleFragListBuilder"/>
-
- <!-- Configure the single fragListBuilder -->
- <fragListBuilder name="single"
- class="solr.highlight.SingleFragListBuilder"/>
-
- <!-- Configure the weighted fragListBuilder -->
- <fragListBuilder name="weighted"
- default="true"
- class="solr.highlight.WeightedFragListBuilder"/>
-
- <!-- default tag FragmentsBuilder -->
- <fragmentsBuilder name="default"
- default="true"
- class="solr.highlight.ScoreOrderFragmentsBuilder">
- <!--
- <lst name="defaults">
- <str name="hl.multiValuedSeparatorChar">/</str>
- </lst>
- -->
- </fragmentsBuilder>
-
- <!-- multi-colored tag FragmentsBuilder -->
- <fragmentsBuilder name="colored"
- class="solr.highlight.ScoreOrderFragmentsBuilder">
- <lst name="defaults">
- <str name="hl.tag.pre"><![CDATA[
- <b style="background:yellow">,<b style="background:lawgreen">,
- <b style="background:aquamarine">,<b style="background:magenta">,
- <b style="background:palegreen">,<b style="background:coral">,
- <b style="background:wheat">,<b style="background:khaki">,
- <b style="background:lime">,<b style="background:deepskyblue">]]></str>
- <str name="hl.tag.post"><![CDATA[</b>]]></str>
- </lst>
- </fragmentsBuilder>
-
- <boundaryScanner name="default"
- default="true"
- class="solr.highlight.SimpleBoundaryScanner">
- <lst name="defaults">
- <str name="hl.bs.maxScan">10</str>
- <str name="hl.bs.chars">.,!? 	 </str>
- </lst>
- </boundaryScanner>
-
- <boundaryScanner name="breakIterator"
- class="solr.highlight.BreakIteratorBoundaryScanner">
- <lst name="defaults">
- <!-- type should be one of CHARACTER, WORD(default), LINE and SENTENCE -->
- <str name="hl.bs.type">WORD</str>
- <!-- language and country are used when constructing Locale object. -->
- <!-- And the Locale object will be used when getting instance of BreakIterator -->
- <str name="hl.bs.language">en</str>
- <str name="hl.bs.country">US</str>
- </lst>
- </boundaryScanner>
- </highlighting>
- </searchComponent>
-
-
- <queryResponseWriter name="json" class="solr.JSONResponseWriter">
- <str name="content-type">text/plain; charset=UTF-8</str>
- </queryResponseWriter>
-
- <admin>
- <defaultQuery>*:*</defaultQuery>
- </admin>
-
-</config>
diff --git a/oak-solr-core/src/main/resources/solr/oak/core.properties b/oak-solr-core/src/main/resources/solr/oak/core.properties
deleted file mode 100644
index 60ed22f7f8..0000000000
--- a/oak-solr-core/src/main/resources/solr/oak/core.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-name=oak
diff --git a/oak-solr-core/src/main/resources/solr/solr.xml b/oak-solr-core/src/main/resources/solr/solr.xml
deleted file mode 100644
index c94a54a244..0000000000
--- a/oak-solr-core/src/main/resources/solr/solr.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<!--
- This is an example of a simple "solr.xml" file for configuring one or
- more Solr Cores, as well as allowing Cores to be added, removed, and
- reloaded via HTTP requests.
-
- More information about options available in this configuration file,
- and Solr Core administration can be found online:
- http://wiki.apache.org/solr/CoreAdmin
--->
-
-<solr>
-
- <solrcloud>
- <str name="host">${host:}</str>
- <int name="hostPort">${jetty.port:8983}</int>
- <str name="hostContext">${hostContext:solr}</str>
- <int name="zkClientTimeout">${zkClientTimeout:30000}</int>
- <bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool>
- </solrcloud>
-
- <shardHandlerFactory name="shardHandlerFactory"
- class="HttpShardHandlerFactory">
- <int name="socketTimeout">${socketTimeout:0}</int>
- <int name="connTimeout">${connTimeout:0}</int>
- </shardHandlerFactory>
-
-</solr>
diff --git a/oak-solr-core/src/main/resources/solr/zoo.cfg b/oak-solr-core/src/main/resources/solr/zoo.cfg
deleted file mode 100644
index 07d7fd3f9d..0000000000
--- a/oak-solr-core/src/main/resources/solr/zoo.cfg
+++ /dev/null
@@ -1,32 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# The number of milliseconds of each tick
-tickTime=2000
-# The number of ticks that the initial
-# synchronization phase can take
-initLimit=10
-# The number of ticks that can pass between
-# sending a request and getting an acknowledgement
-syncLimit=5
-
-# the directory where the snapshot is stored.
-# dataDir=/opt/zookeeper/data
-# NOTE: Solr defaults the dataDir to <solrHome>/zoo_data
-
-# the port at which the clients will connect
-# clientPort=2181
-# NOTE: Solr sets this based on zkRun / zkHost params
-
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/SolrOakRepositoryStub.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/SolrOakRepositoryStub.java
deleted file mode 100644
index b5ea47eb3f..0000000000
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/SolrOakRepositoryStub.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.jcr;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
-import javax.jcr.RepositoryException;
-
-import org.apache.jackrabbit.oak.plugins.index.aggregate.AggregateIndexProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.DefaultSolrConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.DefaultSolrConfigurationProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate.NodeStateSolrServersObserver;
-import org.apache.jackrabbit.oak.plugins.index.solr.index.SolrIndexEditorProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndexProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.server.EmbeddedSolrServerProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.util.SolrIndexInitializer;
-import org.apache.solr.client.solrj.SolrClient;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.junit.After;
-
-import static org.junit.Assert.assertNotNull;
-
-@Deprecated(forRemoval=true, since="1.74.0")
-public class SolrOakRepositoryStub extends OakSegmentTarRepositoryStub {
-
- private SolrServerProvider solrServerProvider;
-
- public SolrOakRepositoryStub(Properties settings)
- throws RepositoryException {
- super(settings);
- }
-
- @After
- public void tearDown() throws Exception{
- solrServerProvider.close();
- }
-
- @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 = new SolrServerProvider() {
- @Override
- public void close() throws IOException {
- if (solrServer != null) {
- solrServer.close();
- }
- }
-
- @Nullable
- @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() {
- @NotNull
- @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));
- }
-}
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/FacetTest.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/FacetTest.java
deleted file mode 100644
index fffa871674..0000000000
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/FacetTest.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.jackrabbit.oak.jcr.query;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Session;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.QueryResult;
-
-import java.util.List;
-
-import org.apache.jackrabbit.core.query.AbstractQueryTest;
-import org.apache.jackrabbit.oak.query.facet.FacetResult;
-
-/**
- * Test for faceting capabilities via JCR API
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class FacetTest extends AbstractQueryTest {
-
- public void testFacetRetrieval() throws Exception {
- Session session = superuser;
- Node n1 = testRootNode.addNode("node1");
- n1.setProperty("text", "hello");
- Node n2 = testRootNode.addNode("node2");
- n2.setProperty("text", "hallo");
- Node n3 = testRootNode.addNode("node3");
- n3.setProperty("text", "oh hallo");
- session.save();
-
- QueryManager qm = session.getWorkspace().getQueryManager();
- String sql2 = "select [jcr:path], [rep:facet(text)] from [nt:base] " +
- "where contains([text], 'hello OR hallo') order by [jcr:path]";
- Query q = qm.createQuery(sql2, Query.JCR_SQL2);
- QueryResult result = q.execute();
- FacetResult facetResult = new FacetResult(result);
- assertNotNull(facetResult);
- assertNotNull(facetResult.getDimensions());
- assertEquals(1, facetResult.getDimensions().size());
- assertTrue(facetResult.getDimensions().contains("text"));
- List<FacetResult.Facet> facets = facetResult.getFacets("text");
- assertNotNull(facets);
- assertEquals("hallo", facets.get(0).getLabel());
- assertEquals(1, facets.get(0).getCount(), 0);
- assertEquals("hello", facets.get(1).getLabel());
- assertEquals(1, facets.get(1).getCount(), 0);
- assertEquals("oh hallo", facets.get(2).getLabel());
- assertEquals(1, facets.get(2).getCount(), 0);
-
- NodeIterator nodes = result.getNodes();
- assertTrue(nodes.hasNext());
- assertNotNull(nodes.nextNode());
- assertTrue(nodes.hasNext());
- assertNotNull(nodes.nextNode());
- assertTrue(nodes.hasNext());
- assertNotNull(nodes.nextNode());
- assertFalse(nodes.hasNext());
- }
-
- public void testFacetRetrievalMV() throws Exception {
- Session session = superuser;
- Node n1 = testRootNode.addNode("node1");
- n1.setProperty("jcr:title", "apache jackrabbit oak");
- n1.setProperty("tags", new String[]{"software", "repository", "apache"});
- Node n2 = testRootNode.addNode("node2");
- n2.setProperty("jcr:title", "oak furniture");
- n2.setProperty("tags", "furniture");
- Node n3 = testRootNode.addNode("node3");
- n3.setProperty("jcr:title", "oak cosmetics");
- n3.setProperty("tags", "cosmetics");
- Node n4 = testRootNode.addNode("node4");
- n4.setProperty("jcr:title", "oak and aem");
- n4.setProperty("tags", new String[]{"software", "repository", "aem"});
- session.save();
-
- QueryManager qm = session.getWorkspace().getQueryManager();
- String sql2 = "select [jcr:path], [rep:facet(tags)] from [nt:base] " +
- "where contains([jcr:title], 'oak') order by [jcr:path]";
- Query q = qm.createQuery(sql2, Query.JCR_SQL2);
- QueryResult result = q.execute();
- FacetResult facetResult = new FacetResult(result);
- assertNotNull(facetResult);
- assertNotNull(facetResult.getDimensions());
- assertEquals(1, facetResult.getDimensions().size());
- assertTrue(facetResult.getDimensions().contains("tags"));
- List<FacetResult.Facet> facets = facetResult.getFacets("tags");
- assertNotNull(facets);
- assertEquals("repository", facets.get(0).getLabel());
- assertEquals(2, facets.get(0).getCount(), 0);
- assertEquals("software", facets.get(1).getLabel());
- assertEquals(2, facets.get(1).getCount(), 0);
- assertEquals("aem", facets.get(2).getLabel());
- assertEquals(1, facets.get(2).getCount(), 0);
- assertEquals("apache", facets.get(3).getLabel());
- assertEquals(1, facets.get(3).getCount(), 0);
- assertEquals("cosmetics", facets.get(4).getLabel());
- assertEquals(1, facets.get(4).getCount(), 0);
- assertEquals("furniture", facets.get(5).getLabel());
- assertEquals(1, facets.get(5).getCount(), 0);
-
-
- NodeIterator nodes = result.getNodes();
- assertTrue(nodes.hasNext());
- assertNotNull(nodes.nextNode());
- assertTrue(nodes.hasNext());
- assertNotNull(nodes.nextNode());
- assertTrue(nodes.hasNext());
- assertNotNull(nodes.nextNode());
- assertTrue(nodes.hasNext());
- assertNotNull(nodes.nextNode());
- assertFalse(nodes.hasNext());
- }
-
- public void testFacetRetrievalWithAnonymousUser() throws Exception {
- Session session = superuser;
-
- Node n1 = testRootNode.addNode("node1");
- n1.setProperty("text", "hello");
- Node n2 = testRootNode.addNode("node2");
- n2.setProperty("text", "hallo");
- Node n3 = testRootNode.addNode("node3");
- n3.setProperty("text", "oh hallo");
- session.save();
-
- session = getHelper().getReadOnlySession();
-
- QueryManager qm = session.getWorkspace().getQueryManager();
- String sql2 = "select [jcr:path], [rep:facet(text)] from [nt:base] " +
- "where contains([text], 'hello OR hallo') order by [jcr:path]";
- Query q = qm.createQuery(sql2, Query.JCR_SQL2);
- QueryResult result = q.execute();
- FacetResult facetResult = new FacetResult(result);
- assertNotNull(facetResult);
- assertNotNull(facetResult.getDimensions());
- assertEquals(1, facetResult.getDimensions().size());
- assertTrue(facetResult.getDimensions().contains("text"));
- List<FacetResult.Facet> facets = facetResult.getFacets("text");
- assertNotNull(facets);
- assertEquals("hallo", facets.get(0).getLabel());
- assertEquals(1, facets.get(0).getCount(), 0);
- assertEquals("hello", facets.get(1).getLabel());
- assertEquals(1, facets.get(1).getCount(), 0);
- assertEquals("oh hallo", facets.get(2).getLabel());
- assertEquals(1, facets.get(2).getCount(), 0);
-
- NodeIterator nodes = result.getNodes();
- assertTrue(nodes.hasNext());
- assertNotNull(nodes.nextNode());
- assertTrue(nodes.hasNext());
- assertNotNull(nodes.nextNode());
- assertTrue(nodes.hasNext());
- assertNotNull(nodes.nextNode());
- assertFalse(nodes.hasNext());
- }
-
- public void testFacetRetrieval2() throws Exception {
- Session session = superuser;
- Node n1 = testRootNode.addNode("node1");
- String pn = "jcr:title";
- n1.setProperty(pn, "hello");
- Node n2 = testRootNode.addNode("node2");
- n2.setProperty(pn, "hallo");
- Node n3 = testRootNode.addNode("node3");
- n3.setProperty(pn, "oh hallo");
- session.save();
-
- QueryManager qm = session.getWorkspace().getQueryManager();
- String sql2 = "select [jcr:path], [rep:facet(" + pn + ")] from [nt:base] " +
- "where contains([" + pn + "], 'hallo') order by [jcr:path]";
- Query q = qm.createQuery(sql2, Query.JCR_SQL2);
- QueryResult result = q.execute();
- FacetResult facetResult = new FacetResult(result);
- assertNotNull(facetResult);
- assertNotNull(facetResult.getDimensions());
- assertEquals(1, facetResult.getDimensions().size());
- assertTrue(facetResult.getDimensions().contains(pn));
- List<FacetResult.Facet> facets = facetResult.getFacets(pn);
- assertNotNull(facets);
- assertEquals("hallo", facets.get(0).getLabel());
- assertEquals(1, facets.get(0).getCount(), 0);
- assertEquals("oh hallo", facets.get(1).getLabel());
- assertEquals(1, facets.get(1).getCount(), 0);
-
- NodeIterator nodes = result.getNodes();
- assertTrue(nodes.hasNext());
- assertNotNull(nodes.nextNode());
- assertTrue(nodes.hasNext());
- assertNotNull(nodes.nextNode());
- assertFalse(nodes.hasNext());
- }
-
- public void testMultipleFacetsRetrieval() throws Exception {
- Session session = superuser;
- Node n1 = testRootNode.addNode("node1");
- String pn = "jcr:title";
- String pn2 = "jcr:description";
- n1.setProperty(pn, "hello");
- n1.setProperty(pn2, "a");
- Node n2 = testRootNode.addNode("node2");
- n2.setProperty(pn, "hallo");
- n2.setProperty(pn2, "b");
- Node n3 = testRootNode.addNode("node3");
- n3.setProperty(pn, "oh hallo");
- n3.setProperty(pn2, "a");
- session.save();
-
- QueryManager qm = session.getWorkspace().getQueryManager();
- String sql2 = "select [jcr:path], [rep:facet(" + pn + ")], [rep:facet(" + pn2 + ")] from [nt:base] " +
- "where contains([" + pn + "], 'hallo') order by [jcr:path]";
- Query q = qm.createQuery(sql2, Query.JCR_SQL2);
- QueryResult result = q.execute();
- FacetResult facetResult = new FacetResult(result);
- assertNotNull(facetResult);
- assertNotNull(facetResult.getDimensions());
- assertEquals(2, facetResult.getDimensions().size());
- assertTrue(facetResult.getDimensions().contains(pn));
- assertTrue(facetResult.getDimensions().contains(pn2));
- List<FacetResult.Facet> facets = facetResult.getFacets(pn);
- assertNotNull(facets);
- assertEquals("hallo", facets.get(0).getLabel());
- assertEquals(1, facets.get(0).getCount(), 0);
- assertEquals("oh hallo", facets.get(1).getLabel());
- assertEquals(1, facets.get(1).getCount(), 0);
- List<FacetResult.Facet> facets1 = facetResult.getFacets(pn2);
- assertNotNull(facets1);
- assertEquals("a", facets1.get(0).getLabel());
- assertEquals(1, facets1.get(0).getCount(), 0);
- assertEquals("b", facets1.get(1).getLabel());
- assertEquals(1, facets1.get(1).getCount(), 0);
-
- NodeIterator nodes = result.getNodes();
- assertTrue(nodes.hasNext());
- assertNotNull(nodes.nextNode());
- assertTrue(nodes.hasNext());
- assertNotNull(nodes.nextNode());
- assertFalse(nodes.hasNext());
- }
-
-}
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryFulltextTest.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryFulltextTest.java
deleted file mode 100644
index 46d77a8516..0000000000
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryFulltextTest.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.jackrabbit.oak.jcr.query;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.RowIterator;
-
-import org.apache.jackrabbit.core.query.AbstractQueryTest;
-
-/**
- * Tests the fulltext index.
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class QueryFulltextTest extends AbstractQueryTest {
-
- public void testScore() throws Exception {
- Session session = superuser;
- QueryManager qm = session.getWorkspace().getQueryManager();
- Node n1 = testRootNode.addNode("node1");
- n1.setProperty("text", "hello hello hello");
- Node n2 = testRootNode.addNode("node2");
- n2.setProperty("text", "hello");
- session.save();
-
- String xpath = "/jcr:root//*[jcr:contains(@text, 'hello')] order by jcr:score()";
- Query q = qm.createQuery(xpath, "xpath");
- String result = getResult(q.execute(), "jcr:score");
- // expect two numbers (any value)
- result = result.replaceAll("[0-9\\.]+", "n");
- assertEquals("n, n", result);
- }
-
- public void testNativeMatchAll() throws Exception {
- Session session = superuser;
- QueryManager qm = session.getWorkspace().getQueryManager();
-
- String sql2 = "select [jcr:path] as [path] from [nt:base] " +
- "where native('solr', '*:*')";
- Query q = qm.createQuery(sql2, Query.JCR_SQL2);
- QueryResult result = q.execute();
- NodeIterator nodes = result.getNodes();
- while (nodes.hasNext()) {
- Node node = nodes.nextNode();
- assertNotNull(node);
- }
- }
-
- public void testFulltext() throws Exception {
- Session session = superuser;
- QueryManager qm = session.getWorkspace().getQueryManager();
- Node n1 = testRootNode.addNode("node1");
- n1.setProperty("text", "hello");
- Node n2 = testRootNode.addNode("node2");
- n2.setProperty("text", "hallo");
- Node n3 = testRootNode.addNode("node3");
- n3.setProperty("text", "hello hallo");
- session.save();
-
- // lowercase "or" mean search for the term "or"
- String sql2 = "select [jcr:path] as [path] from [nt:base] " +
- "where contains([text], 'hello or hallo') order by [jcr:path]";
- Query q = qm.createQuery(sql2, Query.JCR_SQL2);
- assertEquals("", getResult(q.execute(), "path"));
-
- }
-
- public void testFulltextRelativeProperty() throws Exception {
- Session session = superuser;
- QueryManager qm = session.getWorkspace().getQueryManager();
- Node n1 = testRootNode.addNode("node1");
- n1.setProperty("text", "hello");
- Node n2 = testRootNode.addNode("node2");
- n2.setProperty("text", "hallo");
- Node n3 = testRootNode.addNode("node3");
- n3.setProperty("text", "hello hallo");
- session.save();
-
- Query q;
-
- String sql2 = "select [jcr:path] as [path] from [nt:base] " +
- "where ISCHILDNODE([/testroot])" +
- " AND CONTAINS(text, 'hallo')";
-
- q = qm.createQuery(sql2, Query.JCR_SQL2);
- assertEquals("/testroot/node2, /testroot/node3", getResult(q.execute(), "path"));
-
- sql2 = "select [jcr:path] as [path] from [nt:base] "
- + "where contains([node1/text], 'hello') order by [jcr:path]";
- q = qm.createQuery(sql2, Query.JCR_SQL2);
- assertEquals("/testroot", getResult(q.execute(), "path"));
-
- sql2 = "select [jcr:path] as [path] from [nt:base] "
- + "where contains([node2/text], 'hello OR hallo') order by [jcr:path]";
- q = qm.createQuery(sql2, Query.JCR_SQL2);
- assertEquals("/testroot", getResult(q.execute(), "path"));
-
- sql2 = "select [jcr:path] as [path] from [nt:base] "
- + "where contains([node1/text], 'hello') "
- + "and contains([node2/text], 'hallo') "
- + "order by [jcr:path]";
- q = qm.createQuery(sql2, Query.JCR_SQL2);
- assertEquals("/testroot", getResult(q.execute(), "path"));
- }
-
- public void testInValues() throws Exception {
-
- Session session = superuser;
- QueryManager qm = session.getWorkspace().getQueryManager();
- Node n1 = testRootNode.addNode("node1");
- n1.setProperty("text", "hello");
- Node n2 = testRootNode.addNode("node2");
- n2.setProperty("text", "hallo");
- Node n3 = testRootNode.addNode("node3");
- n3.setProperty("text", "hello hallo");
- session.save();
-
- String sql2 = "select [jcr:path] as [path], [jcr:score], * from [nt:base] as a " +
- "where [text] in('hello', 'hallo')";
-
- Query q = qm.createQuery(sql2, Query.JCR_SQL2);
- String path = getResult(q.execute(), "path");
- assertEquals("/testroot/node1, /testroot/node2", path);
-
- }
-
- static String getResult(QueryResult result, String propertyName) throws RepositoryException {
- StringBuilder buff = new StringBuilder();
- RowIterator it = result.getRows();
- while (it.hasNext()) {
- if (buff.length() > 0) {
- buff.append(", ");
- }
- buff.append(it.nextRow().getValue(propertyName).getString());
- }
- return buff.toString();
- }
-
-}
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryJcrTest.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryJcrTest.java
deleted file mode 100644
index 3eec1a7684..0000000000
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryJcrTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.jcr.query;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.apache.jackrabbit.core.query.ChildAxisQueryTest;
-import org.apache.jackrabbit.core.query.DerefTest;
-import org.apache.jackrabbit.core.query.ExcerptTest;
-import org.apache.jackrabbit.core.query.FnNameQueryTest;
-import org.apache.jackrabbit.core.query.FulltextQueryTest;
-import org.apache.jackrabbit.core.query.FulltextSQL2QueryTest;
-import org.apache.jackrabbit.core.query.JoinTest;
-import org.apache.jackrabbit.core.query.LimitAndOffsetTest;
-import org.apache.jackrabbit.core.query.MixinTest;
-import org.apache.jackrabbit.core.query.OrderByTest;
-import org.apache.jackrabbit.core.query.ParentNodeTest;
-import org.apache.jackrabbit.core.query.PathQueryNodeTest;
-import org.apache.jackrabbit.core.query.QueryResultTest;
-import org.apache.jackrabbit.core.query.SQL2NodeLocalNameTest;
-import org.apache.jackrabbit.core.query.SQL2OffsetLimitTest;
-import org.apache.jackrabbit.core.query.SQL2OrderByTest;
-import org.apache.jackrabbit.core.query.SQL2OuterJoinTest;
-import org.apache.jackrabbit.core.query.SQL2PathEscapingTest;
-import org.apache.jackrabbit.core.query.SQL2QueryResultTest;
-import org.apache.jackrabbit.core.query.SQLTest;
-import org.apache.jackrabbit.core.query.SelectClauseTest;
-import org.apache.jackrabbit.core.query.ShareableNodeTest;
-import org.apache.jackrabbit.core.query.SimilarQueryTest;
-import org.apache.jackrabbit.core.query.SimpleQueryTest;
-import org.apache.jackrabbit.core.query.SkipDeletedNodesTest;
-import org.apache.jackrabbit.core.query.UpperLowerCaseQueryTest;
-import org.apache.jackrabbit.core.query.VersionStoreQueryTest;
-import org.apache.jackrabbit.core.query.XPathAxisTest;
-import org.apache.jackrabbit.test.ConcurrentTestSuite;
-
-/**
- * Test suite of JCR tests to be run with Oak Solr index
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class QueryJcrTest extends TestCase {
-
- public static Test suite() {
- TestSuite suite = new ConcurrentTestSuite(
- "Jackrabbit query tests using a Solr based index");
- suite.addTestSuite(FulltextQueryTest.class);
- suite.addTestSuite(SQLTest.class);
- suite.addTestSuite(JoinTest.class);
- suite.addTestSuite(SkipDeletedNodesTest.class);
- suite.addTestSuite(PathQueryNodeTest.class);
- suite.addTestSuite(FulltextSQL2QueryTest.class);
- suite.addTestSuite(SQL2NodeLocalNameTest.class);
- suite.addTestSuite(SQL2OrderByTest.class);
- suite.addTestSuite(MixinTest.class);
- suite.addTestSuite(SQL2OuterJoinTest.class);
- suite.addTestSuite(SQL2OffsetLimitTest.class);
- suite.addTestSuite(LimitAndOffsetTest.class);
- suite.addTestSuite(OrderByTest.class);
-
- // OAK-9261: can't run this test with embedded Solr
- // suite.addTestSuite(ExcerptTest.class);
-
- suite.addTestSuite(QueryResultTest.class);
- suite.addTestSuite(ParentNodeTest.class);
- suite.addTestSuite(SimilarQueryTest.class);
- suite.addTestSuite(DerefTest.class);
- suite.addTestSuite(XPathAxisTest.class);
- suite.addTestSuite(SQL2QueryResultTest.class);
- suite.addTestSuite(SimpleQueryTest.class);
- suite.addTestSuite(FnNameQueryTest.class);
- suite.addTestSuite(UpperLowerCaseQueryTest.class);
- suite.addTestSuite(SQL2PathEscapingTest.class);
- suite.addTestSuite(ChildAxisQueryTest.class);
- suite.addTestSuite(SelectClauseTest.class);
- suite.addTestSuite(ShareableNodeTest.class);
- suite.addTestSuite(VersionStoreQueryTest.class);
- return suite;
- }
-}
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/SpellcheckTest.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/SpellcheckTest.java
deleted file mode 100644
index 628c89e602..0000000000
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/SpellcheckTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.jackrabbit.oak.jcr.query;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.Row;
-import javax.jcr.query.RowIterator;
-
-import org.apache.jackrabbit.core.query.AbstractQueryTest;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Tests the spellcheck support.
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class SpellcheckTest extends AbstractQueryTest {
-
- public void testSpellcheckSql() throws Exception {
- Session session = superuser;
- QueryManager qm = session.getWorkspace().getQueryManager();
- Node n1 = testRootNode.addNode("node1");
- n1.setProperty("jcr:title", "hello hello hello alt");
- Node n2 = testRootNode.addNode("node2");
- n2.setProperty("jcr:title", "hold");
- session.save();
-
- String sql = "SELECT [rep:spellcheck()] FROM nt:base WHERE [jcr:path] = '/' AND SPELLCHECK('helo')";
- Query q = qm.createQuery(sql, Query.SQL);
- List<String> result = getResult(q.execute(), "rep:spellcheck()");
- assertNotNull(result);
- assertEquals(2, result.size());
- assertEquals("[hello, hold]", result.toString());
- }
-
- public void testSpellcheckXPath() throws Exception {
- Session session = superuser;
- QueryManager qm = session.getWorkspace().getQueryManager();
- Node n1 = testRootNode.addNode("node1");
- n1.setProperty("jcr:title", "hello hello hello alt");
- Node n2 = testRootNode.addNode("node2");
- n2.setProperty("jcr:title", "hold");
- session.save();
-
- String xpath = "/jcr:root[rep:spellcheck('helo')]/(rep:spellcheck())";
- Query q = qm.createQuery(xpath, Query.XPATH);
- List<String> result = getResult(q.execute(), "rep:spellcheck()");
- assertNotNull(result);
- assertEquals(2, result.size());
- assertEquals("[hello, hold]", result.toString());
- }
-
- public void testSpellcheckMultipleWords() throws Exception {
- Session session = superuser;
- QueryManager qm = session.getWorkspace().getQueryManager();
- Node n1 = testRootNode.addNode("node1");
- n1.setProperty("jcr:title", "it is always a good idea to go visiting ontario");
- Node n2 = testRootNode.addNode("node2");
- n2.setProperty("jcr:title", "ontario is a nice place to live in");
- Node n3 = testRootNode.addNode("node3");
- n2.setProperty("jcr:title", "I flied to ontario for voting for the major polls");
- Node n4 = testRootNode.addNode("node4");
- n2.setProperty("jcr:title", "I will go voting in ontario, I always voted since I've been allowed to");
- session.save();
-
- String xpath = "/jcr:root[rep:spellcheck('votin in ontari')]/(rep:spellcheck())";
- Query q = qm.createQuery(xpath, Query.XPATH);
- List<String> result = getResult(q.execute(), "rep:spellcheck()");
- assertNotNull(result);
- assertEquals(1, result.size());
- assertEquals("voting in ontario", result.get(0));
- }
-
- static List<String> getResult(QueryResult result, String propertyName) throws RepositoryException {
- List<String> results = new ArrayList<>();
- RowIterator it = result.getRows();
- while (it.hasNext()) {
- Row row = it.nextRow();
- results.add(row.getValue(propertyName).getString());
- }
- return results;
- }
-
-}
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/SuggestTest.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/SuggestTest.java
deleted file mode 100644
index 99d8f6c014..0000000000
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/SuggestTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.jackrabbit.oak.jcr.query;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.Row;
-import javax.jcr.query.RowIterator;
-
-import org.apache.jackrabbit.core.query.AbstractQueryTest;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Tests the suggest support.
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class SuggestTest extends AbstractQueryTest {
-
- public void testSuggestSql() throws Exception {
- Session session = superuser;
- QueryManager qm = session.getWorkspace().getQueryManager();
- Node n1 = testRootNode.addNode("node1");
- n1.setProperty("jcr:title", "in 2015 my fox is red, like mike's fox and john's fox");
- Node n2 = testRootNode.addNode("node2");
- n2.setProperty("jcr:title", "in 2015 a red fox is still a fox");
- session.save();
-
- String sql = "SELECT [rep:suggest()] FROM nt:base WHERE [jcr:path] = '/' AND SUGGEST('in 201')";
- Query q = qm.createQuery(sql, Query.SQL);
- List<String> result = getResult(q.execute(), "rep:suggest()");
- assertNotNull(result);
- assertEquals(2, result.size());
- assertTrue(result.contains("in 2015 a red fox is still a fox"));
- assertTrue(result.contains("in 2015 my fox is red, like mike's fox and john's fox"));
- }
-
- public void testSuggestXPath() throws Exception {
- Session session = superuser;
- QueryManager qm = session.getWorkspace().getQueryManager();
- Node n1 = testRootNode.addNode("node1");
- n1.setProperty("jcr:title", "in 2015 my fox is red, like mike's fox and john's fox");
- Node n2 = testRootNode.addNode("node2");
- n2.setProperty("jcr:title", "in 2015 a red fox is still a fox");
- session.save();
-
- String xpath = "/jcr:root[rep:suggest('in 201')]/(rep:suggest())";
- Query q = qm.createQuery(xpath, Query.XPATH);
- List<String> result = getResult(q.execute(), "rep:suggest()");
- assertNotNull(result);
- assertEquals(2, result.size());
- assertTrue(result.contains("in 2015 a red fox is still a fox"));
- assertTrue(result.contains("in 2015 my fox is red, like mike's fox and john's fox"));
- }
-
- public void testNoSuggestions() throws Exception {
- Session session = superuser;
- QueryManager qm = session.getWorkspace().getQueryManager();
- Node n1 = testRootNode.addNode("node1");
- n1.setProperty("jcr:title", "in 2015 my fox is red, like mike's fox and john's fox");
- Node n2 = testRootNode.addNode("node2");
- n2.setProperty("jcr:title", "in 2015 a red fox is still a fox");
- session.save();
-
- String sql = "SELECT [rep:suggest()] FROM nt:base WHERE [jcr:path] = '/' AND SUGGEST('blablabla')";
- Query q = qm.createQuery(sql, Query.SQL);
- List<String> result = getResult(q.execute(), "rep:suggest()");
- assertNotNull(result);
- assertEquals("There shouldn't be any suggestions", 0, result.size());
- }
-
- static List<String> getResult(QueryResult result, String propertyName) throws RepositoryException {
- List<String> results = new ArrayList<>();
- RowIterator it = result.getRows();
- while (it.hasNext()) {
- Row row = it.nextRow();
- results.add(row.getValue(propertyName).getString());
- }
- return results;
- }
-
-}
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/TextExtractionQueryTest.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/TextExtractionQueryTest.java
deleted file mode 100644
index 15ae910bed..0000000000
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/TextExtractionQueryTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.jcr.query;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import javax.jcr.Binary;
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.query.Query;
-
-import org.apache.jackrabbit.JcrConstants;
-import org.apache.jackrabbit.commons.JcrUtils;
-import org.apache.jackrabbit.core.query.AbstractQueryTest;
-
-@Deprecated(forRemoval=true, since="1.74.0")
-public class TextExtractionQueryTest extends AbstractQueryTest {
-
- public void testFileContains() throws Exception {
- assertFileContains("test.txt", "text/plain",
- "AE502DBEA2C411DEBD340AD156D89593");
- assertFileContains("test.rtf", "application/rtf", "quick brown fox");
- }
-
- public void testNtFile() throws RepositoryException, IOException {
- while (testRootNode.hasNode(nodeName1)) {
- testRootNode.getNode(nodeName1).remove();
- }
-
- String content = "The quick brown fox jumps over the lazy dog.";
- Node file = JcrUtils.putFile(testRootNode, nodeName1, "text/plain",
- new ByteArrayInputStream(content.getBytes("UTF-8")));
-
- testRootNode.getSession().save();
- String xpath = testPath + "/*[jcr:contains(jcr:content, 'lazy')]";
- executeXPathQuery(xpath, new Node[] { file });
- }
-
- private void assertFileContains(String name, String type,
- String... statements) throws Exception {
- if (testRootNode.hasNode(nodeName1)) {
- testRootNode.getNode(nodeName1).remove();
- }
- testRootNode.getSession().save();
-
- Node resource = testRootNode.addNode(nodeName1, NodeType.NT_RESOURCE);
- resource.setProperty(JcrConstants.JCR_MIMETYPE, type);
- InputStream stream = getClass().getResourceAsStream(name);
- assertNotNull(stream);
- try {
- Binary binary = testRootNode.getSession().getValueFactory()
- .createBinary(stream);
- resource.setProperty(JcrConstants.JCR_DATA, binary);
- } finally {
- stream.close();
- }
- testRootNode.getSession().save();
- for (String statement : statements) {
- assertContainsQuery(statement, true);
- }
- }
-
- @SuppressWarnings("deprecation")
- private void assertContainsQuery(String statement, boolean match)
- throws RepositoryException {
- StringBuffer stmt = new StringBuffer();
- stmt.append("/jcr:root").append(testRoot).append("/*");
- stmt.append("[jcr:contains(., '").append(statement);
- stmt.append("')]");
-
- Query q = qm.createQuery(stmt.toString(), Query.XPATH);
- checkResult(q.execute(), match ? 1 : 0);
-
- stmt = new StringBuffer();
- stmt.append("SELECT * FROM nt:base ");
- stmt.append("WHERE jcr:path LIKE '").append(testRoot).append("/%' ");
- stmt.append("AND CONTAINS(., '").append(statement).append("')");
-
- q = qm.createQuery(stmt.toString(), Query.SQL);
- checkResult(q.execute(), match ? 1 : 0);
- }
-
-}
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/SolrBaseTest.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/SolrBaseTest.java
deleted file mode 100644
index dbf06adb65..0000000000
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/SolrBaseTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr;
-
-import javax.jcr.NoSuchWorkspaceException;
-import javax.security.auth.login.LoginException;
-
-import org.apache.jackrabbit.oak.Oak;
-import org.apache.jackrabbit.oak.api.ContentRepository;
-import org.apache.jackrabbit.oak.api.Root;
-import org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate.NodeStateSolrServersObserver;
-import org.apache.jackrabbit.oak.plugins.index.solr.index.SolrIndexEditorProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndexProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.util.SolrIndexInitializer;
-import org.apache.jackrabbit.oak.InitialContent;
-import org.apache.jackrabbit.oak.segment.SegmentNodeStoreBuilders;
-import org.apache.jackrabbit.oak.segment.memory.MemoryStore;
-import org.apache.jackrabbit.oak.spi.commit.EditorHook;
-import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider;
-import org.apache.jackrabbit.oak.spi.state.NodeStore;
-import org.apache.solr.client.solrj.SolrClient;
-import org.junit.After;
-import org.junit.Before;
-
-/**
- * Test base class for Oak-Solr
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public abstract class SolrBaseTest {
-
- protected NodeStore store;
- protected TestUtils provider;
- protected SolrClient server;
- protected OakSolrConfiguration configuration;
- protected EditorHook hook;
- private ContentRepository repository;
-
- @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(new SolrIndexInitializer(false)) // synchronous
- .with(new SolrQueryIndexProvider(provider, provider))
- .with(new NodeStateSolrServersObserver())
- .with(new SolrIndexEditorProvider(provider, provider));
- repository = oak
- .createContentRepository();
- }
-
- @After
- public void tearDown() throws Exception {
- if (server != null && server.ping() != null) {
- server.deleteByQuery("*:*");
- server.commit();
- server.close();
- server = null;
- }
- }
-
- protected Root createRoot() throws LoginException, NoSuchWorkspaceException {
- return repository.login(null, null).getLatestRoot();
- }
-
-}
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/TestUtils.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/TestUtils.java
deleted file mode 100644
index 01636b3e5e..0000000000
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/TestUtils.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr;
-
-import java.io.File;
-import java.io.IOException;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.DefaultSolrConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.server.EmbeddedSolrServerProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider;
-import org.apache.solr.client.solrj.SolrClient;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- * Utility class for tests
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class TestUtils
- implements SolrServerProvider, OakSolrConfigurationProvider {
-
- static final String SOLR_HOME_PATH = "/solr";
-
- 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);
- }
- }
-
- public static void cleanDataDir() {
- String path = TestUtils.class.getResource("/solr/oak/data").getFile();
- File file = new File(path);
- if (file.exists()) {
- assertTrue(file.delete());
- }
- }
-
- public static OakSolrConfiguration getTestConfiguration() {
- return new DefaultSolrConfiguration() {
- @NotNull
- @Override
- public CommitPolicy getCommitPolicy() {
- return CommitPolicy.HARD;
- }
-
- @Override
- public boolean useForPropertyRestrictions() {
- return true;
- }
-
- @Override
- public boolean useForPrimaryTypes() {
- return true;
- }
-
- @Override
- public boolean useForPathRestrictions() {
- return true;
- }
- };
- }
-
- private final SolrClient solrServer = createSolrServer();
-
- private final OakSolrConfiguration configuration = getTestConfiguration();
-
- @Nullable
- @Override
- public SolrClient getSolrServer() {
- return solrServer;
- }
-
- @Nullable
- @Override
- public SolrClient getIndexingSolrServer() throws Exception {
- return solrServer;
- }
-
- @Nullable
- @Override
- public SolrClient getSearchingSolrServer() throws Exception {
- return solrServer;
- }
-
- @NotNull
- @Override
- public OakSolrConfiguration getConfiguration() {
- return configuration;
- }
-
- @Override
- public void close() throws IOException {
-
- }
-}
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultAnalyzersConfigurationTest.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultAnalyzersConfigurationTest.java
deleted file mode 100644
index a79ed3df4a..0000000000
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultAnalyzersConfigurationTest.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.configuration;
-
-import java.io.StringReader;
-import java.util.regex.Pattern;
-
-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.BaseTokenStreamTestCase;
-import org.apache.lucene.analysis.TokenStream;
-import org.apache.lucene.analysis.Tokenizer;
-import org.apache.lucene.analysis.core.KeywordTokenizer;
-import org.apache.lucene.analysis.miscellaneous.LengthFilter;
-import org.apache.lucene.analysis.miscellaneous.RemoveDuplicatesTokenFilter;
-import org.apache.lucene.analysis.path.PathHierarchyTokenizer;
-import org.apache.lucene.analysis.pattern.PatternCaptureGroupTokenFilter;
-import org.apache.lucene.analysis.pattern.PatternReplaceFilter;
-import org.apache.lucene.analysis.reverse.ReverseStringFilter;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Testcase for checking default analyzers configurations behave as expected with regards to path related restrictions
- *
- * Note that default Solr analyzers for Oak should be equivalent to the ones programmatically defined here.
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@RunWith(com.carrotsearch.randomizedtesting.RandomizedRunner.class)
-@ThreadLeakScope(ThreadLeakScope.Scope.NONE)
-@Deprecated(forRemoval=true, since="1.74.0")
-public class DefaultAnalyzersConfigurationTest extends BaseTokenStreamTestCase {
-
- private Analyzer parentPathIndexingAnalyzer;
- private Analyzer parentPathSearchingAnalyzer;
- private Analyzer exactPathAnalyzer;
- private Analyzer directChildrenPathIndexingAnalyzer;
- private Analyzer directChildrenPathSearchingAnalyzer;
- private Analyzer allChildrenPathIndexingAnalyzer;
- private Analyzer allChildrenPathSearchingAnalyzer;
-
- @Before
- public void setUp() throws Exception {
- super.setUp();
- this.exactPathAnalyzer = new Analyzer() {
- @Override
- protected TokenStreamComponents createComponents(String fieldName) {
- Tokenizer source = new KeywordTokenizer();
- return new TokenStreamComponents(source);
- }
- };
- this.parentPathIndexingAnalyzer = new Analyzer() {
- @Override
- protected TokenStreamComponents createComponents(String fieldName) {
- Tokenizer source = new KeywordTokenizer();
- return new TokenStreamComponents(source);
- }
- };
- this.parentPathSearchingAnalyzer = new Analyzer() {
- @Override
- protected TokenStreamComponents createComponents(String fieldName) {
- Tokenizer source = new KeywordTokenizer();
- TokenStream filter = new ReverseStringFilter(source);
- filter = new PatternReplaceFilter(filter, Pattern.compile("[^\\/]+\\/"), "", false);
- filter = new ReverseStringFilter(filter);
- return new TokenStreamComponents(source, filter);
- }
- };
-
- this.directChildrenPathIndexingAnalyzer = new Analyzer() {
- @Override
- protected TokenStreamComponents createComponents(String fieldName) {
- Tokenizer source = new KeywordTokenizer();
- TokenStream filter = new ReverseStringFilter(source);
- filter = new LengthFilter(filter, 2, Integer.MAX_VALUE);
- filter = new PatternReplaceFilter(filter, Pattern.compile("([^\\/]+)(\\/)"), "$2", false);
- filter = new PatternReplaceFilter(filter, Pattern.compile("(\\/)(.+)"), "$2", false);
- filter = new ReverseStringFilter(filter);
- return new TokenStreamComponents(source, filter);
- }
- };
- this.directChildrenPathSearchingAnalyzer = new Analyzer() {
- @Override
- protected TokenStreamComponents createComponents(String fieldName) {
- Tokenizer source = new KeywordTokenizer();
- return new TokenStreamComponents(source);
- }
- };
-
- this.allChildrenPathIndexingAnalyzer = new Analyzer() {
- @Override
- protected TokenStreamComponents createComponents(String fieldName) {
- Tokenizer source = new PathHierarchyTokenizer();
- TokenStream filter = new PatternCaptureGroupTokenFilter(source, false, Pattern.compile("((\\/).*)"));
- filter = new RemoveDuplicatesTokenFilter(filter);
- return new TokenStreamComponents(source, filter);
- }
- };
- this.allChildrenPathSearchingAnalyzer = new Analyzer() {
- @Override
- protected TokenStreamComponents createComponents(String fieldName) {
- Tokenizer source = new KeywordTokenizer();
- return new TokenStreamComponents(source);
- }
- };
- }
-
- @After
- public void tearDown() throws Exception {
- super.tearDown();
- this.exactPathAnalyzer.close();
- this.parentPathIndexingAnalyzer.close();
- this.parentPathSearchingAnalyzer.close();
- this.directChildrenPathIndexingAnalyzer.close();
- this.directChildrenPathSearchingAnalyzer.close();
- this.allChildrenPathIndexingAnalyzer.close();
- this.allChildrenPathSearchingAnalyzer.close();
- }
-
- @Test
- public void testAllChildrenIndexingTokenization() throws Exception {
- try {
- TokenStream ts = allChildrenPathIndexingAnalyzer.tokenStream("text", new StringReader("/jcr:a/jcr:b/c/jcr:d"));
- assertTokenStreamContents(ts, new String[]{"/jcr:a", "/", "/jcr:a/jcr:b", "/jcr:a/jcr:b/c", "/jcr:a/jcr:b/c/jcr:d"});
- } finally {
- allChildrenPathIndexingAnalyzer.close();
- }
- }
-
- @Test
- public void testAllChildrenSearchingTokenization() throws Exception {
- try {
- TokenStream ts = allChildrenPathSearchingAnalyzer.tokenStream("text", new StringReader("/jcr:a/jcr:b/jcr:c"));
- assertTokenStreamContents(ts, new String[]{"/jcr:a/jcr:b/jcr:c"});
- } finally {
- allChildrenPathSearchingAnalyzer.close();
- }
- }
-
- @Test
- public void testDirectChildrenPathIndexingTokenization() throws Exception {
- try {
- TokenStream ts = directChildrenPathIndexingAnalyzer.tokenStream("text", new StringReader("/jcr:a/b/jcr:c"));
- assertTokenStreamContents(ts, new String[]{"/jcr:a/b"});
- ts = directChildrenPathIndexingAnalyzer.tokenStream("text", new StringReader("/jcr:a"));
- assertTokenStreamContents(ts, new String[]{"/"});
- ts = directChildrenPathIndexingAnalyzer.tokenStream("text", new StringReader("/"));
- assertTokenStreamContents(ts, new String[]{});
- } finally {
- directChildrenPathIndexingAnalyzer.close();
- }
- }
-
- @Test
- public void testDirectChildrenPathSearchingTokenization() throws Exception {
- try {
- TokenStream ts = directChildrenPathSearchingAnalyzer.tokenStream("text", new StringReader("/jcr:a/jcr:b"));
- assertTokenStreamContents(ts, new String[]{"/jcr:a/jcr:b"});
- } finally {
- directChildrenPathSearchingAnalyzer.close();
- }
- }
-
- @Test
- public void testExactPathIndexingTokenizationAndSearch() throws Exception {
- try {
- TokenStream ts = exactPathAnalyzer.tokenStream("text", new StringReader("/jcr:a/jcr:b/c"));
- assertTokenStreamContents(ts, new String[]{"/jcr:a/jcr:b/c"});
- } finally {
- exactPathAnalyzer.close();
- }
- }
-
- @Test
- public void testParentPathSearchingTokenization() throws Exception {
- try {
- TokenStream ts = parentPathSearchingAnalyzer.tokenStream("text", new StringReader("/jcr:a/b/jcr:c"));
- assertTokenStreamContents(ts, new String[]{"/jcr:a/b"});
- } finally {
- parentPathSearchingAnalyzer.close();
- }
- }
-
- @Test
- public void testParentPathIndexingTokenization() throws Exception {
- try {
- TokenStream ts = parentPathIndexingAnalyzer.tokenStream("text", new StringReader("/a/b"));
- assertTokenStreamContents(ts, new String[]{"/a/b"});
- } finally {
- parentPathIndexingAnalyzer.close();
- }
- }
-
- @Ignore("wrong endOffset")
- @Test
- public void testAllChildrenPathMatching() throws Exception {
- String nodePath = "/jcr:a/jcr:b/c";
- String descendantPath = nodePath + "/d/jcr:e";
- assertAnalyzesTo(allChildrenPathIndexingAnalyzer, descendantPath, new String[]{"/jcr:a", "/", "/jcr:a/jcr:b",
- "/jcr:a/jcr:b/c", "/jcr:a/jcr:b/c/d", "/jcr:a/jcr:b/c/d/jcr:e"});
- assertAnalyzesTo(allChildrenPathSearchingAnalyzer, nodePath, new String[]{nodePath});
- assertAnalyzesTo(allChildrenPathSearchingAnalyzer, "/jcr:a", new String[]{"/jcr:a"});
- assertAnalyzesTo(allChildrenPathSearchingAnalyzer, "/jcr:a/b", new String[]{"/jcr:a/b"});
- assertAnalyzesTo(allChildrenPathSearchingAnalyzer, "/a/b/c", new String[]{"/a/b/c"});
- assertAnalyzesTo(allChildrenPathSearchingAnalyzer, "/a/b/c/d", new String[]{"/a/b/c/d"});
- assertAnalyzesTo(allChildrenPathSearchingAnalyzer, "/a/b/c/d/jcr:e", new String[]{"/a/b/c/d/jcr:e"});
- assertAnalyzesTo(allChildrenPathSearchingAnalyzer, "/", new String[]{"/"});
- }
-
- @Ignore("wrong endOffset")
- @Test
- public void testAllChildrenPathMatchingOnRootNode() throws Exception {
- String nodePath = "/";
- String descendantPath = nodePath + "jcr:a/jcr:b";
- assertAnalyzesTo(allChildrenPathIndexingAnalyzer, descendantPath, new String[]{"/jcr:a", "/", "/jcr:a/jcr:b"});
- }
-
- @Test
- public void testDirectChildrenPathMatching() throws Exception {
- String nodePath = "/a/b/c";
- String childPath = nodePath + "/d";
- assertAnalyzesTo(directChildrenPathIndexingAnalyzer, childPath, new String[]{nodePath});
- assertAnalyzesTo(directChildrenPathSearchingAnalyzer, nodePath, new String[]{nodePath});
-
- nodePath = "/";
- childPath = nodePath + "/jcr:a";
- assertAnalyzesTo(directChildrenPathIndexingAnalyzer, childPath, new String[]{nodePath});
- assertAnalyzesTo(directChildrenPathSearchingAnalyzer, nodePath, new String[]{nodePath});
-
- String childPath1 = "/test/jcr:resource";
- String childPath2 = "/test/resource";
-
- nodePath = "/test";
- assertAnalyzesTo(directChildrenPathIndexingAnalyzer, childPath1, new String[]{nodePath});
- assertAnalyzesTo(directChildrenPathIndexingAnalyzer, childPath2, new String[]{nodePath});
- assertAnalyzesTo(directChildrenPathSearchingAnalyzer, nodePath, new String[]{nodePath});
- }
-
- @Test
- public void testParentPathMatching() throws Exception {
- String parentPath = "/a/b";
- String nodePath = parentPath + "/jcr:c";
- assertAnalyzesTo(parentPathIndexingAnalyzer, parentPath, new String[]{parentPath});
- assertAnalyzesTo(parentPathSearchingAnalyzer, nodePath, new String[]{parentPath});
- }
-
-}
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/EmbeddedSolrServerConfiguration.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/EmbeddedSolrServerConfiguration.java
deleted file mode 100644
index 6cbcd714b7..0000000000
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/EmbeddedSolrServerConfiguration.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.configuration;
-
-import org.apache.jackrabbit.oak.plugins.index.solr.server.EmbeddedSolrServerProvider;
-
-/**
- * Configuration parameters for starting a {@link org.apache.solr.client.solrj.SolrClient}
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class EmbeddedSolrServerConfiguration extends SolrServerConfiguration<EmbeddedSolrServerProvider> {
-
- private final String solrHomePath;
- private final String coreName;
- private HttpConfiguration httpConfiguration;
-
- public EmbeddedSolrServerConfiguration(String solrHomePath, String coreName) {
- this.solrHomePath = solrHomePath;
- this.coreName = coreName;
- }
-
- public EmbeddedSolrServerConfiguration withHttpConfiguration(String context, Integer httpPort) {
- if (context != null && context.length() > 0 && httpPort != null && httpPort > 0) {
- this.httpConfiguration = new HttpConfiguration(context, httpPort);
- }
- return this;
- }
-
- /**
- * get the Solr home path where all the configuration files are stored
- *
- * @return a <code>String</code> representing a path to the Solr home.
- */
- public String getSolrHomePath() {
- return solrHomePath;
- }
-
- /**
- * get the default core name to use for the Solr server
- *
- * @return a <code>String</code> representing the core name
- */
- public String getCoreName() {
- return coreName;
- }
-
- /**
- * get the {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration.HttpConfiguration} holding parameters for enabling Solr
- * server with HTTP bindings
- *
- * @return a {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration.HttpConfiguration} or <code>null</code> if not set
- */
- public HttpConfiguration getHttpConfiguration() {
- return httpConfiguration;
- }
-
- public static class HttpConfiguration {
- private final String context;
- private final Integer httpPort;
-
- HttpConfiguration(String context, Integer httpPort) {
- this.context = context;
- this.httpPort = httpPort;
- }
-
- public String getContext() {
- return context;
- }
-
- public Integer getHttpPort() {
- return httpPort;
- }
-
- @Override
- public String toString() {
- return "HttpConfiguration{" +
- "context='" + context + '\'' +
- ", httpPort=" + httpPort +
- '}';
- }
- }
-
- @Override
- public String toString() {
- return "EmbeddedSolrServerConfiguration{" +
- "solrHomePath='" + solrHomePath + '\'' +
- ", coreName='" + coreName + '\'' +
- ", httpConfiguration=" + httpConfiguration +
- '}';
- }
-}
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationTest.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationTest.java
deleted file mode 100644
index c09e97ee68..0000000000
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.configuration;
-
-import org.apache.jackrabbit.oak.plugins.index.solr.server.EmbeddedSolrServerProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.server.RemoteSolrServerProvider;
-import org.junit.Test;
-
-import static org.junit.Assert.assertNotNull;
-
-/**
- * Testcase for {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfiguration}
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class SolrServerConfigurationTest {
-
- @Test
- public void testCreateRemoteServerFromConfig() throws Exception {
- SolrServerConfiguration<RemoteSolrServerProvider> remoteSolrServerProviderSolrServerConfiguration =
- new RemoteSolrServerConfiguration(null, null, 1, 1, null, 10, 10, null);
- RemoteSolrServerProvider remoteSolrServerProvider = remoteSolrServerProviderSolrServerConfiguration.getProvider();
- assertNotNull(remoteSolrServerProvider);
- }
-
- @Test
- public void testCreteEmbeddedServerFromConfig() throws Exception {
- SolrServerConfiguration<EmbeddedSolrServerProvider> embeddedSolrServerSolrServerConfiguration = new EmbeddedSolrServerConfiguration(null, null);
- EmbeddedSolrServerProvider embeddedSolrServerProvider = embeddedSolrServerSolrServerConfiguration.getProvider();
- assertNotNull(embeddedSolrServerProvider);
- }
-}
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/nodestate/OakSolrNodeStateConfigurationTest.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/nodestate/OakSolrNodeStateConfigurationTest.java
deleted file mode 100644
index 0c5983dd45..0000000000
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/nodestate/OakSolrNodeStateConfigurationTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import org.apache.jackrabbit.oak.segment.SegmentNodeStoreBuilders;
-import org.apache.jackrabbit.oak.segment.memory.MemoryStore;
-import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
-import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
-import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.jackrabbit.oak.spi.state.NodeStore;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Tests for {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.nodestate.OakSolrNodeStateConfiguration}
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class OakSolrNodeStateConfigurationTest {
-
- private NodeStore store;
-
- @Before
- public void setUp() throws Exception {
- store = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
- NodeBuilder builder = store.getRoot().builder();
- builder.setProperty("a", 1)
- .setProperty("b", 2)
- .setProperty("c", 3);
-
- builder.setChildNode("x");
- builder.setChildNode("y");
- builder.setChildNode("z");
-
- builder.setChildNode("oak:index").setChildNode("solrIdx")
- .setProperty("type", "solr")
- .setProperty("rows", "100");
-
- store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
- }
-
- @Test
- public void testExistingPath() throws Exception {
- NodeState idxDef = store.getRoot().getChildNode("oak:index").getChildNode("solrIdx");
- OakSolrNodeStateConfiguration nodeStateConfiguration = new OakSolrNodeStateConfiguration(idxDef);
- assertNotNull(nodeStateConfiguration.getCatchAllField());
- }
-
- @Test
- public void testNonExistingPath() throws Exception {
- NodeState idxDef = store.getRoot().getChildNode("oak:index").getChildNode("a");
- try {
- new OakSolrNodeStateConfiguration(idxDef);
- } catch (IllegalArgumentException e) {
- // expected to fail as the NodeState doesn't exist
- }
- }
-
- @Test
- public void testWrongNodeState() throws Exception {
- NodeState idxDef = store.getRoot().getChildNode("x");
- try {
- new OakSolrNodeStateConfiguration(idxDef);
- fail();
- } catch (IllegalArgumentException e) {
- // expected to fail as the NodeState is not a solr node
- }
- }
-}
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditorIT.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditorIT.java
deleted file mode 100644
index 30bdc7a9df..0000000000
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditorIT.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.index;
-
-import org.apache.jackrabbit.oak.api.Root;
-import org.apache.jackrabbit.oak.plugins.index.solr.SolrBaseTest;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- * Integration test for {@link SolrIndexEditor}
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class SolrIndexEditorIT extends SolrBaseTest {
-
- @Test
- public void testAddSomeNodes() throws Exception {
- Root r = createRoot();
- r.getTree("/").addChild("a").addChild("b").addChild("doc1").
- setProperty("text", "hit that hot hat tattoo");
- r.getTree("/").getChild("a").addChild("c").addChild("doc2").
- setProperty("text", "it hits hot hats");
- r.getTree("/").getChild("a").getChild("b").addChild("doc3").
- setProperty("text", "tattoos hate hot hits");
- r.getTree("/").getChild("a").getChild("b").addChild("doc4").
- setProperty("text", "hats tattoos hit hot");
- r.commit();
-
- SolrQuery query = new SolrQuery();
- query.setQuery("*:*");
- QueryResponse queryResponse = server.query(query);
- assertTrue("no documents were indexed", queryResponse.getResults().size() > 0);
- }
-
- @Test
- public void testRemoveNode() throws Exception {
- Root r = createRoot();
-
- // Add a node
- r.getTree("/").addChild("testRemoveNode").setProperty("foo", "bar");
- r.commit();
-
- // check the node is not in Solr anymore
- SolrQuery query = new SolrQuery();
- query.setQuery("path_exact:\\/testRemoveNode");
- assertTrue("item with id:testRemoveNode was not found in the index",
- server.query(query).getResults().size() > 0);
-
- // remove the node in oak
- r.getTree("/").getChild("testRemoveNode").remove();
- r.commit();
-
- // check the node is not in Solr anymore
- assertTrue("item with id:testRemoveNode was found in the index",
- server.query(query).getResults().size() == 0);
- }
-}
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditorTest.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditorTest.java
deleted file mode 100644
index 08c9788025..0000000000
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditorTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.index;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-
-import org.apache.jackrabbit.oak.api.PropertyState;
-import org.apache.jackrabbit.oak.plugins.index.IndexUpdateCallback;
-import org.apache.jackrabbit.oak.plugins.index.solr.TestUtils;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.DefaultSolrConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration;
-import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
-import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.solr.client.solrj.SolrClient;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.jetbrains.annotations.NotNull;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-/**
- * Testcase for {@link org.apache.jackrabbit.oak.plugins.index.solr.index.SolrIndexEditor}
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class SolrIndexEditorTest {
-
- @Test
- public void testIndexedProperties() throws Exception {
- SolrClient solrServer = TestUtils.createSolrServer();
- try {
- OakSolrConfiguration configuration = TestUtils.getTestConfiguration();
- IndexUpdateCallback callback = mock(IndexUpdateCallback.class);
- SolrIndexEditor solrIndexEditor = new SolrIndexEditor(solrServer, configuration, callback);
- NodeState before = mock(NodeState.class);
- NodeState after = mock(NodeState.class);
- Iterable properties = (Iterable<PropertyState>) () -> Collections.singletonList(PropertyStates.createProperty("foo1", "bar")).iterator();
- when(after.getProperties()).thenReturn(properties);
- solrIndexEditor.leave(before, after);
- QueryResponse queryResponse = solrServer.query(new SolrQuery("foo1:*"));
- assertEquals(1, queryResponse.getResults().getNumFound());
- } finally {
- solrServer.close();
- }
- }
-
- @Test
- public void testIgnoredPropertiesNotIndexed() throws Exception {
- SolrClient solrServer = TestUtils.createSolrServer();
- try {
- OakSolrConfiguration configuration = new DefaultSolrConfiguration() {
- @NotNull
- @Override
- public Collection<String> getIgnoredProperties() {
- return Collections.singletonList("foo2");
- }
-
- @NotNull
- @Override
- public CommitPolicy getCommitPolicy() {
- return CommitPolicy.HARD;
- }
- };
- IndexUpdateCallback callback = mock(IndexUpdateCallback.class);
- SolrIndexEditor solrIndexEditor = new SolrIndexEditor(solrServer, configuration, callback);
- NodeState before = mock(NodeState.class);
- NodeState after = mock(NodeState.class);
- Iterable properties = new Iterable<PropertyState>() {
- @Override
- public Iterator<PropertyState> iterator() {
- return Collections.singletonList(PropertyStates.createProperty("foo2", "bar")).iterator();
- }
- };
- when(after.getProperties()).thenReturn(properties);
- solrIndexEditor.leave(before, after);
- QueryResponse queryResponse = solrServer.query(new SolrQuery("foo2:*"));
- assertEquals(0, queryResponse.getResults().getNumFound());
- } finally {
- solrServer.close();
- }
- }
-}
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/EmbeddedSolrServerConfigurationProvider.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/EmbeddedSolrServerConfigurationProvider.java
deleted file mode 100644
index 90c5bc9ae4..0000000000
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/EmbeddedSolrServerConfigurationProvider.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.osgi;
-
-import java.io.File;
-
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.metatype.annotations.Designate;
-import org.osgi.service.metatype.annotations.ObjectClassDefinition;
-import org.osgi.service.metatype.annotations.AttributeDefinition;
-
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationDefaults;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.server.EmbeddedSolrServerProvider;
-
-import org.jetbrains.annotations.NotNull;
-
-/**
- * An OSGi service {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationProvider}
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Component(
- immediate = true,
- service = { SolrServerConfigurationProvider.class }
-)
-@Designate( ocd = EmbeddedSolrServerConfigurationProvider.Configuration.class )
-@Deprecated(forRemoval=true, since="1.74.0")
-public class EmbeddedSolrServerConfigurationProvider implements SolrServerConfigurationProvider<EmbeddedSolrServerProvider> {
-
- @ObjectClassDefinition(
- id = "org.apache.jackrabbit.oak.plugins.index.solr.osgi.EmbeddedSolrServerConfigurationProvider",
- name = "Apache Jackrabbit Oak Solr embedded server configuration"
- )
- @interface Configuration {
- @AttributeDefinition(
- name = "Solr home directory"
- )
- String solr_home_path() default SolrServerConfigurationDefaults.SOLR_HOME_PATH;
-
- @AttributeDefinition(
- name = "Solr Core name"
- )
- String solr_core_name() default SolrServerConfigurationDefaults.CORE_NAME;
-
- String name() default "embedded";
- }
-
- private String solrHome;
- private String solrCoreName;
-
- private SolrServerConfiguration<EmbeddedSolrServerProvider> solrServerConfiguration;
-
-
- @Activate
- protected void activate(Configuration configuration) throws Exception {
- solrHome = configuration.solr_home_path();
- File file = new File(solrHome);
- if (!file.exists()) {
- assert file.createNewFile();
- }
- solrCoreName = configuration.solr_core_name();
-
- solrServerConfiguration = new EmbeddedSolrServerConfiguration(solrHome, solrCoreName);
- }
-
- @Deactivate
- protected void deactivate() throws Exception {
- solrHome = null;
- solrCoreName = null;
- }
-
- @NotNull
- @Override
- public SolrServerConfiguration<EmbeddedSolrServerProvider> getSolrServerConfiguration() {
- return solrServerConfiguration;
- }
-}
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/FilterQueryParserTest.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/FilterQueryParserTest.java
deleted file mode 100644
index f3bd6e6eca..0000000000
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/FilterQueryParserTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.query;
-
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.DefaultSolrConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration;
-import org.apache.jackrabbit.oak.spi.query.Filter;
-import org.apache.jackrabbit.oak.spi.query.QueryIndex;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.junit.Test;
-
-import java.util.Arrays;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-/**
- * Testcase for {@link FilterQueryParser}
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class FilterQueryParserTest {
-
- @Test
- public void testMatchAllConversionWithNoConstraints() throws Exception {
- Filter filter = mock(Filter.class);
- OakSolrConfiguration configuration = mock(OakSolrConfiguration.class);
- QueryIndex.IndexPlan plan = mock(QueryIndex.IndexPlan.class);
- SolrQuery solrQuery = FilterQueryParser.getQuery(filter, plan, configuration);
- assertNotNull(solrQuery);
- assertEquals("*:*", solrQuery.getQuery());
- }
-
- @Test
- public void testAllChildrenQueryParsing() throws Exception {
- String query = "select [jcr:path], [jcr:score], * from [nt:hierarchy] as a where isdescendantnode(a, '/')";
- Filter filter = mock(Filter.class);
- OakSolrConfiguration configuration = new DefaultSolrConfiguration(){
- @Override
- public boolean useForPathRestrictions() {
- return true;
- }
- };
- when(filter.getQueryStatement()).thenReturn(query);
- Filter.PathRestriction pathRestriction = Filter.PathRestriction.ALL_CHILDREN;
- when(filter.getPathRestriction()).thenReturn(pathRestriction);
- when(filter.getPath()).thenReturn("/");
- QueryIndex.IndexPlan plan = mock(QueryIndex.IndexPlan.class);
- SolrQuery solrQuery = FilterQueryParser.getQuery(filter, plan, configuration);
- assertNotNull(solrQuery);
- String[] filterQueries = solrQuery.getFilterQueries();
- assertTrue(Arrays.asList(filterQueries).contains(configuration.getFieldForPathRestriction(pathRestriction) + ":\\/"));
- assertEquals("*:*", solrQuery.get("q"));
- }
-
- @Test
- public void testCollapseJcrContentNodes() throws Exception {
- String query = "select [jcr:path], [jcr:score], * from [nt:hierarchy] as a where isdescendantnode(a, '/')";
- Filter filter = mock(Filter.class);
- OakSolrConfiguration configuration = new DefaultSolrConfiguration(){
- @Override
- public boolean collapseJcrContentNodes() {
- return true;
- }
- };
- when(filter.getQueryStatement()).thenReturn(query);
- QueryIndex.IndexPlan plan = mock(QueryIndex.IndexPlan.class);
- SolrQuery solrQuery = FilterQueryParser.getQuery(filter, plan, configuration);
- assertNotNull(solrQuery);
- String[] filterQueries = solrQuery.getFilterQueries();
- assertTrue(Arrays.asList(filterQueries).contains("{!collapse field=" + configuration.getCollapsedPathField()
- + " min=" + configuration.getPathDepthField() + " hint=top_fc nullPolicy=expand}"));
- assertEquals("*:*", solrQuery.get("q"));
- }
-
-}
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexIT.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexIT.java
deleted file mode 100644
index cbe808e3ef..0000000000
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexIT.java
+++ /dev/null
@@ -1,701 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.query;
-
-import javax.jcr.query.Query;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.jackrabbit.JcrConstants;
-import org.apache.jackrabbit.oak.Oak;
-import org.apache.jackrabbit.oak.api.ContentRepository;
-import org.apache.jackrabbit.oak.api.Tree;
-import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.plugins.index.aggregate.SimpleNodeAggregator;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.DefaultSolrConfigurationProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.index.SolrIndexEditorProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.server.DefaultSolrServerProvider;
-import org.apache.jackrabbit.oak.InitialContent;
-import org.apache.jackrabbit.oak.query.AbstractQueryTest;
-import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
-
-import static java.util.Arrays.asList;
-import static org.apache.jackrabbit.oak.api.Type.STRINGS;
-import static org.junit.Assert.*;
-
-/**
- * General query extensive testcase for {@link SolrQueryIndex}
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class SolrIndexIT extends AbstractQueryTest {
-
- @Rule
- public TestName name = new TestName();
-
- @Override
- protected void createTestIndexNode() throws Exception {
- Tree index = root.getTree("/");
- Tree solrIndexNode = createTestIndexNode(index, SolrQueryIndex.TYPE);
- solrIndexNode.setProperty("pathRestrictions", true);
- solrIndexNode.setProperty("propertyRestrictions", true);
- solrIndexNode.setProperty("primaryTypes", true);
- solrIndexNode.setProperty("commitPolicy", "hard");
- Tree server = solrIndexNode.addChild("server");
- server.setProperty("solrServerType", "embedded");
- server.setProperty("solrHomePath", "target/" + name.getMethodName());
-
- root.commit();
- }
-
- @Override
- protected ContentRepository createRepository() {
- try {
- DefaultSolrServerProvider solrServerProvider = new DefaultSolrServerProvider();
- DefaultSolrConfigurationProvider oakSolrConfigurationProvider = new DefaultSolrConfigurationProvider();
- return new Oak().with(new InitialContent())
- .with(new OpenSecurityProvider())
- .with(new SolrQueryIndexProvider(solrServerProvider, oakSolrConfigurationProvider, new SimpleNodeAggregator()))
- .with(new SolrIndexEditorProvider(solrServerProvider, oakSolrConfigurationProvider))
- .createContentRepository();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- @Test
- public void sql1() throws Exception {
- test("sql1.txt");
- }
-
- @Test
- public void sql2() throws Exception {
- test("sql2.txt");
- }
-
- @Test
- public void sql2FullText() throws Exception {
- test("sql2-fulltext.txt");
- }
-
- @Test
- @Ignore("OAK-420")
- public void sql2Measure() throws Exception {
- test("sql2_measure.txt");
- }
-
- @Test
- public void descendantTest() throws Exception {
- Tree test = root.getTree("/").addChild("test");
- test.addChild("a").addChild("c");
- test.addChild("b").addChild("d");
- root.commit();
-
- Iterator<String> result = executeQuery(
- "select [jcr:path] from [nt:base] where isdescendantnode('/test')",
- "JCR-SQL2").iterator();
- assertTrue(result.hasNext());
- assertEquals("/test/a", result.next());
- assertTrue(result.hasNext());
- assertEquals("/test/a/c", result.next());
- assertTrue(result.hasNext());
- assertEquals("/test/b", result.next());
- assertTrue(result.hasNext());
- assertEquals("/test/b/d", result.next());
- assertFalse(result.hasNext());
- }
-
- @Test
- public void descendantTest2() throws Exception {
- Tree test = root.getTree("/").addChild("test");
- test.addChild("a").addChild("c").setProperty("name", asList("Hello", "World"), STRINGS);
- test.addChild("b").setProperty("name", "Hello");
- root.commit();
-
- Iterator<String> result = executeQuery(
- "select [jcr:path] from [nt:base] where isdescendantnode('/test') and name='World'",
- "JCR-SQL2").iterator();
- assertTrue(result.hasNext());
- assertEquals("/test/a/c", result.next());
- assertFalse(result.hasNext());
- }
-
- @Test
- public void ischildnodeTest() throws Exception {
- Tree tree = root.getTree("/");
- Tree parents = tree.addChild("parents");
- parents.addChild("p0").setProperty("id", "0");
- parents.addChild("p1").setProperty("id", "1");
- parents.addChild("p2").setProperty("id", "2");
- Tree children = tree.addChild("children");
- children.addChild("c1").setProperty("p", "1");
- children.addChild("c2").setProperty("p", "2");
- children.addChild("c3").setProperty("p", "3");
- children.addChild("c4").setProperty("p", "4");
- root.commit();
-
- Iterator<String> result = executeQuery(
- "select p.[jcr:path], p2.[jcr:path] from [nt:base] as p inner join [nt:base] as p2 on ischildnode(p2, p) where p.[jcr:path] = '/'",
- "JCR-SQL2").iterator();
- assertTrue(result.hasNext());
- assertEquals("/, /children", result.next());
- assertTrue(result.hasNext());
- assertEquals("/, /jcr:system", result.next());
- assertTrue(result.hasNext());
- assertEquals("/, /oak:index", result.next());
- assertTrue(result.hasNext());
- assertEquals("/, /parents", result.next());
- assertFalse(result.hasNext());
-
- }
-
- @Test
- public void ischildnodeTest2() throws Exception {
- Tree tree = root.getTree("/");
- Tree test = tree.addChild("test");
- test.addChild("jcr:resource").addChild("x");
- test.addChild("resource");
- root.commit();
-
- Iterator<String> strings = executeQuery("select [jcr:path] from [nt:base] as b where ischildnode(b, '/test')", "JCR-SQL2").iterator();
- assertTrue(strings.hasNext());
- assertEquals("/test/jcr:resource", strings.next());
- assertTrue(strings.hasNext());
- assertEquals("/test/resource", strings.next());
- assertFalse(strings.hasNext());
- }
-
- @Test
- public void testNativeSolrQuery() throws Exception {
- String nativeQueryString = "select [jcr:path] from [nt:base] where native('solr', 'name:(Hello OR World)')";
-
- Tree tree = root.getTree("/");
- Tree test = tree.addChild("test");
- test.addChild("a").setProperty("name", "Hello");
- test.addChild("b").setProperty("name", "World");
- test.addChild("c");
- root.commit();
-
- Iterator<String> strings = executeQuery(nativeQueryString, "JCR-SQL2").iterator();
- assertTrue(strings.hasNext());
- assertEquals("/test/a", strings.next());
- assertTrue(strings.hasNext());
- assertEquals("/test/b", strings.next());
- assertFalse(strings.hasNext());
- }
-
- @Test
- public void testNativeSolrFunctionQuery() throws Exception {
- String nativeQueryString = "select [jcr:path] from [nt:base] where native('solr', 'path_child:\\/test _val_:\"recip(rord(name),1,2,3)\"')";
-
- Tree tree = root.getTree("/");
- Tree test = tree.addChild("test");
- test.addChild("a").setProperty("name", "Hello");
- test.addChild("b").setProperty("name", "World");
- tree.addChild("c");
- root.commit();
-
- Iterator<String> strings = executeQuery(nativeQueryString, "JCR-SQL2").iterator();
- assertTrue(strings.hasNext());
- assertEquals("/test/a", strings.next());
- assertTrue(strings.hasNext());
- assertEquals("/test/b", strings.next());
- assertFalse(strings.hasNext());
- }
-
- @Test
- public void testNativeSolrLocalParams() throws Exception {
- String nativeQueryString = "select [jcr:path] from [nt:base] where native('solr', '_query_:\"{!dismax qf=catch_all q.op=OR}hello world\"')";
-
- Tree tree = root.getTree("/");
- Tree test = tree.addChild("test");
- test.addChild("a").setProperty("name", "Hello");
- test.addChild("b").setProperty("name", "World");
- test.addChild("c");
- root.commit();
-
- Iterator<String> strings = executeQuery(nativeQueryString, "JCR-SQL2").iterator();
- assertTrue(strings.hasNext());
- assertEquals("/test/a", strings.next());
- assertTrue(strings.hasNext());
- assertEquals("/test/b", strings.next());
- assertFalse(strings.hasNext());
- }
-
- @Test
- public void testNativeMLTQuery() throws Exception {
- String nativeQueryString = "select [jcr:path] from [nt:base] where native('solr', 'mlt?q=text:welt&mlt.fl=text&mlt.mindf=1&mlt.mintf=1')";
-
- Tree tree = root.getTree("/");
- Tree test = tree.addChild("test");
- test.addChild("a").setProperty("text", "Hello World today weather is nice");
- test.addChild("b").setProperty("text", "Cheers World today weather is quite nice");
- test.addChild("c").setProperty("text", "Halo Welt today sky is cloudy");
- root.commit();
-
- Iterator<String> strings = executeQuery(nativeQueryString, "JCR-SQL2").iterator();
- assertTrue(strings.hasNext());
- assertEquals("/test/a", strings.next());
- assertTrue(strings.hasNext());
- assertEquals("/test/b", strings.next());
- assertFalse(strings.hasNext());
- }
-
- @Test
- public void testNativeMLTQueryWithStream() throws Exception {
- String nativeQueryString = "select [jcr:path] from [nt:base] where native('solr', 'mlt?stream.body=sky is cloudy&mlt.fl=text&mlt.mindf=0&mlt.mintf=0')";
-
- Tree tree = root.getTree("/");
- Tree test = tree.addChild("test");
- test.addChild("a").setProperty("text", "Hello World, today weather is nice");
- test.addChild("b").setProperty("text", "Cheers World, today weather is quite nice");
- test.addChild("c").setProperty("text", "Halo Welt, today sky is cloudy");
- root.commit();
-
- Iterator<String> strings = executeQuery(nativeQueryString, "JCR-SQL2").iterator();
- assertTrue(strings.hasNext());
- assertEquals("/test/a", strings.next());
- assertTrue(strings.hasNext());
- assertEquals("/test/b", strings.next());
- assertFalse(strings.hasNext());
- }
-
- @Test
- public void testRepSimilarXPathQuery() throws Exception {
- String query = "//element(*, nt:base)[rep:similar(., '/test/a')]";
- Tree test = root.getTree("/").addChild("test");
- test.addChild("a").setProperty("text", "the quick brown fox jumped over the lazy white dog");
- test.addChild("b").setProperty("text", "I am a dog");
- test.addChild("c").setProperty("text", "dogs don't hurt");
- test.addChild("d").setProperty("text", "white men can't jump");
- test.addChild("e").setProperty("text", "the fox is brown");
- test.addChild("f").setProperty("text", "a quickest dog jumped over the quick white dog");
- test.addChild("g").setProperty("text", "hello world");
- test.addChild("h").setProperty("text", "over the lazy top");
- root.commit();
- Iterator<String> result = executeQuery(query, "xpath").iterator();
- String list = "";
- while (result.hasNext()) {
- String p = result.next();
- if (p.startsWith("/oak:index")) {
- // OAK-3728
- // /oak:index nodes can match, because they have an info
- // we ignore those
- continue;
- }
- list += p + " ";
- }
- assertEquals(
- "/test/b " +
- "/test/d " +
- "/test/e " +
- "/test/f " +
- "/test/h ", list);
- }
-
- @Test
- public void nativeSolr() throws Exception {
- test("native_solr.txt");
- }
-
- @Test
- public void testTokenizeCN() throws Exception {
- Tree t = root.getTree("/").addChild("containsCN");
- Tree one = t.addChild("one");
- one.setProperty("t", "美女衬衫");
- root.commit();
- assertQuery("//*[jcr:contains(., '美女')]", "xpath", List.of(one.getPath()));
- }
-
- @Test
- @Ignore("OAK-9261")
- public void testCompositeRepExcerpt() throws Exception {
- String sqlQuery = "select [jcr:path], [jcr:score], [rep:excerpt] from [nt:base] as a " +
- "where (contains([jcr:content/*], 'square') or contains([jcr:content/jcr:title], 'square')" +
- " or contains([jcr:content/jcr:description], 'square')) and isdescendantnode(a, '/test') " +
- "order by [jcr:score] desc";
- Tree tree = root.getTree("/");
- Tree test = tree.addChild("test");
- Tree child = test.addChild("child");
- Tree a = child.addChild("a");
- a.setProperty("jcr:title", "Hello World, today square is nice");
- Tree b = child.addChild("b");
- b.setProperty("jcr:description", "Cheers World, today weather is squary nice");
- Tree c = child.addChild("c");
- c.setProperty("jcr:title", "Halo Welt, today sky is square");
- root.commit();
-
- Iterator<String> strings = executeQuery(sqlQuery, "JCR-SQL2").iterator();
- assertTrue(strings.hasNext());
- assertTrue(strings.next().startsWith("/test/child,"));
- assertFalse(strings.hasNext());
- }
-
- @Test
- public void contains() throws Exception {
- String h = "Hello" + System.currentTimeMillis();
- String w = "World" + System.currentTimeMillis();
-
- Tree test = root.getTree("/").addChild("test");
- test.addChild("a").setProperty("name", asList(h, w), STRINGS);
- test.addChild("b").setProperty("name", h);
- root.commit();
-
- // query 'hello'
- StringBuffer stmt = new StringBuffer();
- stmt.append("/jcr:root//*[jcr:contains(., '").append(h);
- stmt.append("')]");
- assertQuery(stmt.toString(), "xpath",
- List.of("/test/a", "/test/b"));
-
- // query 'world'
- stmt = new StringBuffer();
- stmt.append("/jcr:root//*[jcr:contains(., '").append(w);
- stmt.append("')]");
- assertQuery(stmt.toString(), "xpath", List.of("/test/a"));
-
- }
-
- @Test
- @Ignore("depends on chosen text_general tokenizer")
- public void containsDash() throws Exception {
- Tree test = root.getTree("/").addChild("test");
- test.addChild("a").setProperty("name", "hello-wor");
- test.addChild("b").setProperty("name", "hello-world");
- test.addChild("c").setProperty("name", "hello");
- root.commit();
-
- assertQuery("/jcr:root//*[jcr:contains(., 'hello-wor*')]", "xpath",
- List.of("/test/a", "/test/b"));
- assertQuery("/jcr:root//*[jcr:contains(., '*hello-wor*')]", "xpath",
- List.of("/test/a", "/test/b"));
-
- }
-
- @Test
- public void multiPhraseQuery() throws Exception {
- Tree test = root.getTree("/").addChild("test");
- test.addChild("a").setProperty("dc:format", "type:application/pdf");
- root.commit();
-
- assertQuery(
- "/jcr:root//*[jcr:contains(@dc:format, 'type:appli*')]",
- "xpath", List.of("/test/a"));
-
- }
-
- @Test
- public void testFulltextOperators() throws Exception {
- Tree test = root.getTree("/").addChild("test");
- test.addChild("a").setProperty("text", "the lazy fox jumped over the brown dog");
- test.addChild("b").setProperty("text", "the lazy bones raised to eat a dog");
- root.commit();
-
- assertQuery(
- "/jcr:root//*[jcr:contains(., 'lazy AND brown')]",
- "xpath", List.of("/test/a"));
-
- assertQuery(
- "/jcr:root//*[jcr:contains(., 'lazy OR eat')]",
- "xpath", List.of("/test/a", "/test/b"));
-
- assertQuery(
- "/jcr:root//*[jcr:contains(., 'lazy AND bones')]",
- "xpath", List.of("/test/b"));
-
- assertQuery(
- "/jcr:root//*[jcr:contains(., 'lazy OR dog')]",
- "xpath", List.of("/test/a", "/test/b"));
- }
-
- @Test
- public void containsPath() throws Exception {
-
- Tree test = root.getTree("/").addChild("test");
- test.addChild("a").setProperty("name", "/parent/child/node");
- root.commit();
-
- assertQuery("//*[jcr:contains(., '/parent/child')]", "xpath", List.of("/test/a"));
-
- }
-
- @Test
- public void containsPathNum() throws Exception {
-
- Tree test = root.getTree("/").addChild("test");
- Tree a = test.addChild("a");
- a.setProperty("name", "/segment1/segment2/segment3");
- root.commit();
-
- assertQuery("//*[jcr:contains(., '/segment1/segment2')]", "xpath", List.of("/test/a"));
-
- }
-
- /**
- * OAK-1208 property existence constraints break queries
- */
- @Test
- public void testOAK1208() throws Exception {
- Tree t = root.getTree("/").addChild("containsWithMultipleOr");
- Tree one = t.addChild("one");
- one.setProperty("p", "dam/smartcollection");
- one.setProperty("t", "media");
-
- Tree two = t.addChild("two");
- two.setProperty("p", "dam/collection");
- two.setProperty("t", "media");
-
- Tree three = t.addChild("three");
- three.setProperty("p", "dam/hits");
- three.setProperty("t", "media");
-
- root.commit();
-
- assertQuery("//*[jcr:contains(., 'media') and (@p = 'dam/smartcollection' or @p = 'dam/collection') ]", "xpath",
- List.of(one.getPath(), two.getPath()));
- }
-
- @Test
- public void testSortingOnPath() throws Exception {
- Tree test = root.getTree("/").addChild("test");
- test.addChild("a").addChild("c");
- test.addChild("b").addChild("d");
- root.commit();
-
- Iterator<String> result = executeQuery(
- "select [jcr:path] from [nt:base] where isdescendantnode('/test') order by [jcr:path] asc",
- "JCR-SQL2").iterator();
- assertTrue(result.hasNext());
- assertEquals("/test/a", result.next());
- assertTrue(result.hasNext());
- assertEquals("/test/a/c", result.next());
- assertTrue(result.hasNext());
- assertEquals("/test/b", result.next());
- assertTrue(result.hasNext());
- assertEquals("/test/b/d", result.next());
- assertFalse(result.hasNext());
- }
-
- @Test
- public void testSortingOnProperty() throws Exception {
- Tree test = root.getTree("/").addChild("test");
- Tree a = test.addChild("a");
- a.setProperty("foo", "bar");
- a.addChild("c").setProperty("foo", "car");
- Tree b = test.addChild("b");
- b.setProperty("foo", "tar");
- b.addChild("d").setProperty("foo", "jar");
- root.commit();
-
- Iterator<String> result = executeQuery(
- "select [jcr:path] from [nt:base] where isdescendantnode('/test') order by [foo] asc",
- "JCR-SQL2").iterator();
- assertTrue(result.hasNext());
- assertEquals("/test/a", result.next());
- assertTrue(result.hasNext());
- assertEquals("/test/a/c", result.next());
- assertTrue(result.hasNext());
- assertEquals("/test/b/d", result.next());
- assertTrue(result.hasNext());
- assertEquals("/test/b", result.next());
- assertFalse(result.hasNext());
- }
-
- @Test
- @Ignore("OAK-9261")
- public void testOrderByJcrScore() throws Exception {
- Tree index = root.getTree("/oak:index/" + TEST_INDEX_NAME);
- assertTrue(index.exists());
-
- index.setProperty("rows", 10000);
- index.setProperty("reindex", true);
- root.commit();
-
- Tree content = root.getTree("/").addChild("content");
- Tree a = content.addChild("a");
- a.setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
- a.setProperty("type", "doc doc doc");
- root.commit();
-
- String statement = "select [jcr:path], [jcr:score], [rep:excerpt] " +
- "from [nt:unstructured] as a " +
- "where contains(*, 'doc') " +
- "and isdescendantnode(a, '/content') " +
- "order by [jcr:score] desc";
-
- Iterator<String> results = executeQuery(statement, Query.JCR_SQL2, true).iterator();
- assertTrue(results.hasNext());
- assertEquals("/content/a", results.next());
- assertFalse(results.hasNext());
- }
-
- @Test
- public void testOrderByMVProperty() throws Exception {
- Tree index = root.getTree("/oak:index/" + TEST_INDEX_NAME);
- assertTrue(index.exists());
-
- index.setProperty("rows", 10000);
- index.setProperty("reindex", true);
- root.commit();
-
- Tree content = root.getTree("/").addChild("content");
- Tree a = content.addChild("a");
- a.setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
- a.setProperty("type", Arrays.asList("a", "z"), Type.STRINGS);
- a.setProperty("text", "a doc");
- Tree aContent = a.addChild("jcr:content");
- aContent.setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
- aContent.setProperty("type", Collections.singletonList("3"), Type.STRINGS);
- Tree b = content.addChild("b");
- b.setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
- b.setProperty("type", Arrays.asList("b", "y"), Type.STRINGS);
- b.setProperty("text", "b doc");
- Tree bContent = b.addChild("jcr:content");
- bContent.setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
- bContent.setProperty("type", Collections.singletonList("1"), Type.STRINGS);
- root.commit();
- Tree c = content.addChild("c");
- c.setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
- c.setProperty("type", Arrays.asList("c", "x"), Type.STRINGS);
- c.setProperty("text", "c doc");
- Tree cContent = c.addChild("jcr:content");
- cContent.setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
- cContent.setProperty("type", Collections.singletonList("2"), Type.STRINGS);
- root.commit();
-
- String statement = "select [jcr:path], [jcr:score] " +
- "from [nt:unstructured] as a " +
- "where contains(*, 'doc') " +
- "and isdescendantnode(a, '/content') " +
- "order by [type] desc";
-
- Iterator<String> results = executeQuery(statement, Query.JCR_SQL2, true).iterator();
- assertTrue(results.hasNext());
- assertEquals("/content/c", results.next());
- assertTrue(results.hasNext());
- assertEquals("/content/b", results.next());
- assertTrue(results.hasNext());
- assertEquals("/content/a", results.next());
- assertFalse(results.hasNext());
-
- statement = "select [jcr:path], [jcr:score] " +
- "from [nt:unstructured] as a " +
- "where contains(*, 'doc') " +
- "and isdescendantnode(a, '/content') " +
- "order by [type] asc";
-
- results = executeQuery(statement, Query.JCR_SQL2, true).iterator();
- assertTrue(results.hasNext());
- assertEquals("/content/a", results.next());
- assertTrue(results.hasNext());
- assertEquals("/content/b", results.next());
- assertTrue(results.hasNext());
- assertEquals("/content/c", results.next());
- assertFalse(results.hasNext());
- }
-
- @Test
- public void testCollapsedJcrContentNodeDescandants() throws Exception {
-
- Tree index = root.getTree("/oak:index/" + TEST_INDEX_NAME);
- assertTrue(index.exists());
-
- index.setProperty("collapseJcrContentNodes", true);
- index.setProperty("reindex", true);
- root.commit();
-
- Tree test = root.getTree("/").addChild("test");
- Tree content = test.addChild("content");
- Tree content1 = content.addChild("sample1").addChild("jcr:content");
- content1.setProperty("foo", "bar");
- content1.addChild("text").setProperty("text", "bar");
- Tree content2 = content.addChild("sample2").addChild("jcr:content");
- content2.setProperty("foo", "bar");
- content2.addChild("text").setProperty("text", "bar");
- root.commit();
-
- String xpath = "/jcr:root/test/content//element(*, nt:base)[jcr:contains(., 'bar')]";
-
- Iterator<String> result = executeQuery(xpath, XPATH).iterator();
- assertTrue(result.hasNext());
- assertEquals("/test/content/sample1", result.next());
- assertTrue(result.hasNext());
- assertEquals("/test/content/sample2", result.next());
- assertFalse(result.hasNext());
- }
-
- @Test
- public void testJcrContentNodeChild() throws Exception {
-
- Tree index = root.getTree("/oak:index/" + TEST_INDEX_NAME);
- assertTrue(index.exists());
-
- Tree test = root.getTree("/").addChild("test");
- Tree content = test.addChild("content");
- Tree content1 = content.addChild("sample1").addChild("jcr:content");
- content1.setProperty("text", "bar");
- Tree content2 = content.addChild("sample2").addChild("jcr:content");
- content2.setProperty("foo", "bar");
- root.commit();
-
- String xpath = "/jcr:root/test/content//element(*, nt:base)[jcr:contains(., 'bar')]";
-
- Iterator<String> result = executeQuery(xpath, XPATH).iterator();
- assertTrue(result.hasNext());
- assertEquals("/test/content/sample1", result.next());
- assertTrue(result.hasNext());
- assertEquals("/test/content/sample2", result.next());
- assertFalse(result.hasNext());
- }
-
- @Test
- public void testNotNullAndNative() throws Exception {
- Tree index = root.getTree("/oak:index/" + TEST_INDEX_NAME);
- assertTrue(index.exists());
-
- index.setProperty("rows", 10000);
- index.setProperty("reindex", true);
- root.commit();
-
- Tree content = root.getTree("/").addChild("content");
- Tree a = content.addChild("a");
- a.setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
- a.setProperty("foo", "doc doc doc");
- a.setProperty("loc", "2");
- Tree b = content.addChild("b");
- b.setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
- b.setProperty("foo", "bye bye bye");
- b.setProperty("loc", "1");
- root.commit();
-
- String query = "select [jcr:path] from [nt:base] where native('solr','select?q=loc:*') AND foo IS NOT NULL";
-
- Iterator<String> results = executeQuery(query, Query.JCR_SQL2, true).iterator();
- assertTrue(results.hasNext());
- assertEquals("/content/a", results.next());
- assertTrue(results.hasNext());
- assertEquals("/content/b", results.next());
- assertFalse(results.hasNext());
- }
-}
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexLookupTest.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexLookupTest.java
deleted file mode 100644
index 764e57c116..0000000000
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexLookupTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.jackrabbit.oak.plugins.index.solr.query;
-
-import java.util.Set;
-import org.apache.jackrabbit.oak.query.index.FilterImpl;
-import org.apache.jackrabbit.oak.spi.query.Filter;
-import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.junit.Test;
-
-import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
-import static org.apache.jackrabbit.oak.api.Type.NAME;
-import static org.apache.jackrabbit.oak.api.Type.STRINGS;
-import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.*;
-import static org.apache.jackrabbit.oak.plugins.memory.PropertyStates.createProperty;
-import static org.apache.jackrabbit.oak.InitialContentHelper.INITIAL_CONTENT;
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests for {@link SolrIndexLookup}
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class SolrIndexLookupTest {
- private NodeState root = INITIAL_CONTENT;
-
- private NodeBuilder builder = root.builder();
-
- @Test
- public void collectPathOnRootNode() throws Exception {
- NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME);
- newSolrIndexDefinition(index, "l1", Set.of("foo"));
- newSolrIndexDefinition(index, "l2", Set.of("foo"));
-
- SolrIndexLookup lookup = new SolrIndexLookup(builder.getNodeState());
- FilterImpl f = FilterImpl.newTestInstance();
- f.restrictPath("/", Filter.PathRestriction.EXACT);
- assertEquals(Set.of("/oak:index/l1", "/oak:index/l2"),
- lookup.collectIndexNodePaths(f));
- }
-
- @Test
- public void collectPathOnSubNode() throws Exception {
- NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME);
- newSolrIndexDefinition(index, "l1", Set.of("foo"));
-
- index = builder.child("a").child(INDEX_DEFINITIONS_NAME);
- newSolrIndexDefinition(index, "l2", Set.of("foo"));
-
- index = builder.child("a").child("b").child(INDEX_DEFINITIONS_NAME);
- newSolrIndexDefinition(index, "l3", Set.of("foo"));
-
- SolrIndexLookup lookup = new SolrIndexLookup(builder.getNodeState());
- FilterImpl f = FilterImpl.newTestInstance();
- f.restrictPath("/a", Filter.PathRestriction.EXACT);
- assertEquals(Set.of("/oak:index/l1", "/a/oak:index/l2"),
- lookup.collectIndexNodePaths(f));
-
- f.restrictPath("/a/b", Filter.PathRestriction.EXACT);
- assertEquals(Set.of("/oak:index/l1", "/a/oak:index/l2", "/a/b/oak:index/l3"),
- lookup.collectIndexNodePaths(f));
- }
-
- private static NodeBuilder newSolrIndexDefinition(
- @NotNull NodeBuilder index, @NotNull String name,
- @Nullable Set<String> properties) {
- if (index.hasChildNode(name)) {
- return index.child(name);
- }
- index = index.child(name);
- index.setProperty(JCR_PRIMARYTYPE, INDEX_DEFINITIONS_NODE_TYPE, NAME)
- .setProperty(TYPE_PROPERTY_NAME, "solr")
- .setProperty(ASYNC_PROPERTY_NAME, "async")
- .setProperty(REINDEX_PROPERTY_NAME, true);
- index.child("server").setProperty("solrServerType", "embedded");
- if (properties != null && !properties.isEmpty()) {
- index.setProperty(createProperty("usedProperties",
- properties, STRINGS));
- }
- return index;
- }
-}
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndexTest.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndexTest.java
deleted file mode 100644
index 76d4c5f5f8..0000000000
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndexTest.java
+++ /dev/null
@@ -1,469 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.query;
-
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.jackrabbit.oak.api.Result;
-import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.DefaultSolrConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider;
-import org.apache.jackrabbit.oak.plugins.memory.PropertyValues;
-import org.apache.jackrabbit.oak.InitialContentHelper;
-import org.apache.jackrabbit.oak.query.NodeStateNodeTypeInfoProvider;
-import org.apache.jackrabbit.oak.query.QueryEngineSettings;
-import org.apache.jackrabbit.oak.query.ast.NodeTypeInfo;
-import org.apache.jackrabbit.oak.query.ast.NodeTypeInfoProvider;
-import org.apache.jackrabbit.oak.query.ast.Operator;
-import org.apache.jackrabbit.oak.query.ast.SelectorImpl;
-import org.apache.jackrabbit.oak.query.index.FilterImpl;
-import org.apache.jackrabbit.oak.spi.query.Cursor;
-import org.apache.jackrabbit.oak.spi.query.Filter;
-import org.apache.jackrabbit.oak.spi.query.IndexRow;
-import org.apache.jackrabbit.oak.spi.query.QueryIndex;
-import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.solr.client.solrj.SolrClient;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrDocumentList;
-import org.apache.solr.common.params.SolrParams;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
-import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
-import static org.junit.Assert.*;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-/**
- * Tests for {@link SolrQueryIndex}
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class SolrQueryIndexTest {
-
- private NodeState nodeState;
-
- @Before
- public void setUp() throws Exception {
- NodeState root = EMPTY_NODE;
- NodeBuilder builder = root.builder();
- builder.child("oak:index").child("solr")
- .setProperty(JCR_PRIMARYTYPE, "oak:QueryIndexDefinition")
- .setProperty("type", "solr")
- .child("server").setProperty("solrServerType", "embedded");
- nodeState = builder.getNodeState();
- }
-
- @Test
- public void testNoIndexPlanWithNoRestrictions() throws Exception {
-
- SelectorImpl selector = mock(SelectorImpl.class);
-
- SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
-
- FilterImpl filter = new FilterImpl(selector, "", new QueryEngineSettings());
- List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
- List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
- assertEquals(0, plans.size());
- }
-
-
- @Test
- public void testNoPlanWithPathRestrictions() throws Exception {
- SelectorImpl selector = newSelector(nodeState, "a");
-
- SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
-
- FilterImpl filter = new FilterImpl(selector, "select * from [nt:base] as a where isdescendantnode(a, '/test')", new QueryEngineSettings());
- filter.restrictPath("/test", Filter.PathRestriction.ALL_CHILDREN);
- List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
- List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
- assertEquals(0, plans.size());
- }
-
- @Test
- public void testNoPlanWithOnlyPathRestrictionsEnabled() throws Exception {
- NodeBuilder builder = nodeState.builder();
- builder.child("oak:index").child("solr").setProperty("pathRestrictions", true);
- nodeState = builder.getNodeState();
-
- SelectorImpl selector = newSelector(nodeState, "a");
-
- SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
-
- FilterImpl filter = new FilterImpl(selector, "select * from [nt:base] as a where isdescendantnode(a, '/test')", new QueryEngineSettings());
- filter.restrictPath("/test", Filter.PathRestriction.ALL_CHILDREN);
- List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
- List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
- assertEquals(0, plans.size());
- }
-
- @Test
- public void testPlanWithPropertyAndPathRestrictionsEnabled() throws Exception {
- NodeBuilder builder = nodeState.builder();
- builder.child("oak:index").child("solr")
- .setProperty("pathRestrictions", true)
- .setProperty("propertyRestrictions", true);
- nodeState = builder.getNodeState();
-
- SelectorImpl selector = newSelector(nodeState, "a");
-
- SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
-
- FilterImpl filter = new FilterImpl(selector, "select * from [nt:base] as a where isdescendantnode(a, '/test')", new QueryEngineSettings());
- filter.restrictPath("/test", Filter.PathRestriction.ALL_CHILDREN);
- filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("bar"));
- List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
- List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
- assertEquals(1, plans.size());
- }
-
- @Test
- public void testNoPlanWithPropertyRestrictions() throws Exception {
- SelectorImpl selector = newSelector(nodeState, "a");
-
- SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
-
- FilterImpl filter = new FilterImpl(selector, "select * from [nt:base] as a where name = 'hello')", new QueryEngineSettings());
- filter.restrictProperty("name", Operator.EQUAL, PropertyValues.newString("hello"));
- List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
- List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
- assertEquals(0, plans.size());
- }
-
- @Test
- public void testPlanWithPropertyRestrictionsEnabled() throws Exception {
- NodeBuilder builder = nodeState.builder();
- builder.child("oak:index").child("solr")
- .setProperty("propertyRestrictions", true);
- nodeState = builder.getNodeState();
-
- SelectorImpl selector = newSelector(nodeState, "a");
-
- SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
-
- FilterImpl filter = new FilterImpl(selector, "select * from [nt:base] as a where name = 'hello')", new QueryEngineSettings());
- filter.restrictProperty("name", Operator.EQUAL, PropertyValues.newString("hello"));
- List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
- List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
- assertEquals(1, plans.size());
- }
-
- @Test
- public void testNoPlanWithPrimaryTypeRestrictions() throws Exception {
- SelectorImpl selector = newSelector(nodeState, "a");
-
- SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
-
- FilterImpl filter = new FilterImpl(selector, "select * from [nt:base] as a where jcr:primaryType = 'nt:unstructured')", new QueryEngineSettings());
- filter.restrictProperty("jcr:primaryType", Operator.EQUAL, PropertyValues.newString("nt:unstructured"));
- List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
- List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
- assertEquals(0, plans.size());
- }
-
- @Test
- public void testNoPlanWithOnlyPrimaryTypeRestrictionsEnabled() throws Exception {
- NodeBuilder builder = nodeState.builder();
- builder.child("oak:index").child("solr").setProperty("primaryTypes", true);
- nodeState = builder.getNodeState();
-
- SelectorImpl selector = newSelector(nodeState, "a");
-
- SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
-
- FilterImpl filter = new FilterImpl(selector, "select * from [nt:base] as a where jcr:primaryType = 'nt:unstructured')", new QueryEngineSettings());
- filter.restrictProperty("jcr:primaryType", Operator.EQUAL, PropertyValues.newString("nt:unstructured"));
- List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
- List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
- assertEquals(0, plans.size());
- }
-
- @Test
- public void testPlanWithPropertyAndPrimaryTypeRestrictionsEnabled() throws Exception {
- NodeBuilder builder = nodeState.builder();
- builder.child("oak:index").child("solr")
- .setProperty("propertyRestrictions", true)
- .setProperty("primaryTypes", true);
- nodeState = builder.getNodeState();
-
- SelectorImpl selector = newSelector(nodeState, "a");
-
- SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
-
- FilterImpl filter = new FilterImpl(selector, "select * from [nt:base] as a where jcr:primaryType = 'nt:unstructured')", new QueryEngineSettings());
- filter.restrictProperty("jcr:primaryType", Operator.EQUAL, PropertyValues.newString("nt:unstructured"));
- filter.restrictProperty("name", Operator.EQUAL, PropertyValues.newString("hello"));
- List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
- List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
- assertEquals(1, plans.size());
- }
-
- @Test
- public void testNoPlanWithPropertyRestrictionsEnabledButPropertyIgnored() throws Exception {
- NodeBuilder builder = nodeState.builder();
- builder.child("oak:index").child("solr")
- .setProperty("ignoredProperties", Collections.singleton("name"), Type.STRINGS)
- .setProperty("propertyRestrictions", true);
- nodeState = builder.getNodeState();
-
- SelectorImpl selector = newSelector(nodeState, "a");
-
- SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
-
- FilterImpl filter = new FilterImpl(selector, "select * from [nt:base] as a where name = 'hello')", new QueryEngineSettings());
- filter.restrictProperty("name", Operator.EQUAL, PropertyValues.newString("hello"));
- List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
- List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
- assertEquals(0, plans.size()); // there's no plan matching the filter
- }
-
- @Test
- public void testNoPlanWithPropertyRestrictionsEnabledButNotUsedProperty() throws Exception {
- NodeBuilder builder = nodeState.builder();
- builder.child("oak:index").child("solr")
- .setProperty("usedProperties", Collections.singleton("foo"), Type.STRINGS)
- .setProperty("propertyRestrictions", true);
- nodeState = builder.getNodeState();
-
- SelectorImpl selector = newSelector(nodeState, "a");
-
- SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
-
- FilterImpl filter = new FilterImpl(selector, "select * from [nt:base] as a where name = 'hello')", new QueryEngineSettings());
- filter.restrictProperty("name", Operator.EQUAL, PropertyValues.newString("hello"));
- List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
- List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
- assertEquals(0, plans.size());
- }
-
- @Test
- public void testPlanWithPropertyRestrictionsEnabledAndUsedProperty() throws Exception {
- NodeBuilder builder = nodeState.builder();
- builder.child("oak:index").child("solr")
- .setProperty("usedProperties", Collections.singleton("name"), Type.STRINGS)
- .setProperty("propertyRestrictions", true);
- nodeState = builder.getNodeState();
-
- SelectorImpl selector = newSelector(nodeState, "a");
-
- SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
-
- FilterImpl filter = new FilterImpl(selector, "select * from [nt:base] as a where name = 'hello')", new QueryEngineSettings());
- filter.restrictProperty("name", Operator.EQUAL, PropertyValues.newString("hello"));
- List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
- List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
- assertEquals(1, plans.size());
- }
-
- @Test
- public void testNoPlanWithPropertyNotListedInUsedProperties() throws Exception {
- NodeBuilder builder = nodeState.builder();
- builder.child("oak:index").child("solr")
- .setProperty("usedProperties", Collections.singleton("name"), Type.STRINGS)
- .setProperty("propertyRestrictions", true);
- nodeState = builder.getNodeState();
-
- SelectorImpl selector = newSelector(nodeState, "a");
-
- SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
-
- FilterImpl filter = new FilterImpl(selector, "select * from [nt:base] as a where foo = 'bar')", new QueryEngineSettings());
- filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("bar"));
- List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
- List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
- assertEquals(0, plans.size());
- }
-
- @Test
- public void testUnion() throws Exception {
- SelectorImpl selector = mock(SelectorImpl.class);
-
- SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
-
- String sqlQuery = "select [jcr:path], [jcr:score], [rep:excerpt] from [nt:hierarchyNode] as a where" +
- " isdescendantnode(a, '/content') and contains([jcr:content/*], 'founded') union select [jcr:path]," +
- " [jcr:score], [rep:excerpt] from [nt:hierarchyNode] as a where isdescendantnode(a, '/content') and " +
- "contains([jcr:content/jcr:title], 'founded') union select [jcr:path], [jcr:score], [rep:excerpt]" +
- " from [nt:hierarchyNode] as a where isdescendantnode(a, '/content') and " +
- "contains([jcr:content/jcr:description], 'founded') order by [jcr:score] desc";
- FilterImpl filter = new FilterImpl(selector, sqlQuery, new QueryEngineSettings());
- List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
- List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
- assertEquals(0, plans.size());
- }
-
- @Test
- public void testSize() throws Exception {
- NodeState root = InitialContentHelper.INITIAL_CONTENT;
- SelectorImpl selector = newSelector(root, "a");
- String sqlQuery = "select [jcr:path], [jcr:score] from [nt:base] as a where" +
- " contains([jcr:content/*], 'founded')";
- SolrServerProvider solrServerProvider = mock(SolrServerProvider.class);
- OakSolrConfigurationProvider configurationProvider = mock(OakSolrConfigurationProvider.class);
- OakSolrConfiguration configuration = new DefaultSolrConfiguration() {
- @Override
- public boolean useForPropertyRestrictions() {
- return true;
- }
- };
- when(configurationProvider.getConfiguration()).thenReturn(configuration);
-
- SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, configurationProvider, solrServerProvider);
- FilterImpl filter = new FilterImpl(selector, sqlQuery, new QueryEngineSettings());
- List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, null, root);
- for (QueryIndex.IndexPlan p : plans) {
- Cursor cursor = solrQueryIndex.query(p, root);
- assertNotNull(cursor);
- long sizeExact = cursor.getSize(Result.SizePrecision.EXACT, 100000);
- long sizeApprox = cursor.getSize(Result.SizePrecision.APPROXIMATION, 100000);
- long sizeFastApprox = cursor.getSize(Result.SizePrecision.FAST_APPROXIMATION, 100000);
- assertTrue(Math.abs(sizeExact - sizeApprox) < 10);
- assertTrue(Math.abs(sizeExact - sizeFastApprox) > 10000);
- }
- }
-
- @Test
- public void testNoMoreThanThreeSolrRequests() throws Exception {
- NodeState root = InitialContentHelper.INITIAL_CONTENT;
- SelectorImpl selector = newSelector(root, "a");
- String sqlQuery = "select [jcr:path], [jcr:score] from [nt:base] as a where" +
- " contains([jcr:content/*], 'founded')";
- SolrClient solrServer = mock(SolrClient.class);
- SolrServerProvider solrServerProvider = mock(SolrServerProvider.class);
- when(solrServerProvider.getSearchingSolrServer()).thenReturn(solrServer);
- OakSolrConfigurationProvider configurationProvider = mock(OakSolrConfigurationProvider.class);
- OakSolrConfiguration configuration = new DefaultSolrConfiguration() {
- @Override
- public boolean useForPropertyRestrictions() {
- return true;
- }
-
- @Override
- public int getRows() {
- return 10;
- }
- };
- when(configurationProvider.getConfiguration()).thenReturn(configuration);
-
- SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, configurationProvider, solrServerProvider);
- FilterImpl filter = new FilterImpl(selector, sqlQuery, new QueryEngineSettings());
- CountingResponse response = new CountingResponse(0);
- when(solrServer.query(any(SolrParams.class))).thenReturn(response);
-
- List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, null, root);
- for (QueryIndex.IndexPlan p : plans) {
- Cursor cursor = solrQueryIndex.query(p, root);
- assertNotNull(cursor);
- while (cursor.hasNext()) {
- IndexRow row = cursor.next();
- assertNotNull(row);
- }
- assertEquals(3, response.getCounter());
- }
- }
-
- @Test
- public void testNoNegativeCost() throws Exception {
- NodeState root = InitialContentHelper.INITIAL_CONTENT;
- NodeBuilder builder = root.builder();
- builder.child("oak:index").child("solr")
- .setProperty("usedProperties", Collections.singleton("name"), Type.STRINGS)
- .setProperty("propertyRestrictions", true)
- .setProperty("type", "solr");
- nodeState = builder.getNodeState();
- SelectorImpl selector = newSelector(root, "a");
- String query = "select * from [nt:base] as a where native('solr','select?q=searchKeywords:\"foo\"^20 text:\"foo\"^1 " +
- "description:\"foo\"^8 something:\"foo\"^3 headline:\"foo\"^5 title:\"foo\"^10 &q.op=OR'";
- String sqlQuery = "select * from [nt:base] a where native('solr','" + query + "'";
- SolrClient solrServer = mock(SolrClient.class);
- SolrServerProvider solrServerProvider = mock(SolrServerProvider.class);
- when(solrServerProvider.getSearchingSolrServer()).thenReturn(solrServer);
- OakSolrConfigurationProvider configurationProvider = mock(OakSolrConfigurationProvider.class);
- OakSolrConfiguration configuration = new DefaultSolrConfiguration() {
- @Override
- public boolean useForPropertyRestrictions() {
- return true;
- }
-
- @Override
- public int getRows() {
- return 10;
- }
- };
- when(configurationProvider.getConfiguration()).thenReturn(configuration);
-
- SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, configurationProvider, solrServerProvider);
- FilterImpl filter = new FilterImpl(selector, sqlQuery, new QueryEngineSettings());
- filter.restrictProperty("native*solr", Operator.EQUAL, PropertyValues.newString(query));
- CountingResponse response = new CountingResponse(0);
- when(solrServer.query(any(SolrParams.class))).thenReturn(response);
-
- List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, null, nodeState);
- for (QueryIndex.IndexPlan p : plans) {
- double costPerEntry = p.getCostPerEntry();
- assertTrue(costPerEntry >= 0);
- double costPerExecution = p.getCostPerExecution();
- assertTrue(costPerExecution >= 0);
- long estimatedEntryCount = p.getEstimatedEntryCount();
- assertTrue(estimatedEntryCount >= 0);
-
- double c = p.getCostPerExecution() + estimatedEntryCount * p.getCostPerEntry();
- assertTrue(c >= 0);
- }
- }
-
- private static SelectorImpl newSelector(NodeState root, String name) {
- NodeTypeInfoProvider types = new NodeStateNodeTypeInfoProvider(root);
- NodeTypeInfo type = types.getNodeTypeInfo("nt:base");
- return new SelectorImpl(type, name);
- }
-
- private class CountingResponse extends QueryResponse {
-
- private int counter;
-
- public CountingResponse(int counter) {
- this.counter = counter;
- }
-
- @Override
- public SolrDocumentList getResults() {
- SolrDocumentList results = new SolrDocumentList();
- for (int i = 0; i < 1000; i++) {
- results.add(new SolrDocument());
- }
- results.setNumFound(1000);
- counter++;
- return results;
- }
-
- public int getCounter() {
- return counter;
- }
- }
-
-}
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SubtreeSolrIndexIT.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SubtreeSolrIndexIT.java
deleted file mode 100644
index de3b189dbe..0000000000
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SubtreeSolrIndexIT.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.query;
-
-import javax.jcr.query.Query;
-import java.util.Iterator;
-
-import org.apache.jackrabbit.JcrConstants;
-import org.apache.jackrabbit.oak.Oak;
-import org.apache.jackrabbit.oak.api.ContentRepository;
-import org.apache.jackrabbit.oak.api.Tree;
-import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.DefaultSolrConfigurationProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.index.SolrIndexEditorProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.server.DefaultSolrServerProvider;
-import org.apache.jackrabbit.oak.InitialContent;
-import org.apache.jackrabbit.oak.query.AbstractQueryTest;
-import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
-
-import static org.junit.Assert.*;
-
-/**
- * Integration test for indexing / search over subtrees with Solr index.
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class SubtreeSolrIndexIT extends AbstractQueryTest {
-
- public static final String SUBTREE = "subtree";
-
- @Rule
- public TestName name = new TestName();
-
- @Override
- protected void createTestIndexNode() throws Exception {
- Tree rootTree = root.getTree("/");
- Tree subtree = rootTree.addChild(SUBTREE);
- Tree solrIndexNode = createTestIndexNode(subtree, SolrQueryIndex.TYPE);
- solrIndexNode.setProperty("pathRestrictions", false);
- solrIndexNode.setProperty("propertyRestrictions", true);
- solrIndexNode.setProperty("primaryTypes", false);
- solrIndexNode.setProperty("commitPolicy", "hard");
- Tree server = solrIndexNode.addChild("server");
- server.setProperty("solrServerType", "embedded");
- server.setProperty("solrHomePath", "target/" + name.getMethodName());
-
- root.commit();
- }
-
- @Override
- protected ContentRepository createRepository() {
- try {
- DefaultSolrServerProvider solrServerProvider = new DefaultSolrServerProvider();
- DefaultSolrConfigurationProvider oakSolrConfigurationProvider = new DefaultSolrConfigurationProvider();
- return new Oak().with(new InitialContent())
- .with(new OpenSecurityProvider())
- .with(new SolrQueryIndexProvider(solrServerProvider, oakSolrConfigurationProvider))
- .with(new SolrIndexEditorProvider(solrServerProvider, oakSolrConfigurationProvider))
- .createContentRepository();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- @Test
- public void test() throws Exception {
-
- Tree content = root.getTree("/").getChild(SUBTREE);
- Tree a = content.addChild("a");
- a.setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
- a.setProperty("foo", "doc bye");
- a.setProperty("loc", "2");
- Tree b = content.addChild("b");
- b.setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
- b.setProperty("foo", "bye doc bye");
- b.setProperty("loc", "1");
- root.commit();
-
- String query = "select [jcr:path] from [nt:base] where contains(*,'doc') " +
- "AND isdescendantnode('/" + SUBTREE + "')";
-
- Iterator<String> results = executeQuery(query, Query.JCR_SQL2, true).iterator();
- assertTrue(results.hasNext());
- assertEquals("/" + SUBTREE + "/a", results.next());
- assertTrue(results.hasNext());
- assertEquals("/" + SUBTREE + "/b", results.next());
- assertFalse(results.hasNext());
- }
-}
diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/server/EmbeddedSolrServerProvider.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/server/EmbeddedSolrServerProvider.java
deleted file mode 100644
index 9765dde6c1..0000000000
--- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/server/EmbeddedSolrServerProvider.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.index.solr.server;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.FileSystems;
-import java.nio.file.Path;
-import java.util.Arrays;
-import org.apache.commons.io.FileUtils;
-import org.apache.jackrabbit.oak.commons.IOUtils;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationDefaults;
-import org.apache.solr.client.solrj.SolrClient;
-import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
-import org.apache.solr.client.solrj.embedded.JettySolrRunner;
-import org.apache.solr.client.solrj.impl.HttpSolrClient;
-import org.apache.solr.core.CoreContainer;
-import org.jetbrains.annotations.Nullable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Default implementation of {@link org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider} which uses an
- * {@link EmbeddedSolrServer} configured as per passed {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfiguration}.
- * <p>
- * @deprecated Solr support is deprecated and will be removed in a future version of Oak; see <a href=https://issues.apache.org/jira/browse/OAK-11314 target=_blank>Jira ticket OAK-11314</a> for more information.
- */
-@Deprecated(forRemoval=true, since="1.74.0")
-public class EmbeddedSolrServerProvider implements SolrServerProvider {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private final EmbeddedSolrServerConfiguration solrServerConfiguration;
-
- public EmbeddedSolrServerProvider(EmbeddedSolrServerConfiguration solrServerConfiguration) {
- this.solrServerConfiguration = solrServerConfiguration;
- }
-
- private SolrClient createSolrServer() throws Exception {
-
- log.info("creating new embedded solr server with config: {}", solrServerConfiguration);
-
- String solrHomePath = solrServerConfiguration.getSolrHomePath();
- String coreName = solrServerConfiguration.getCoreName();
- EmbeddedSolrServerConfiguration.HttpConfiguration httpConfiguration = solrServerConfiguration.getHttpConfiguration();
-
- if (solrHomePath != null && coreName != null) {
- checkSolrConfiguration(solrHomePath, coreName);
- if (httpConfiguration != null) {
- if (log.isInfoEnabled()) {
- log.info("starting embedded Solr server with http bindings");
- }
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(JettySolrRunner.class.getClassLoader());
-
- Integer httpPort = httpConfiguration.getHttpPort();
- String context = httpConfiguration.getContext();
- JettySolrRunner jettySolrRunner = null;
- try {
- jettySolrRunner = new JettySolrRunner(solrHomePath, context, httpPort);
- if (log.isInfoEnabled()) {
- log.info("Jetty runner instantiated");
- }
- jettySolrRunner.start();
- if (log.isInfoEnabled()) {
- log.info("Jetty runner started");
- }
- } catch (Exception t) {
- if (log.isErrorEnabled()) {
- log.error("an error has occurred while starting Solr Jetty", t);
- }
- } finally {
- if (jettySolrRunner != null && !jettySolrRunner.isRunning()) {
- try {
- jettySolrRunner.stop();
- if (log.isInfoEnabled()) {
- log.info("Jetty runner stopped");
- }
- } catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error("error while stopping the Jetty runner", e);
- }
- }
- }
- Thread.currentThread().setContextClassLoader(classLoader);
- }
- if (log.isInfoEnabled()) {
- log.info("starting HTTP Solr server");
- }
- return new HttpWithJettySolrServer(SolrServerConfigurationDefaults.LOCAL_BASE_URL + ':' + httpPort + context + '/' + coreName, jettySolrRunner);
- } else {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(CoreContainer.class.getClassLoader());
-
- CoreContainer coreContainer = null;
- try {
- Path path = FileSystems.getDefault().getPath(solrHomePath);
- coreContainer = CoreContainer.createAndLoad(path);
- if (!coreContainer.isLoaded(coreName)) {
- coreContainer.load();
- }
- } catch (Exception e) {
- log.error("cannot load core {}, shutting down embedded Solr..", coreName, e);
- try {
- coreContainer.shutdown();
- } catch (Exception se) {
- log.error("could not shutdown embedded Solr", se);
- }
- return null;
- } finally {
- Thread.currentThread().setContextClassLoader(classLoader);
- }
-
- EmbeddedSolrServer server = new EmbeddedSolrServer(coreContainer, coreName);
- if (server.ping().getStatus() == 0) {
- return server;
- } else {
- throw new IOException("the embedded Solr server is not alive");
- }
- }
- } else {
- throw new Exception("SolrServer configuration proprties not set");
- }
- }
-
- private void checkSolrConfiguration(String solrHomePath, String coreName) throws IOException {
- File solrHomePathFile = new File(solrHomePath);
-
- log.info("checking configuration at {}", solrHomePathFile.getAbsolutePath());
-
- // check if solrHomePath exists
- if (!solrHomePathFile.exists()) {
- if (!solrHomePathFile.mkdirs()) {
- throw new IOException("could not create solrHomePath directory");
- } else {
- // copy all the needed files to the just created directory
- copy("/solr/solr.xml", solrHomePath);
- copy("/solr/zoo.cfg", solrHomePath);
-
- }
- } else if (!solrHomePathFile.isDirectory()) {
- throw new IOException("a non directory file with the specified name already exists for the given solrHomePath '" + solrHomePath);
- }
-
- File solrCorePathFile = new File(solrHomePathFile, coreName);
- if (!solrCorePathFile.exists()) {
- if (!new File(solrCorePathFile, "conf").mkdirs()) {
- throw new IOException("could not create nested core directory in solrHomePath/solrCoreName/conf");
- }
- String solrCoreDir = solrCorePathFile.getAbsolutePath();
- File coreProperties = new File(new File(solrCoreDir), "core.properties");
- assert coreProperties.createNewFile();
- FileOutputStream out = new FileOutputStream(coreProperties);
- IOUtils.writeBytes(out, ("name=" + coreName).getBytes("UTF-8"));
- out.flush();
- out.close();
-
- String coreConfDir = solrCoreDir + "/conf/";
- copy("/solr/oak/conf/schema.xml", coreConfDir);
- copy("/solr/oak/conf/solrconfig.xml", coreConfDir);
- } else if (!solrCorePathFile.isDirectory()) {
- throw new IOException("a non directory file with the specified name already exists for the given Solr core path'" + solrCorePathFile.getAbsolutePath());
- }
- // clean data dir
- File solrDataPathFile = new File(solrHomePathFile + "/" + coreName + "/data/index");
- if (solrDataPathFile.exists()) {
- log.debug("deleting stale lock files");
- File[] locks = solrDataPathFile.listFiles((dir, name) -> "write.lock".equals(name));
- log.debug("found {} lock files", locks.length);
- // remove eventaul previous lock files (e.g. due to ungraceful shutdown)
- if (locks.length > 0) {
- for (File f : locks) {
- FileUtils.forceDelete(f);
- log.debug("deleted {}", f.getAbsolutePath());
- }
- }
- }
-
- // check if the a core with the given coreName exists
- String[] files = solrHomePathFile.list();
- if (files != null) {
- Arrays.sort(files);
- if (Arrays.binarySearch(files, coreName) < 0) {
- throw new IOException("could not find a directory with the coreName '" + coreName
- + "' in the solrHomePath '" + solrHomePath + "'");
- }
- }
- }
-
- private void copy(String resource, String dir) throws IOException {
- String fileName = dir + resource.substring(resource.lastIndexOf("/"));
- File outputFile = new File(fileName);
- if (outputFile.createNewFile()) {
- InputStream inputStream = null;
- FileOutputStream outputStream = null;
- try {
- inputStream = getClass().getResourceAsStream(resource);
- outputStream = new FileOutputStream(outputFile);
- IOUtils.copy(inputStream, outputStream);
- } finally {
- if (inputStream != null) {
- try {
- inputStream.close();
- } catch (Exception e) {
- // do nothing
- }
- }
- if (outputStream != null) {
... 3068 lines suppressed ...