diff --git a/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/elasticsearch/executor/CopyExecutor.java b/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/elasticsearch/executor/CopyExecutor.java index f7d088fcaab..02453e85c91 100644 --- a/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/elasticsearch/executor/CopyExecutor.java +++ b/modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/elasticsearch/executor/CopyExecutor.java @@ -50,8 +50,7 @@ private ElasticsearchQuery createQuery() final QueryBuilder idFilterBuilder = new FilterBuilderFactory( SearchQueryFieldNameResolver.INSTANCE ).create( Filters.from( idFilter ) ); - return ElasticsearchQuery.create() - .query( QueryBuilders.boolQuery().must( idFilterBuilder ) ) + return ElasticsearchQuery.create().query( QueryBuilders.boolQuery().filter( idFilterBuilder ) ) .addIndexName( copyRequest.getStorageSource().getStorageName().getName() ) .addIndexType( copyRequest.getStorageSource().getStorageType().getName() ) .size( copyRequest.getNodeIds().size() ) diff --git a/modules/itest/itest-core/src/test/java/com/enonic/xp/core/node/PushNodesCommandTest.java b/modules/itest/itest-core/src/test/java/com/enonic/xp/core/node/PushNodesCommandTest.java index c71e0ae6839..9c70c71d893 100644 --- a/modules/itest/itest-core/src/test/java/com/enonic/xp/core/node/PushNodesCommandTest.java +++ b/modules/itest/itest-core/src/test/java/com/enonic/xp/core/node/PushNodesCommandTest.java @@ -1,8 +1,12 @@ package com.enonic.xp.core.node; +import java.util.concurrent.TimeUnit; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import com.google.common.base.Stopwatch; + import com.enonic.xp.core.AbstractNodeTest; import com.enonic.xp.node.CreateNodeParams; import com.enonic.xp.node.FindNodesByQueryResult; @@ -14,8 +18,11 @@ import com.enonic.xp.node.PushNodeEntry; import com.enonic.xp.node.PushNodesResult; import com.enonic.xp.node.RefreshMode; +import com.enonic.xp.node.ResolveSyncWorkResult; import com.enonic.xp.node.UpdateNodeParams; import com.enonic.xp.repo.impl.node.FindNodesByQueryCommand; +import com.enonic.xp.repo.impl.node.PushNodesCommand; +import com.enonic.xp.repo.impl.node.ResolveSyncWorkCommand; import com.enonic.xp.security.acl.AccessControlEntry; import com.enonic.xp.security.acl.AccessControlList; import com.enonic.xp.security.acl.Permission; @@ -438,6 +445,43 @@ public void push_with_capital_node_id() assertNotNull( prodNode ); } + @Test + void push_more_than_1024_nodes_at_once() + { + final Node rootNode = createNodeSkipVerification( CreateNodeParams.create().name( "rootNode" ).parent( NodePath.ROOT ).build() ); + + createNodes( rootNode, 10, 3, 1 ); + + refresh(); + + final ResolveSyncWorkResult syncWork = ResolveSyncWorkCommand.create() + .nodeId( rootNode.id() ) + .target( WS_OTHER ) + .indexServiceInternal( this.indexServiceInternal ) + .storageService( this.storageService ) + .searchService( this.searchService ) + .build() + .execute(); + + final Stopwatch started = Stopwatch.createStarted(); + + final PushNodesResult result = PushNodesCommand.create() + .ids( syncWork.getNodeComparisons().getNodeIds() ) + .target( WS_OTHER ) + .indexServiceInternal( this.indexServiceInternal ) + .storageService( this.storageService ) + .searchService( this.searchService ) + .build() + .execute(); + + started.stop(); + + final long elapsed = started.elapsed( TimeUnit.SECONDS ); + final int number = result.getSuccessfulEntries().size(); + + System.out.println( "Pushed : " + number + " in " + started + ", " + ( elapsed == 0 ? "n/a" : ( number / elapsed ) + "/s" ) ); + } + private Node getNodeByPathInOther( final NodePath nodePath ) { return ctxOther().callWith( () -> getNodeByPath( nodePath ) );