public void testMultiPercolate() { String multiPercolateShardAction = MultiPercolateAction.NAME + "[shard][s]"; interceptTransportActions(multiPercolateShardAction); client().prepareIndex("test-get", "type", "1").setSource("field", "value").get(); MultiPercolateRequest multiPercolateRequest = new MultiPercolateRequest(); List<String> indices = new ArrayList<>(); int numRequests = iterations(1, 30); for (int i = 0; i < numRequests; i++) { String[] indicesOrAliases = randomIndicesOrAliases(); Collections.addAll(indices, indicesOrAliases); PercolateRequest percolateRequest = new PercolateRequest().indices(indicesOrAliases).documentType("type"); if (randomBoolean()) { percolateRequest.getRequest(new GetRequest("test-get", "type", "1")); } else { percolateRequest.source("\"field\":\"value\""); } multiPercolateRequest.add(percolateRequest); } internalCluster().clientNodeClient().multiPercolate(multiPercolateRequest).actionGet(); clearInterceptedActions(); assertIndicesSubset(indices, multiPercolateShardAction); }
@Override public void handleRequest( RestRequest restRequest, RestChannel restChannel, final Client client) { PercolateRequest percolateRequest = new PercolateRequest(); percolateRequest.onlyCount(true); parseExistingDocPercolate(percolateRequest, restRequest, restChannel, client); }
void parseExistingDocPercolate( PercolateRequest percolateRequest, RestRequest restRequest, RestChannel restChannel, final Client client) { String index = restRequest.param("index"); String type = restRequest.param("type"); percolateRequest.indices( Strings.splitStringByCommaToArray(restRequest.param("percolate_index", index))); percolateRequest.documentType(restRequest.param("percolate_type", type)); GetRequest getRequest = new GetRequest(index, type, restRequest.param("id")); getRequest.routing(restRequest.param("routing")); getRequest.preference(restRequest.param("preference")); getRequest.refresh(restRequest.paramAsBoolean("refresh", getRequest.refresh())); getRequest.realtime(restRequest.paramAsBoolean("realtime", getRequest.realtime())); getRequest.version(RestActions.parseVersion(restRequest)); getRequest.versionType( VersionType.fromString(restRequest.param("version_type"), getRequest.versionType())); percolateRequest.getRequest(getRequest); percolateRequest.routing(restRequest.param("percolate_routing")); percolateRequest.preference(restRequest.param("percolate_preference")); percolateRequest.source(RestActions.getRestContent(restRequest)); percolateRequest.indicesOptions( IndicesOptions.fromRequest(restRequest, percolateRequest.indicesOptions())); executePercolate(percolateRequest, restChannel, client); }
public void testPercolate() { String percolateShardAction = PercolateAction.NAME + "[s]"; interceptTransportActions(percolateShardAction); client().prepareIndex("test-get", "type", "1").setSource("field", "value").get(); PercolateRequest percolateRequest = new PercolateRequest().indices(randomIndicesOrAliases()).documentType("type"); if (randomBoolean()) { percolateRequest.getRequest(new GetRequest("test-get", "type", "1")); } else { percolateRequest.source("\"field\":\"value\""); } internalCluster().clientNodeClient().percolate(percolateRequest).actionGet(); clearInterceptedActions(); assertSameIndices(percolateRequest, percolateShardAction); }
void parseDocPercolate( PercolateRequest percolateRequest, RestRequest restRequest, RestChannel restChannel, final Client client) { percolateRequest.indices(Strings.splitStringByCommaToArray(restRequest.param("index"))); percolateRequest.documentType(restRequest.param("type")); percolateRequest.routing(restRequest.param("routing")); percolateRequest.preference(restRequest.param("preference")); percolateRequest.source(RestActions.getRestContent(restRequest)); percolateRequest.indicesOptions( IndicesOptions.fromRequest(restRequest, percolateRequest.indicesOptions())); executePercolate(percolateRequest, restChannel, client); }