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 fo...@apache.org on 2020/05/22 11:00:22 UTC
svn commit: r1878026 [2/3] - in /jackrabbit/oak/trunk:
oak-benchmarks-elastic/src/main/java/org/apache/jackrabbit/oak/benchmark/
oak-benchmarks-elastic/src/main/java/org/apache/jackrabbit/oak/benchmark/util/
oak-search-elastic/ oak-search-elastic/src/m...
Copied: jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexEditorProvider.java (from r1878025, jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/index/ElasticsearchIndexEditorProvider.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexEditorProvider.java?p2=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexEditorProvider.java&p1=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/index/ElasticsearchIndexEditorProvider.java&r1=1878025&r2=1878026&rev=1878026&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/index/ElasticsearchIndexEditorProvider.java (original)
+++ jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexEditorProvider.java Fri May 22 11:00:21 2020
@@ -14,14 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.jackrabbit.oak.plugins.index.elasticsearch.index;
+package org.apache.jackrabbit.oak.plugins.index.elastic.index;
import org.apache.jackrabbit.oak.plugins.index.ContextAwareCallback;
import org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider;
import org.apache.jackrabbit.oak.plugins.index.IndexUpdateCallback;
import org.apache.jackrabbit.oak.plugins.index.IndexingContext;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.ElasticsearchConnection;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.ElasticsearchIndexDefinition;
+import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticConnection;
+import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexDefinition;
import org.apache.jackrabbit.oak.plugins.index.search.ExtractedTextCache;
import org.apache.jackrabbit.oak.spi.commit.Editor;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
@@ -29,16 +29,16 @@ import org.apache.jackrabbit.oak.spi.sta
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import static org.apache.jackrabbit.oak.plugins.index.elasticsearch.ElasticsearchIndexDefinition.TYPE_ELASTICSEARCH;
+import static org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexDefinition.TYPE_ELASTICSEARCH;
-public class ElasticsearchIndexEditorProvider implements IndexEditorProvider {
+public class ElasticIndexEditorProvider implements IndexEditorProvider {
- private final ElasticsearchConnection elasticsearchConnection;
+ private final ElasticConnection elasticConnection;
private final ExtractedTextCache extractedTextCache;
- public ElasticsearchIndexEditorProvider(@NotNull ElasticsearchConnection elasticsearchConnection,
- ExtractedTextCache extractedTextCache) {
- this.elasticsearchConnection = elasticsearchConnection;
+ public ElasticIndexEditorProvider(@NotNull ElasticConnection elasticConnection,
+ ExtractedTextCache extractedTextCache) {
+ this.elasticConnection = elasticConnection;
this.extractedTextCache = extractedTextCache != null ? extractedTextCache : new ExtractedTextCache(0, 0);
}
@@ -53,20 +53,20 @@ public class ElasticsearchIndexEditorPro
IndexingContext indexingContext = ((ContextAwareCallback) callback).getIndexingContext();
String indexPath = indexingContext.getIndexPath();
- ElasticsearchIndexDefinition indexDefinition =
- new ElasticsearchIndexDefinition(root, definition.getNodeState(), indexPath, elasticsearchConnection.getIndexPrefix());
+ ElasticIndexDefinition indexDefinition =
+ new ElasticIndexDefinition(root, definition.getNodeState(), indexPath, elasticConnection.getIndexPrefix());
- ElasticsearchIndexWriterFactory writerFactory = new ElasticsearchIndexWriterFactory(elasticsearchConnection);
+ ElasticIndexWriterFactory writerFactory = new ElasticIndexWriterFactory(elasticConnection);
- ElasticsearchIndexEditorContext context = new ElasticsearchIndexEditorContext(root,
+ ElasticIndexEditorContext context = new ElasticIndexEditorContext(root,
definition, indexDefinition,
callback,
writerFactory,
extractedTextCache,
indexingContext,
- true, elasticsearchConnection.getIndexPrefix());
+ true, elasticConnection.getIndexPrefix());
- return new ElasticsearchIndexEditor(context);
+ return new ElasticIndexEditor(context);
}
return null;
}
Copied: jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexHelper.java (from r1878025, jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/index/ElasticsearchIndexHelper.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexHelper.java?p2=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexHelper.java&p1=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/index/ElasticsearchIndexHelper.java&r1=1878025&r2=1878026&rev=1878026&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/index/ElasticsearchIndexHelper.java (original)
+++ jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexHelper.java Fri May 22 11:00:21 2020
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.jackrabbit.oak.plugins.index.elasticsearch.index;
+package org.apache.jackrabbit.oak.plugins.index.elastic.index;
import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.ElasticsearchIndexDefinition;
+import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexDefinition;
import org.apache.jackrabbit.oak.plugins.index.search.FieldNames;
import org.apache.jackrabbit.oak.plugins.index.search.PropertyDefinition;
import org.elasticsearch.client.indices.CreateIndexRequest;
@@ -33,9 +33,9 @@ import java.util.stream.Collectors;
/**
* Provides utility functions around Elasticsearch indexing
*/
-class ElasticsearchIndexHelper {
+class ElasticIndexHelper {
- public static CreateIndexRequest createIndexRequest(ElasticsearchIndexDefinition indexDefinition) throws IOException {
+ public static CreateIndexRequest createIndexRequest(ElasticIndexDefinition indexDefinition) throws IOException {
final CreateIndexRequest request = new CreateIndexRequest(indexDefinition.getRemoteIndexName());
// provision settings
@@ -87,7 +87,7 @@ class ElasticsearchIndexHelper {
// .endObject();
}
- private static void mapIndexRules(ElasticsearchIndexDefinition indexDefinition, XContentBuilder mappingBuilder) throws IOException {
+ private static void mapIndexRules(ElasticIndexDefinition indexDefinition, XContentBuilder mappingBuilder) throws IOException {
// we need to check if in the defined rules there are properties with the same name and different types
final List<Map.Entry<String, List<PropertyDefinition>>> multiTypesFields = indexDefinition.getPropertiesByName()
.entrySet()
Copied: jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexWriter.java (from r1878025, jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/index/ElasticsearchIndexWriter.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexWriter.java?p2=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexWriter.java&p1=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/index/ElasticsearchIndexWriter.java&r1=1878025&r2=1878026&rev=1878026&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/index/ElasticsearchIndexWriter.java (original)
+++ jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexWriter.java Fri May 22 11:00:21 2020
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.jackrabbit.oak.plugins.index.elasticsearch.index;
+package org.apache.jackrabbit.oak.plugins.index.elastic.index;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.ElasticsearchConnection;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.ElasticsearchIndexDefinition;
+import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticConnection;
+import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexDefinition;
import org.apache.jackrabbit.oak.plugins.index.search.spi.editor.FulltextIndexWriter;
import org.elasticsearch.ElasticsearchStatusException;
import org.elasticsearch.action.DocWriteRequest;
@@ -63,15 +63,15 @@ import java.util.stream.Collectors;
import static org.elasticsearch.common.xcontent.ToXContent.EMPTY_PARAMS;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-class ElasticsearchIndexWriter implements FulltextIndexWriter<ElasticsearchDocument> {
- private static final Logger LOG = LoggerFactory.getLogger(ElasticsearchIndexWriter.class);
+class ElasticIndexWriter implements FulltextIndexWriter<ElasticDocument> {
+ private static final Logger LOG = LoggerFactory.getLogger(ElasticIndexWriter.class);
- private final ElasticsearchConnection elasticsearchConnection;
- private final ElasticsearchIndexDefinition indexDefinition;
+ private final ElasticConnection elasticConnection;
+ private final ElasticIndexDefinition indexDefinition;
/**
* Coordinates communication between bulk processes. It has a main controller registered at creation time and
- * de-registered on {@link ElasticsearchIndexWriter#close(long)}. Each bulk request register a new party in
+ * de-registered on {@link ElasticIndexWriter#close(long)}. Each bulk request register a new party in
* this Phaser in {@link OakBulkProcessorListener#beforeBulk(long, BulkRequest)} and de-register itself when
* the request returns.
*/
@@ -83,25 +83,25 @@ class ElasticsearchIndexWriter implement
private final ConcurrentHashMap<Long, Boolean> updatesMap = new ConcurrentHashMap<>();
private final BulkProcessor bulkProcessor;
- ElasticsearchIndexWriter(@NotNull ElasticsearchConnection elasticsearchConnection,
- @NotNull ElasticsearchIndexDefinition indexDefinition) {
- this.elasticsearchConnection = elasticsearchConnection;
+ ElasticIndexWriter(@NotNull ElasticConnection elasticConnection,
+ @NotNull ElasticIndexDefinition indexDefinition) {
+ this.elasticConnection = elasticConnection;
this.indexDefinition = indexDefinition;
bulkProcessor = initBulkProcessor();
}
@TestOnly
- ElasticsearchIndexWriter(@NotNull ElasticsearchConnection elasticsearchConnection,
- @NotNull ElasticsearchIndexDefinition indexDefinition,
- @NotNull BulkProcessor bulkProcessor) {
- this.elasticsearchConnection = elasticsearchConnection;
+ ElasticIndexWriter(@NotNull ElasticConnection elasticConnection,
+ @NotNull ElasticIndexDefinition indexDefinition,
+ @NotNull BulkProcessor bulkProcessor) {
+ this.elasticConnection = elasticConnection;
this.indexDefinition = indexDefinition;
this.bulkProcessor = bulkProcessor;
}
private BulkProcessor initBulkProcessor() {
return BulkProcessor.builder((request, bulkListener) ->
- elasticsearchConnection.getClient().bulkAsync(request, RequestOptions.DEFAULT, bulkListener),
+ elasticConnection.getClient().bulkAsync(request, RequestOptions.DEFAULT, bulkListener),
new OakBulkProcessorListener())
.setBulkActions(indexDefinition.bulkActions)
.setBulkSize(new ByteSizeValue(indexDefinition.bulkSizeBytes))
@@ -113,7 +113,7 @@ class ElasticsearchIndexWriter implement
}
@Override
- public void updateDocument(String path, ElasticsearchDocument doc) {
+ public void updateDocument(String path, ElasticDocument doc) {
IndexRequest request = new IndexRequest(indexDefinition.getRemoteIndexAlias())
.id(idFromPath(path))
.source(doc.build(), XContentType.JSON);
@@ -150,7 +150,7 @@ class ElasticsearchIndexWriter implement
protected void provisionIndex() throws IOException {
// check if index already exists
- boolean exists = elasticsearchConnection.getClient().indices().exists(
+ boolean exists = elasticConnection.getClient().indices().exists(
new GetIndexRequest(indexDefinition.getRemoteIndexName()), RequestOptions.DEFAULT
);
if (exists) {
@@ -158,11 +158,11 @@ class ElasticsearchIndexWriter implement
return;
}
- final IndicesClient indicesClient = elasticsearchConnection.getClient().indices();
+ final IndicesClient indicesClient = elasticConnection.getClient().indices();
final String indexName = indexDefinition.getRemoteIndexName();
// create the new index
- final CreateIndexRequest request = ElasticsearchIndexHelper.createIndexRequest(indexDefinition);
+ final CreateIndexRequest request = ElasticIndexHelper.createIndexRequest(indexDefinition);
try {
if (LOG.isDebugEnabled()) {
final String requestMsg = Strings.toString(request.toXContent(jsonBuilder(), EMPTY_PARAMS));
Copied: jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexWriterFactory.java (from r1878025, jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/index/ElasticsearchIndexWriterFactory.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexWriterFactory.java?p2=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexWriterFactory.java&p1=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/index/ElasticsearchIndexWriterFactory.java&r1=1878025&r2=1878026&rev=1878026&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/index/ElasticsearchIndexWriterFactory.java (original)
+++ jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexWriterFactory.java Fri May 22 11:00:21 2020
@@ -14,28 +14,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.jackrabbit.oak.plugins.index.elasticsearch.index;
+package org.apache.jackrabbit.oak.plugins.index.elastic.index;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.ElasticsearchConnection;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.ElasticsearchIndexDefinition;
+import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticConnection;
+import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexDefinition;
import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition;
import org.apache.jackrabbit.oak.plugins.index.search.spi.editor.FulltextIndexWriterFactory;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
import org.jetbrains.annotations.NotNull;
-class ElasticsearchIndexWriterFactory implements FulltextIndexWriterFactory<ElasticsearchDocument> {
- private final ElasticsearchConnection elasticsearchConnection;
+class ElasticIndexWriterFactory implements FulltextIndexWriterFactory<ElasticDocument> {
+ private final ElasticConnection elasticConnection;
- ElasticsearchIndexWriterFactory(@NotNull ElasticsearchConnection elasticsearchConnection) {
- this.elasticsearchConnection = elasticsearchConnection;
+ ElasticIndexWriterFactory(@NotNull ElasticConnection elasticConnection) {
+ this.elasticConnection = elasticConnection;
}
@Override
- public ElasticsearchIndexWriter newInstance(IndexDefinition definition, NodeBuilder definitionBuilder, boolean reindex) {
- if (!(definition instanceof ElasticsearchIndexDefinition)) {
+ public ElasticIndexWriter newInstance(IndexDefinition definition, NodeBuilder definitionBuilder, boolean reindex) {
+ if (!(definition instanceof ElasticIndexDefinition)) {
throw new IllegalArgumentException("IndexDefinition must be of type ElasticsearchIndexDefinition " +
"instead of " + definition.getClass().getName());
}
- return new ElasticsearchIndexWriter(elasticsearchConnection, (ElasticsearchIndexDefinition) definition);
+ return new ElasticIndexWriter(elasticConnection, (ElasticIndexDefinition) definition);
}
}
Copied: jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticIndex.java (from r1878025, jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/query/ElasticsearchIndex.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticIndex.java?p2=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticIndex.java&p1=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/query/ElasticsearchIndex.java&r1=1878025&r2=1878026&rev=1878026&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/query/ElasticsearchIndex.java (original)
+++ jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticIndex.java Fri May 22 11:00:21 2020
@@ -14,9 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.jackrabbit.oak.plugins.index.elasticsearch.query;
+package org.apache.jackrabbit.oak.plugins.index.elastic.query;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.ElasticsearchConnection;
+import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticConnection;
import org.apache.jackrabbit.oak.plugins.index.search.IndexNode;
import org.apache.jackrabbit.oak.plugins.index.search.SizeEstimator;
import org.apache.jackrabbit.oak.plugins.index.search.spi.query.FulltextIndex;
@@ -35,9 +35,9 @@ import java.util.WeakHashMap;
import java.util.function.Predicate;
import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.TYPE_PROPERTY_NAME;
-import static org.apache.jackrabbit.oak.plugins.index.elasticsearch.ElasticsearchIndexDefinition.TYPE_ELASTICSEARCH;
+import static org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexDefinition.TYPE_ELASTICSEARCH;
-class ElasticsearchIndex extends FulltextIndex {
+class ElasticIndex extends FulltextIndex {
private static final Predicate<NodeState> ELASTICSEARCH_INDEX_DEFINITION_PREDICATE =
state -> TYPE_ELASTICSEARCH.equals(state.getString(TYPE_PROPERTY_NAME));
private static final Map<String, LMSEstimator> estimators = new WeakHashMap<>();
@@ -45,11 +45,11 @@ class ElasticsearchIndex extends Fulltex
// higher than some threshold below which the query should rather be answered by something else if possible
private static final double MIN_COST = 100.1;
- private final ElasticsearchConnection elasticsearchConnection;
+ private final ElasticConnection elasticConnection;
private final NodeState root;
- ElasticsearchIndex(@NotNull ElasticsearchConnection elasticsearchConnection, @NotNull NodeState root) {
- this.elasticsearchConnection = elasticsearchConnection;
+ ElasticIndex(@NotNull ElasticConnection elasticConnection, @NotNull NodeState root) {
+ this.elasticConnection = elasticConnection;
this.root = root;
}
@@ -79,20 +79,20 @@ class ElasticsearchIndex extends Fulltex
}
@Override
- protected ElasticsearchIndexNode acquireIndexNode(IndexPlan plan) {
- return (ElasticsearchIndexNode) super.acquireIndexNode(plan);
+ protected ElasticIndexNode acquireIndexNode(IndexPlan plan) {
+ return (ElasticIndexNode) super.acquireIndexNode(plan);
}
@Override
protected IndexNode acquireIndexNode(String indexPath) {
- return new ElasticsearchIndexNode(root, indexPath, elasticsearchConnection);
+ return new ElasticIndexNode(root, indexPath, elasticConnection);
}
@Override
protected String getFulltextRequestString(IndexPlan plan, IndexNode indexNode) {
- return Strings.toString(new ElasticsearchResultRowIterator(plan.getFilter(), getPlanResult(plan), plan,
+ return Strings.toString(new ElasticResultRowIterator(plan.getFilter(), getPlanResult(plan), plan,
acquireIndexNode(plan), FulltextIndex::shouldInclude, getEstimator(plan.getPlanName()))
- .getESQuery(plan, getPlanResult(plan)));
+ .getElasticQuery(plan, getPlanResult(plan)));
}
@Override
@@ -104,7 +104,7 @@ class ElasticsearchIndex extends Fulltex
final FulltextIndexPlanner.PlanResult pr = getPlanResult(plan);
QueryLimits settings = filter.getQueryLimits();
- Iterator<FulltextResultRow> itr = new ElasticsearchResultRowIterator(filter, pr, plan,
+ Iterator<FulltextResultRow> itr = new ElasticResultRowIterator(filter, pr, plan,
acquireIndexNode(plan), FulltextIndex::shouldInclude, getEstimator(plan.getPlanName()));
SizeEstimator sizeEstimator = getSizeEstimator(plan);
Copied: jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticIndexNode.java (from r1878025, jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/query/ElasticsearchIndexNode.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticIndexNode.java?p2=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticIndexNode.java&p1=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/query/ElasticsearchIndexNode.java&r1=1878025&r2=1878026&rev=1878026&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/query/ElasticsearchIndexNode.java (original)
+++ jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticIndexNode.java Fri May 22 11:00:21 2020
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.jackrabbit.oak.plugins.index.elasticsearch.query;
+package org.apache.jackrabbit.oak.plugins.index.elastic.query;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.ElasticsearchConnection;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.ElasticsearchIndexDefinition;
+import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticConnection;
+import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexDefinition;
import org.apache.jackrabbit.oak.plugins.index.search.IndexNode;
import org.apache.jackrabbit.oak.plugins.index.search.IndexStatistics;
import org.apache.jackrabbit.oak.spi.state.NodeState;
@@ -25,16 +25,16 @@ import org.apache.jackrabbit.oak.spi.sta
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-public class ElasticsearchIndexNode implements IndexNode {
+public class ElasticIndexNode implements IndexNode {
- private final ElasticsearchConnection elasticsearchConnection;
- private final ElasticsearchIndexDefinition indexDefinition;
+ private final ElasticConnection elasticConnection;
+ private final ElasticIndexDefinition indexDefinition;
- ElasticsearchIndexNode(@NotNull NodeState root, @NotNull String indexPath,
- @NotNull ElasticsearchConnection elasticsearchConnection) {
+ ElasticIndexNode(@NotNull NodeState root, @NotNull String indexPath,
+ @NotNull ElasticConnection elasticConnection) {
final NodeState indexNS = NodeStateUtils.getNode(root, indexPath);
- this.elasticsearchConnection = elasticsearchConnection;
- this.indexDefinition = new ElasticsearchIndexDefinition(root, indexNS, indexPath, elasticsearchConnection.getIndexPrefix());
+ this.elasticConnection = elasticConnection;
+ this.indexDefinition = new ElasticIndexDefinition(root, indexNS, indexPath, elasticConnection.getIndexPrefix());
}
@Override
@@ -43,12 +43,12 @@ public class ElasticsearchIndexNode impl
}
@Override
- public ElasticsearchIndexDefinition getDefinition() {
+ public ElasticIndexDefinition getDefinition() {
return indexDefinition;
}
- public ElasticsearchConnection getConnection() {
- return elasticsearchConnection;
+ public ElasticConnection getConnection() {
+ return elasticConnection;
}
@Override
@@ -60,6 +60,6 @@ public class ElasticsearchIndexNode impl
@Override
public @Nullable IndexStatistics getIndexStatistics() {
- return new ElasticsearchIndexStatistics(elasticsearchConnection, indexDefinition);
+ return new ElasticIndexStatistics(elasticConnection, indexDefinition);
}
}
Copied: jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticIndexProvider.java (from r1878025, jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/query/ElasticsearchIndexProvider.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticIndexProvider.java?p2=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticIndexProvider.java&p1=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/query/ElasticsearchIndexProvider.java&r1=1878025&r2=1878026&rev=1878026&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/query/ElasticsearchIndexProvider.java (original)
+++ jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticIndexProvider.java Fri May 22 11:00:21 2020
@@ -14,9 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.jackrabbit.oak.plugins.index.elasticsearch.query;
+package org.apache.jackrabbit.oak.plugins.index.elastic.query;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.ElasticsearchConnection;
+import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticConnection;
import org.apache.jackrabbit.oak.spi.query.QueryIndex;
import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
import org.apache.jackrabbit.oak.spi.state.NodeState;
@@ -25,16 +25,16 @@ import org.jetbrains.annotations.NotNull
import java.util.Collections;
import java.util.List;
-public class ElasticsearchIndexProvider implements QueryIndexProvider {
- private final ElasticsearchConnection elasticsearchConnection;
+public class ElasticIndexProvider implements QueryIndexProvider {
+ private final ElasticConnection elasticConnection;
- public ElasticsearchIndexProvider(ElasticsearchConnection elasticsearchConnection) {
- this.elasticsearchConnection = elasticsearchConnection;
+ public ElasticIndexProvider(ElasticConnection elasticConnection) {
+ this.elasticConnection = elasticConnection;
}
@Override
public @NotNull List<? extends QueryIndex> getQueryIndexes(NodeState nodeState) {
- return Collections.singletonList(new ElasticsearchIndex(elasticsearchConnection, nodeState));
+ return Collections.singletonList(new ElasticIndex(elasticConnection, nodeState));
}
}
Copied: jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticIndexStatistics.java (from r1878025, jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/query/ElasticsearchIndexStatistics.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticIndexStatistics.java?p2=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticIndexStatistics.java&p1=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/query/ElasticsearchIndexStatistics.java&r1=1878025&r2=1878026&rev=1878026&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/query/ElasticsearchIndexStatistics.java (original)
+++ jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticIndexStatistics.java Fri May 22 11:00:21 2020
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.jackrabbit.oak.plugins.index.elasticsearch.query;
+package org.apache.jackrabbit.oak.plugins.index.elastic.query;
import com.google.common.base.Ticker;
import com.google.common.cache.CacheBuilder;
@@ -22,8 +22,8 @@ import com.google.common.cache.CacheLoad
import com.google.common.cache.LoadingCache;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListenableFutureTask;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.ElasticsearchConnection;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.ElasticsearchIndexDefinition;
+import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticConnection;
+import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexDefinition;
import org.apache.jackrabbit.oak.plugins.index.search.IndexStatistics;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.core.CountRequest;
@@ -51,7 +51,7 @@ import java.util.concurrent.TimeUnit;
* <li>{@code oak.elastic.statsRefreshMin}</li>
* </ul>
*/
-class ElasticsearchIndexStatistics implements IndexStatistics {
+class ElasticIndexStatistics implements IndexStatistics {
private static final Long MAX_SIZE = Long.getLong("oak.elastic.statsMaxSize", 10000);
private static final Long EXPIRE_MIN = Long.getLong("oak.elastic.statsExpireMin", 10);
@@ -60,42 +60,42 @@ class ElasticsearchIndexStatistics imple
private static final LoadingCache<CountRequestDescriptor, Integer> DEFAULT_STATS_CACHE =
setupCache(MAX_SIZE, EXPIRE_MIN, REFRESH_MIN, null);
- private final ElasticsearchConnection elasticsearchConnection;
- private final ElasticsearchIndexDefinition indexDefinition;
+ private final ElasticConnection elasticConnection;
+ private final ElasticIndexDefinition indexDefinition;
private final LoadingCache<CountRequestDescriptor, Integer> statsCache;
- ElasticsearchIndexStatistics(@NotNull ElasticsearchConnection elasticsearchConnection,
- @NotNull ElasticsearchIndexDefinition indexDefinition) {
- this(elasticsearchConnection, indexDefinition, DEFAULT_STATS_CACHE);
+ ElasticIndexStatistics(@NotNull ElasticConnection elasticConnection,
+ @NotNull ElasticIndexDefinition indexDefinition) {
+ this(elasticConnection, indexDefinition, DEFAULT_STATS_CACHE);
}
@TestOnly
- ElasticsearchIndexStatistics(@NotNull ElasticsearchConnection elasticsearchConnection,
- @NotNull ElasticsearchIndexDefinition indexDefinition,
- @NotNull LoadingCache<CountRequestDescriptor, Integer> statsCache) {
- this.elasticsearchConnection = elasticsearchConnection;
+ ElasticIndexStatistics(@NotNull ElasticConnection elasticConnection,
+ @NotNull ElasticIndexDefinition indexDefinition,
+ @NotNull LoadingCache<CountRequestDescriptor, Integer> statsCache) {
+ this.elasticConnection = elasticConnection;
this.indexDefinition = indexDefinition;
this.statsCache = statsCache;
}
/**
- * Returns the approximate number of documents for the remote index bound to the {@code ElasticsearchIndexDefinition}.
+ * Returns the approximate number of documents for the remote index bound to the {@code ElasticIndexDefinition}.
*/
@Override
public int numDocs() {
return statsCache.getUnchecked(
- new CountRequestDescriptor(elasticsearchConnection, indexDefinition.getRemoteIndexAlias(), null)
+ new CountRequestDescriptor(elasticConnection, indexDefinition.getRemoteIndexAlias(), null)
);
}
/**
* Returns the approximate number of documents for the {@code field} in the remote index bound to the
- * {@code ElasticsearchIndexDefinition}.
+ * {@code ElasticIndexDefinition}.
*/
@Override
public int getDocCountFor(String field) {
return statsCache.getUnchecked(
- new CountRequestDescriptor(elasticsearchConnection, indexDefinition.getRemoteIndexAlias(), field)
+ new CountRequestDescriptor(elasticConnection, indexDefinition.getRemoteIndexAlias(), field)
);
}
@@ -140,13 +140,13 @@ class ElasticsearchIndexStatistics imple
static class CountRequestDescriptor {
@NotNull
- final ElasticsearchConnection connection;
+ final ElasticConnection connection;
@NotNull
final String index;
@Nullable
final String field;
- public CountRequestDescriptor(@NotNull ElasticsearchConnection connection,
+ public CountRequestDescriptor(@NotNull ElasticConnection connection,
@NotNull String index, @Nullable String field) {
this.connection = connection;
this.index = index;
Copied: jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticResultRowIterator.java (from r1878025, jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/query/ElasticsearchResultRowIterator.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticResultRowIterator.java?p2=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticResultRowIterator.java&p1=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/query/ElasticsearchResultRowIterator.java&r1=1878025&r2=1878026&rev=1878026&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/query/ElasticsearchResultRowIterator.java (original)
+++ jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticResultRowIterator.java Fri May 22 11:00:21 2020
@@ -14,17 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.jackrabbit.oak.plugins.index.elasticsearch.query;
+package org.apache.jackrabbit.oak.plugins.index.elastic.query;
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.commons.PathUtils;
import org.apache.jackrabbit.oak.commons.PerfLogger;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.ElasticsearchIndexDefinition;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.facets.ElasticFacetHelper;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.facets.ElasticsearchAggregationData;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.facets.ElasticsearchFacets;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.util.ElasticsearchAggregationBuilderUtil;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.util.ElasticsearchConstants;
+import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexDefinition;
+import org.apache.jackrabbit.oak.plugins.index.elastic.query.facets.ElasticFacetHelper;
+import org.apache.jackrabbit.oak.plugins.index.elastic.query.facets.ElasticAggregationData;
+import org.apache.jackrabbit.oak.plugins.index.elastic.query.facets.ElasticFacets;
+import org.apache.jackrabbit.oak.plugins.index.elastic.util.ElasticAggregationBuilderUtil;
+import org.apache.jackrabbit.oak.plugins.index.elastic.util.ElasticConstants;
import org.apache.jackrabbit.oak.plugins.index.search.FieldNames;
import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition;
import org.apache.jackrabbit.oak.plugins.index.search.PropertyDefinition;
@@ -68,18 +68,18 @@ import static org.apache.jackrabbit.JcrC
import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
import static org.apache.jackrabbit.oak.commons.PathUtils.denotesRoot;
import static org.apache.jackrabbit.oak.commons.PathUtils.getParentPath;
-import static org.apache.jackrabbit.oak.plugins.index.elasticsearch.util.TermQueryBuilderFactory.newAncestorQuery;
-import static org.apache.jackrabbit.oak.plugins.index.elasticsearch.util.TermQueryBuilderFactory.newDepthQuery;
-import static org.apache.jackrabbit.oak.plugins.index.elasticsearch.util.TermQueryBuilderFactory.newMixinTypeQuery;
-import static org.apache.jackrabbit.oak.plugins.index.elasticsearch.util.TermQueryBuilderFactory.newNodeTypeQuery;
-import static org.apache.jackrabbit.oak.plugins.index.elasticsearch.util.TermQueryBuilderFactory.newNotNullPropQuery;
-import static org.apache.jackrabbit.oak.plugins.index.elasticsearch.util.TermQueryBuilderFactory.newNullPropQuery;
-import static org.apache.jackrabbit.oak.plugins.index.elasticsearch.util.TermQueryBuilderFactory.newPathQuery;
-import static org.apache.jackrabbit.oak.plugins.index.elasticsearch.util.TermQueryBuilderFactory.newPrefixPathQuery;
-import static org.apache.jackrabbit.oak.plugins.index.elasticsearch.util.TermQueryBuilderFactory.newPrefixQuery;
-import static org.apache.jackrabbit.oak.plugins.index.elasticsearch.util.TermQueryBuilderFactory.newPropertyRestrictionQuery;
-import static org.apache.jackrabbit.oak.plugins.index.elasticsearch.util.TermQueryBuilderFactory.newWildcardPathQuery;
-import static org.apache.jackrabbit.oak.plugins.index.elasticsearch.util.TermQueryBuilderFactory.newWildcardQuery;
+import static org.apache.jackrabbit.oak.plugins.index.elastic.util.TermQueryBuilderFactory.newAncestorQuery;
+import static org.apache.jackrabbit.oak.plugins.index.elastic.util.TermQueryBuilderFactory.newDepthQuery;
+import static org.apache.jackrabbit.oak.plugins.index.elastic.util.TermQueryBuilderFactory.newMixinTypeQuery;
+import static org.apache.jackrabbit.oak.plugins.index.elastic.util.TermQueryBuilderFactory.newNodeTypeQuery;
+import static org.apache.jackrabbit.oak.plugins.index.elastic.util.TermQueryBuilderFactory.newNotNullPropQuery;
+import static org.apache.jackrabbit.oak.plugins.index.elastic.util.TermQueryBuilderFactory.newNullPropQuery;
+import static org.apache.jackrabbit.oak.plugins.index.elastic.util.TermQueryBuilderFactory.newPathQuery;
+import static org.apache.jackrabbit.oak.plugins.index.elastic.util.TermQueryBuilderFactory.newPrefixPathQuery;
+import static org.apache.jackrabbit.oak.plugins.index.elastic.util.TermQueryBuilderFactory.newPrefixQuery;
+import static org.apache.jackrabbit.oak.plugins.index.elastic.util.TermQueryBuilderFactory.newPropertyRestrictionQuery;
+import static org.apache.jackrabbit.oak.plugins.index.elastic.util.TermQueryBuilderFactory.newWildcardPathQuery;
+import static org.apache.jackrabbit.oak.plugins.index.elastic.util.TermQueryBuilderFactory.newWildcardQuery;
import static org.apache.jackrabbit.oak.plugins.index.search.spi.query.FulltextIndex.isNodePath;
import static org.apache.jackrabbit.oak.spi.query.QueryConstants.JCR_PATH;
import static org.apache.jackrabbit.util.ISO8601.parse;
@@ -88,11 +88,11 @@ import static org.elasticsearch.index.qu
import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
-class ElasticsearchResultRowIterator implements Iterator<FulltextIndex.FulltextResultRow> {
+class ElasticResultRowIterator implements Iterator<FulltextIndex.FulltextResultRow> {
private static final Logger LOG = LoggerFactory
- .getLogger(ElasticsearchResultRowIterator.class);
+ .getLogger(ElasticResultRowIterator.class);
private static final PerfLogger PERF_LOGGER =
- new PerfLogger(LoggerFactory.getLogger(ElasticsearchResultRowIterator.class.getName() + ".perf"));
+ new PerfLogger(LoggerFactory.getLogger(ElasticResultRowIterator.class.getName() + ".perf"));
// TODO: oak-lucene gets this via WildcardQuery class. See if ES also exposes these consts
private static final char WILDCARD_STRING = '*';
@@ -102,22 +102,22 @@ class ElasticsearchResultRowIterator imp
// TODO : find if ES can return dup docs - if so how to avoid
// private final Set<String> seenPaths = Sets.newHashSet();
private SearchHit lastDoc;
- private int nextBatchSize = ElasticsearchConstants.ELASTICSEARCH_QUERY_BATCH_SIZE;
+ private int nextBatchSize = ElasticConstants.ELASTIC_QUERY_BATCH_SIZE;
private boolean noDocs = false;
private final Filter filter;
private final PlanResult planResult;
private final IndexPlan plan;
- private final ElasticsearchIndexNode indexNode;
+ private final ElasticIndexNode indexNode;
private final RowInclusionPredicate rowInclusionPredicate;
private final LMSEstimator estimator;
- ElasticsearchResultRowIterator(@NotNull Filter filter,
- @NotNull PlanResult planResult,
- @NotNull IndexPlan plan,
- ElasticsearchIndexNode indexNode,
- RowInclusionPredicate rowInclusionPredicate,
- LMSEstimator estimator) {
+ ElasticResultRowIterator(@NotNull Filter filter,
+ @NotNull PlanResult planResult,
+ @NotNull IndexPlan plan,
+ ElasticIndexNode indexNode,
+ RowInclusionPredicate rowInclusionPredicate,
+ LMSEstimator estimator) {
this.filter = filter;
this.planResult = planResult;
this.plan = plan;
@@ -153,14 +153,14 @@ class ElasticsearchResultRowIterator imp
SearchHit lastDocToRecord = null;
try {
- ElasticsearchSearcher searcher = getCurrentSearcher(indexNode);
- QueryBuilder query = getESQuery(plan, planResult);
- ElasticsearchIndexDefinition indexDefinition = indexNode.getDefinition();
+ ElasticSearcher searcher = getCurrentElasticSearcher(indexNode);
+ QueryBuilder query = getElasticQuery(plan, planResult);
+ ElasticIndexDefinition indexDefinition = indexNode.getDefinition();
int numberOfFacets = indexDefinition.getNumberOfTopFacets();
- List<TermsAggregationBuilder> aggregationBuilders = ElasticsearchAggregationBuilderUtil
+ List<TermsAggregationBuilder> aggregationBuilders = ElasticAggregationBuilderUtil
.getAggregators(plan, indexDefinition, numberOfFacets);
- ElasticsearchSearcherModel elasticsearchSearcherModel = new ElasticsearchSearcherModel.ElasticsearchSearcherModelBuilder()
+ ElasticSearcherModel elasticSearcherModel = new ElasticSearcherModel.ElasticSearcherModelBuilder()
.withQuery(query)
.withBatchSize(nextBatchSize)
.withAggregation(aggregationBuilders)
@@ -172,10 +172,10 @@ class ElasticsearchResultRowIterator imp
long start = PERF_LOGGER.start();
while (true) {
LOG.debug("loading {} entries for query {}", nextBatchSize, query);
- docs = searcher.search(elasticsearchSearcherModel);
+ docs = searcher.search(elasticSearcherModel);
long totalHits = docs.getHits().getTotalHits().value;
- ElasticsearchAggregationData elasticsearchAggregationData =
- new ElasticsearchAggregationData(numberOfFacets, totalHits, docs.getAggregations());
+ ElasticAggregationData elasticAggregationData =
+ new ElasticAggregationData(numberOfFacets, totalHits, docs.getAggregations());
SearchHit[] searchHits = docs.getHits().getHits();
PERF_LOGGER.end(start, -1, "{} ...", searchHits.length);
@@ -186,9 +186,9 @@ class ElasticsearchResultRowIterator imp
noDocs = true;
}
- nextBatchSize = (int) Math.min(nextBatchSize * 2L, ElasticsearchConstants.ELASTICSEARCH_QUERY_MAX_BATCH_SIZE);
+ nextBatchSize = (int) Math.min(nextBatchSize * 2L, ElasticConstants.ELASTIC_QUERY_MAX_BATCH_SIZE);
- ElasticsearchFacetProvider elasticsearchFacetProvider = new ElasticsearchFacetProvider(ElasticFacetHelper.getAggregates(searcher, query, indexNode, plan, elasticsearchAggregationData));
+ ElasticsearchFacetProvider elasticsearchFacetProvider = new ElasticsearchFacetProvider(ElasticFacetHelper.getAggregates(searcher, query, indexNode, plan, elasticAggregationData));
// TODO: excerpt
@@ -230,8 +230,8 @@ class ElasticsearchResultRowIterator imp
return !queue.isEmpty();
}
- private ElasticsearchSearcher getCurrentSearcher(ElasticsearchIndexNode indexNode) {
- return new ElasticsearchSearcher(indexNode);
+ private ElasticSearcher getCurrentElasticSearcher(ElasticIndexNode indexNode) {
+ return new ElasticSearcher(indexNode);
}
private FulltextIndex.FulltextResultRow convertToRow(SearchHit hit, ElasticsearchFacetProvider elasticsearchFacetProvider) {
@@ -273,11 +273,11 @@ class ElasticsearchResultRowIterator imp
* @param planResult
* @return the Lucene query
*/
- public QueryBuilder getESQuery(IndexPlan plan, PlanResult planResult) {
+ public QueryBuilder getElasticQuery(IndexPlan plan, PlanResult planResult) {
List<QueryBuilder> qs = new ArrayList<>();
Filter filter = plan.getFilter();
FullTextExpression ft = filter.getFullTextConstraint();
- ElasticsearchIndexDefinition defn = (ElasticsearchIndexDefinition) planResult.indexDefinition;
+ ElasticIndexDefinition defn = (ElasticIndexDefinition) planResult.indexDefinition;
if (ft != null) {
qs.add(getFullTextQuery(ft, planResult));
@@ -724,18 +724,18 @@ class ElasticsearchResultRowIterator imp
}
class ElasticsearchFacetProvider implements FulltextIndex.FacetProvider {
- private ElasticsearchFacets elasticsearchFacets;
+ private ElasticFacets elasticFacets;
private Map<String, List<FulltextIndex.Facet>> cachedResults = new HashMap<>();
- ElasticsearchFacetProvider(ElasticsearchFacets elasticsearchFacets) {
- this.elasticsearchFacets = elasticsearchFacets;
+ ElasticsearchFacetProvider(ElasticFacets elasticFacets) {
+ this.elasticFacets = elasticFacets;
}
@Override
public List<FulltextIndex.Facet> getFacets(int numberOfFacets, String columnName) throws IOException {
String facetProp = FulltextIndex.parseFacetField(columnName);
if (cachedResults.get(facetProp) == null) {
- cachedResults = elasticsearchFacets.getElasticSearchFacets(indexNode.getDefinition(), numberOfFacets);
+ cachedResults = elasticFacets.getFacets(indexNode.getDefinition(), numberOfFacets);
}
return cachedResults.get(facetProp);
}
Copied: jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticSearcher.java (from r1878025, jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/query/ElasticsearchSearcher.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticSearcher.java?p2=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticSearcher.java&p1=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/query/ElasticsearchSearcher.java&r1=1878025&r2=1878026&rev=1878026&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/query/ElasticsearchSearcher.java (original)
+++ jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticSearcher.java Fri May 22 11:00:21 2020
@@ -14,49 +14,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.jackrabbit.oak.plugins.index.elasticsearch.query;
+package org.apache.jackrabbit.oak.plugins.index.elastic.query;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.util.SearchSourceBuilderUtil;
-import org.apache.jackrabbit.oak.plugins.index.search.FieldNames;
+import org.apache.jackrabbit.oak.plugins.index.elastic.util.SearchSourceBuilderUtil;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
-import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
-public class ElasticsearchSearcher {
- private final ElasticsearchIndexNode indexNode;
+public class ElasticSearcher {
+ private final ElasticIndexNode indexNode;
- ElasticsearchSearcher(@NotNull ElasticsearchIndexNode indexNode) {
+ ElasticSearcher(@NotNull ElasticIndexNode indexNode) {
this.indexNode = indexNode;
}
- public SearchResponse search(ElasticsearchSearcherModel elasticsearchSearcherModel) throws IOException {
- SearchSourceBuilder searchSourceBuilder = SearchSourceBuilderUtil.createSearchSourceBuilder(elasticsearchSearcherModel);
+ public SearchResponse search(ElasticSearcherModel elasticSearcherModel) throws IOException {
+ SearchSourceBuilder searchSourceBuilder = SearchSourceBuilderUtil.createSearchSourceBuilder(elasticSearcherModel);
SearchRequest request = new SearchRequest(indexNode.getDefinition().getRemoteIndexAlias())
.source(searchSourceBuilder);
return indexNode.getConnection().getClient().search(request, RequestOptions.DEFAULT);
}
-
- @Deprecated
- public SearchResponse search(QueryBuilder query, int batchSize) throws IOException {
- SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder()
- .query(query)
- .fetchSource(FieldNames.PATH, null)
- .size(batchSize);
-
- SearchRequest request = new SearchRequest(indexNode.getDefinition().getRemoteIndexAlias())
- .source(searchSourceBuilder);
-
- return indexNode.getConnection().getClient().search(request, RequestOptions.DEFAULT);
- }
-
- public ElasticsearchSearcher getElasticsearchSearcher(){
- return this;
- }
}
Copied: jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticSearcherModel.java (from r1878025, jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/query/ElasticsearchSearcherModel.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticSearcherModel.java?p2=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticSearcherModel.java&p1=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/query/ElasticsearchSearcherModel.java&r1=1878025&r2=1878026&rev=1878026&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/query/ElasticsearchSearcherModel.java (original)
+++ jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticSearcherModel.java Fri May 22 11:00:21 2020
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.jackrabbit.oak.plugins.index.elasticsearch.query;
+package org.apache.jackrabbit.oak.plugins.index.elastic.query;
import org.apache.jackrabbit.oak.plugins.index.search.FieldNames;
import org.elasticsearch.index.query.QueryBuilder;
@@ -24,17 +24,17 @@ import org.elasticsearch.search.aggregat
import java.util.LinkedList;
import java.util.List;
-public class ElasticsearchSearcherModel {
+public class ElasticSearcherModel {
- private QueryBuilder queryBuilder;
- private List<AggregationBuilder> aggregationBuilders = new LinkedList<>();
- private int batchSize;
- private boolean fetchSource;
- private String storedField = FieldNames.PATH;
- private int from;
+ private final QueryBuilder queryBuilder;
+ private final List<AggregationBuilder> aggregationBuilders;
+ private final int batchSize;
+ private final boolean fetchSource;
+ private final String storedField;
+ private final int from;
- private ElasticsearchSearcherModel(QueryBuilder queryBuilder, List<AggregationBuilder> aggregationBuilders,
- int batchSize, boolean fetchSource, String storedField, int from) {
+ private ElasticSearcherModel(QueryBuilder queryBuilder, List<AggregationBuilder> aggregationBuilders,
+ int batchSize, boolean fetchSource, String storedField, int from) {
this.queryBuilder = queryBuilder;
this.aggregationBuilders = aggregationBuilders;
this.batchSize = batchSize;
@@ -67,36 +67,36 @@ public class ElasticsearchSearcherModel
return storedField;
}
- public static class ElasticsearchSearcherModelBuilder {
+ public static class ElasticSearcherModelBuilder {
private QueryBuilder queryBuilder;
- private List<AggregationBuilder> aggregationBuilders = new LinkedList<>();
+ private final List<AggregationBuilder> aggregationBuilders = new LinkedList<>();
private int batchSize;
private boolean fetchSource = false;
private String storedField = FieldNames.PATH;
private int from;
- public ElasticsearchSearcherModelBuilder withQuery(QueryBuilder query) {
+ public ElasticSearcherModelBuilder withQuery(QueryBuilder query) {
this.queryBuilder = query;
return this;
}
- public ElasticsearchSearcherModelBuilder withAggregation(List<TermsAggregationBuilder> aggregationBuilders) {
+ public ElasticSearcherModelBuilder withAggregation(List<TermsAggregationBuilder> aggregationBuilders) {
this.aggregationBuilders.addAll(aggregationBuilders);
return this;
}
- public ElasticsearchSearcherModelBuilder withBatchSize(int batchSize) {
+ public ElasticSearcherModelBuilder withBatchSize(int batchSize) {
this.batchSize = batchSize;
return this;
}
- public ElasticsearchSearcherModelBuilder withFrom(int from) {
+ public ElasticSearcherModelBuilder withFrom(int from) {
this.from = from;
return this;
}
- public ElasticsearchSearcherModel build() {
- return new ElasticsearchSearcherModel(queryBuilder, aggregationBuilders, batchSize, fetchSource, storedField, from);
+ public ElasticSearcherModel build() {
+ return new ElasticSearcherModel(queryBuilder, aggregationBuilders, batchSize, fetchSource, storedField, from);
}
}
}
Copied: jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/facets/ElasticAggregationData.java (from r1878025, jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/facets/ElasticsearchAggregationData.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/facets/ElasticAggregationData.java?p2=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/facets/ElasticAggregationData.java&p1=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/facets/ElasticsearchAggregationData.java&r1=1878025&r2=1878026&rev=1878026&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/facets/ElasticsearchAggregationData.java (original)
+++ jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/facets/ElasticAggregationData.java Fri May 22 11:00:21 2020
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.jackrabbit.oak.plugins.index.elasticsearch.facets;
+package org.apache.jackrabbit.oak.plugins.index.elastic.query.facets;
import org.elasticsearch.search.aggregations.Aggregations;
@@ -22,12 +22,12 @@ import org.elasticsearch.search.aggregat
This class's object is used in facets to save unnecessary call to Elasticsearch
as this info is also retrieved when calling ES in rowIterator.
*/
-public class ElasticsearchAggregationData {
+public class ElasticAggregationData {
private int numberOfFacets; // topFacet count from indexDefinition
private long totalDocuments; // total documents in query result.
private Aggregations aggregations; // Aggregated data for query from ES
- public ElasticsearchAggregationData(int numberOfFacets, long totalDocuments, Aggregations aggregations) {
+ public ElasticAggregationData(int numberOfFacets, long totalDocuments, Aggregations aggregations) {
this.numberOfFacets = numberOfFacets;
this.totalDocuments = totalDocuments;
this.aggregations = aggregations;
Modified: jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/facets/ElasticFacetHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/facets/ElasticFacetHelper.java?rev=1878026&r1=1878025&r2=1878026&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/facets/ElasticFacetHelper.java (original)
+++ jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/facets/ElasticFacetHelper.java Fri May 22 11:00:21 2020
@@ -16,10 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.jackrabbit.oak.plugins.index.elasticsearch.facets;
+package org.apache.jackrabbit.oak.plugins.index.elastic.query.facets;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.query.ElasticsearchIndexNode;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.query.ElasticsearchSearcher;
+import org.apache.jackrabbit.oak.plugins.index.elastic.query.ElasticIndexNode;
+import org.apache.jackrabbit.oak.plugins.index.elastic.query.ElasticSearcher;
import org.apache.jackrabbit.oak.plugins.index.search.FieldNames;
import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition.SecureFacetConfiguration;
import org.apache.jackrabbit.oak.spi.query.Filter;
@@ -37,25 +37,25 @@ public class ElasticFacetHelper {
private ElasticFacetHelper() {
}
- public static ElasticsearchFacets getAggregates(ElasticsearchSearcher searcher, QueryBuilder query,
- ElasticsearchIndexNode indexNode, QueryIndex.IndexPlan plan,
- ElasticsearchAggregationData elasticsearchAggregationData) {
- ElasticsearchFacets elasticsearchFacets;
+ public static ElasticFacets getAggregates(ElasticSearcher searcher, QueryBuilder query,
+ ElasticIndexNode indexNode, QueryIndex.IndexPlan plan,
+ ElasticAggregationData elasticAggregationData) {
+ ElasticFacets elasticFacets;
SecureFacetConfiguration secureFacetConfiguration = indexNode.getDefinition().getSecureFacetConfiguration();
switch (secureFacetConfiguration.getMode()) {
case INSECURE:
- elasticsearchFacets = new InsecureElasticSearchFacets(searcher, query, plan, elasticsearchAggregationData);
+ elasticFacets = new InsecureElasticFacets(searcher, query, plan, elasticAggregationData);
break;
case STATISTICAL:
- elasticsearchFacets = new StatisticalElasticSearchFacets(searcher, query, plan,
- secureFacetConfiguration, elasticsearchAggregationData);
+ elasticFacets = new StatisticalElasticFacets(searcher, query, plan,
+ secureFacetConfiguration, elasticAggregationData);
break;
case SECURE:
default:
- elasticsearchFacets = new SecureElasticSearchFacets(searcher, query, plan);
+ elasticFacets = new SecureElasticFacets(searcher, query, plan);
break;
}
- return elasticsearchFacets;
+ return elasticFacets;
}
public static List<String> getAccessibleDocIds(SearchHit[] searchHits, Filter filter) {
Copied: jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/facets/ElasticFacets.java (from r1878025, jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/facets/ElasticsearchFacets.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/facets/ElasticFacets.java?p2=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/facets/ElasticFacets.java&p1=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/facets/ElasticsearchFacets.java&r1=1878025&r2=1878026&rev=1878026&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/facets/ElasticsearchFacets.java (original)
+++ jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/facets/ElasticFacets.java Fri May 22 11:00:21 2020
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.jackrabbit.oak.plugins.index.elasticsearch.facets;
+package org.apache.jackrabbit.oak.plugins.index.elastic.query.facets;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.ElasticsearchIndexDefinition;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.query.ElasticsearchSearcher;
+import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexDefinition;
+import org.apache.jackrabbit.oak.plugins.index.elastic.query.ElasticSearcher;
import org.apache.jackrabbit.oak.plugins.index.search.spi.query.FulltextIndex;
import org.apache.jackrabbit.oak.spi.query.QueryIndex;
import org.elasticsearch.index.query.QueryBuilder;
@@ -28,12 +28,12 @@ import java.io.IOException;
import java.util.List;
import java.util.Map;
-public interface ElasticsearchFacets {
+public interface ElasticFacets {
/**
- * @return ElasticsearchSearcher
+ * @return ElasticSearcher
*/
- ElasticsearchSearcher getSearcher();
+ ElasticSearcher getSearcher();
/**
* @return QueryBuilder
@@ -50,18 +50,18 @@ public interface ElasticsearchFacets {
* @return A map with facetName as key and List of facets in descending order of facetCount.
* @throws IOException
*/
- Map<String, List<FulltextIndex.Facet>> getElasticSearchFacets(ElasticsearchIndexDefinition indexDefinition,
- int numberOfFacets) throws IOException;
+ Map<String, List<FulltextIndex.Facet>> getFacets(ElasticIndexDefinition indexDefinition,
+ int numberOfFacets) throws IOException;
/**
* We can retrieve Aggregation in a single call to elastic search while querying. Which can then be passed
- * to ElasticSearchfacets instead of calling ES again to fetch same info. If ElasticsearchAggregationData is null
+ * to ElasticFacets instead of calling ES again to fetch same info. If ElasticAggregationData is null
* then we get data by again querying ES
*
- * @return ElasticsearchAggregationData
+ * @return ElasticAggregationData
*/
@Nullable
- ElasticsearchAggregationData getElasticsearchAggregationData();
+ ElasticAggregationData getElasticAggregationData();
class ElasticSearchFacet {
Copied: jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/facets/InsecureElasticFacets.java (from r1878025, jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/facets/InsecureElasticSearchFacets.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/facets/InsecureElasticFacets.java?p2=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/facets/InsecureElasticFacets.java&p1=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/facets/InsecureElasticSearchFacets.java&r1=1878025&r2=1878026&rev=1878026&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/facets/InsecureElasticSearchFacets.java (original)
+++ jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/facets/InsecureElasticFacets.java Fri May 22 11:00:21 2020
@@ -14,12 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.jackrabbit.oak.plugins.index.elasticsearch.facets;
+package org.apache.jackrabbit.oak.plugins.index.elastic.query.facets;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.ElasticsearchIndexDefinition;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.query.ElasticsearchSearcher;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.query.ElasticsearchSearcherModel;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.util.ElasticsearchAggregationBuilderUtil;
+import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexDefinition;
+import org.apache.jackrabbit.oak.plugins.index.elastic.query.ElasticSearcher;
+import org.apache.jackrabbit.oak.plugins.index.elastic.query.ElasticSearcherModel;
+import org.apache.jackrabbit.oak.plugins.index.elastic.util.ElasticAggregationBuilderUtil;
import org.apache.jackrabbit.oak.plugins.index.search.spi.query.FulltextIndex;
import org.apache.jackrabbit.oak.spi.query.QueryIndex;
import org.elasticsearch.index.query.QueryBuilder;
@@ -35,35 +35,35 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-public class InsecureElasticSearchFacets implements ElasticsearchFacets {
- private static final Logger LOG = LoggerFactory.getLogger(InsecureElasticSearchFacets.class);
+public class InsecureElasticFacets implements ElasticFacets {
+ private static final Logger LOG = LoggerFactory.getLogger(InsecureElasticFacets.class);
- private ElasticsearchSearcher searcher;
+ private ElasticSearcher searcher;
private QueryBuilder query;
private QueryIndex.IndexPlan plan;
- private ElasticsearchAggregationData elasticsearchAggregationData;
+ private ElasticAggregationData elasticAggregationData;
- public InsecureElasticSearchFacets(ElasticsearchSearcher searcher, QueryBuilder query,
- QueryIndex.IndexPlan plan, ElasticsearchAggregationData elasticsearchAggregationData) {
+ public InsecureElasticFacets(ElasticSearcher searcher, QueryBuilder query,
+ QueryIndex.IndexPlan plan, ElasticAggregationData elasticAggregationData) {
this.searcher = searcher;
this.query = query;
this.plan = plan;
- this.elasticsearchAggregationData = elasticsearchAggregationData;
+ this.elasticAggregationData = elasticAggregationData;
}
@Override
- public Map<String, List<FulltextIndex.Facet>> getElasticSearchFacets(ElasticsearchIndexDefinition indexDefinition,
- int numberOfFacets) throws IOException {
- if (elasticsearchAggregationData != null && numberOfFacets <= elasticsearchAggregationData.getNumberOfFacets()) {
- return changeToFacetList(elasticsearchAggregationData.getAggregations().getAsMap(), numberOfFacets);
+ public Map<String, List<FulltextIndex.Facet>> getFacets(ElasticIndexDefinition indexDefinition,
+ int numberOfFacets) throws IOException {
+ if (elasticAggregationData != null && numberOfFacets <= elasticAggregationData.getNumberOfFacets()) {
+ return changeToFacetList(elasticAggregationData.getAggregations().getAsMap(), numberOfFacets);
}
LOG.warn("Facet data is being retrieved by again calling Elasticsearch");
- List<TermsAggregationBuilder> aggregationBuilders = ElasticsearchAggregationBuilderUtil.getAggregators(plan, indexDefinition, numberOfFacets);
- ElasticsearchSearcherModel elasticsearchSearcherModel = new ElasticsearchSearcherModel.ElasticsearchSearcherModelBuilder()
+ List<TermsAggregationBuilder> aggregationBuilders = ElasticAggregationBuilderUtil.getAggregators(plan, indexDefinition, numberOfFacets);
+ ElasticSearcherModel elasticSearcherModel = new ElasticSearcherModel.ElasticSearcherModelBuilder()
.withQuery(query)
.withAggregation(aggregationBuilders)
.build();
- Map<String, Aggregation> facetResult = searcher.search(elasticsearchSearcherModel).getAggregations().getAsMap();
+ Map<String, Aggregation> facetResult = searcher.search(elasticSearcherModel).getAggregations().getAsMap();
return changeToFacetList(facetResult, numberOfFacets);
}
@@ -89,7 +89,7 @@ public class InsecureElasticSearchFacets
}
@Override
- public ElasticsearchSearcher getSearcher() {
+ public ElasticSearcher getSearcher() {
return searcher;
}
@@ -104,7 +104,7 @@ public class InsecureElasticSearchFacets
}
@Override
- public ElasticsearchAggregationData getElasticsearchAggregationData() {
- return elasticsearchAggregationData;
+ public ElasticAggregationData getElasticAggregationData() {
+ return elasticAggregationData;
}
}
Copied: jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/facets/SecureElasticFacets.java (from r1878025, jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/facets/SecureElasticSearchFacets.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/facets/SecureElasticFacets.java?p2=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/facets/SecureElasticFacets.java&p1=jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/facets/SecureElasticSearchFacets.java&r1=1878025&r2=1878026&rev=1878026&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elasticsearch/facets/SecureElasticSearchFacets.java (original)
+++ jackrabbit/oak/trunk/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/facets/SecureElasticFacets.java Fri May 22 11:00:21 2020
@@ -14,13 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.jackrabbit.oak.plugins.index.elasticsearch.facets;
+package org.apache.jackrabbit.oak.plugins.index.elastic.query.facets;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.ElasticsearchIndexDefinition;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.query.ElasticsearchSearcher;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.query.ElasticsearchSearcherModel;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.util.ElasticsearchAggregationBuilderUtil;
-import org.apache.jackrabbit.oak.plugins.index.elasticsearch.util.ElasticsearchConstants;
+import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexDefinition;
+import org.apache.jackrabbit.oak.plugins.index.elastic.query.ElasticSearcher;
+import org.apache.jackrabbit.oak.plugins.index.elastic.query.ElasticSearcherModel;
+import org.apache.jackrabbit.oak.plugins.index.elastic.util.ElasticAggregationBuilderUtil;
+import org.apache.jackrabbit.oak.plugins.index.elastic.util.ElasticConstants;
import org.apache.jackrabbit.oak.plugins.index.search.spi.query.FulltextIndex;
import org.apache.jackrabbit.oak.spi.query.Filter;
import org.apache.jackrabbit.oak.spi.query.QueryIndex;
@@ -39,10 +39,10 @@ import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
-public class SecureElasticSearchFacets extends InsecureElasticSearchFacets {
+public class SecureElasticFacets extends InsecureElasticFacets {
- public SecureElasticSearchFacets(ElasticsearchSearcher searcher, QueryBuilder query,
- QueryIndex.IndexPlan plan) {
+ public SecureElasticFacets(ElasticSearcher searcher, QueryBuilder query,
+ QueryIndex.IndexPlan plan) {
super(searcher, query, plan, null);
}
@@ -51,21 +51,21 @@ public class SecureElasticSearchFacets e
for docs.
*/
@Override
- public Map<String, List<FulltextIndex.Facet>> getElasticSearchFacets(ElasticsearchIndexDefinition indexDefinition,
- int numberOfFacets) throws IOException {
+ public Map<String, List<FulltextIndex.Facet>> getFacets(ElasticIndexDefinition indexDefinition,
+ int numberOfFacets) throws IOException {
Map<String, Map<String, Long>> secureFacetCount = new HashMap<>();
Filter filter = getPlan().getFilter();
boolean doFetch = true;
- for (int from = 0; doFetch; from += ElasticsearchConstants.ELASTICSEARCH_QUERY_BATCH_SIZE) {
- ElasticsearchSearcherModel elasticsearchSearcherModel = new ElasticsearchSearcherModel.ElasticsearchSearcherModelBuilder()
+ for (int from = 0; doFetch; from += ElasticConstants.ELASTIC_QUERY_BATCH_SIZE) {
+ ElasticSearcherModel elasticSearcherModel = new ElasticSearcherModel.ElasticSearcherModelBuilder()
.withQuery(getQuery())
- .withBatchSize(ElasticsearchConstants.ELASTICSEARCH_QUERY_BATCH_SIZE)
+ .withBatchSize(ElasticConstants.ELASTIC_QUERY_BATCH_SIZE)
.withFrom(from)
.build();
- SearchResponse docs = getSearcher().search(elasticsearchSearcherModel);
+ SearchResponse docs = getSearcher().search(elasticSearcherModel);
SearchHit[] searchHits = docs.getHits().getHits();
long totalResults = docs.getHits().getTotalHits().value;
- if (totalResults <= from + ElasticsearchConstants.ELASTICSEARCH_QUERY_BATCH_SIZE || searchHits.length == 0) {
+ if (totalResults <= from + ElasticConstants.ELASTIC_QUERY_BATCH_SIZE || searchHits.length == 0) {
doFetch = false;
}
@@ -119,9 +119,9 @@ public class SecureElasticSearchFacets e
}
private Map<String, Aggregation> getAggregationForDocIds(QueryBuilder queryWithAccessibleDocIds, int facetCount,
- ElasticsearchIndexDefinition indexDefinition) throws IOException {
- List<TermsAggregationBuilder> aggregationBuilders = ElasticsearchAggregationBuilderUtil.getAggregators(getPlan(), indexDefinition, facetCount);
- ElasticsearchSearcherModel idBasedelasticsearchSearcherModelWithAggregation = new ElasticsearchSearcherModel.ElasticsearchSearcherModelBuilder()
+ ElasticIndexDefinition indexDefinition) throws IOException {
+ List<TermsAggregationBuilder> aggregationBuilders = ElasticAggregationBuilderUtil.getAggregators(getPlan(), indexDefinition, facetCount);
+ ElasticSearcherModel idBasedelasticsearchSearcherModelWithAggregation = new ElasticSearcherModel.ElasticSearcherModelBuilder()
.withQuery(queryWithAccessibleDocIds)
.withAggregation(aggregationBuilders)
.build();