use of org.opensearch.common.logging.DeprecationLogger in project OpenSearch by opensearch-project.
the class RequestConvertersTests method testMultiSearch.
public void testMultiSearch() throws IOException {
int numberOfSearchRequests = randomIntBetween(0, 32);
MultiSearchRequest multiSearchRequest = new MultiSearchRequest();
for (int i = 0; i < numberOfSearchRequests; i++) {
SearchRequest searchRequest = randomSearchRequest(() -> {
// No need to return a very complex SearchSourceBuilder here, that is tested
// elsewhere
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.from(randomInt(10));
searchSourceBuilder.size(randomIntBetween(20, 100));
return searchSourceBuilder;
});
// scroll is not supported in the current msearch api, so unset it:
searchRequest.scroll((Scroll) null);
// only expand_wildcards, ignore_unavailable and allow_no_indices can be
// specified from msearch api, so unset other options:
IndicesOptions randomlyGenerated = searchRequest.indicesOptions();
IndicesOptions msearchDefault = new MultiSearchRequest().indicesOptions();
searchRequest.indicesOptions(IndicesOptions.fromOptions(randomlyGenerated.ignoreUnavailable(), randomlyGenerated.allowNoIndices(), randomlyGenerated.expandWildcardsOpen(), randomlyGenerated.expandWildcardsClosed(), msearchDefault.expandWildcardsHidden(), msearchDefault.allowAliasesToMultipleIndices(), msearchDefault.forbidClosedIndices(), msearchDefault.ignoreAliases(), msearchDefault.ignoreThrottled()));
multiSearchRequest.add(searchRequest);
}
Map<String, String> expectedParams = new HashMap<>();
expectedParams.put(RestSearchAction.TYPED_KEYS_PARAM, "true");
if (randomBoolean()) {
multiSearchRequest.maxConcurrentSearchRequests(randomIntBetween(1, 8));
expectedParams.put("max_concurrent_searches", Integer.toString(multiSearchRequest.maxConcurrentSearchRequests()));
}
Request request = RequestConverters.multiSearch(multiSearchRequest);
assertEquals("/_msearch", request.getEndpoint());
assertEquals(HttpPost.METHOD_NAME, request.getMethod());
assertEquals(expectedParams, request.getParameters());
List<SearchRequest> requests = new ArrayList<>();
CheckedBiConsumer<SearchRequest, XContentParser, IOException> consumer = (searchRequest, p) -> {
SearchSourceBuilder searchSourceBuilder = SearchSourceBuilder.fromXContent(p, false);
if (searchSourceBuilder.equals(new SearchSourceBuilder()) == false) {
searchRequest.source(searchSourceBuilder);
}
requests.add(searchRequest);
};
MultiSearchRequest.readMultiLineFormat(new BytesArray(EntityUtils.toByteArray(request.getEntity())), REQUEST_BODY_CONTENT_TYPE.xContent(), consumer, null, multiSearchRequest.indicesOptions(), null, null, null, xContentRegistry(), true, deprecationLogger);
assertEquals(requests, multiSearchRequest.requests());
}
use of org.opensearch.common.logging.DeprecationLogger in project OpenSearch by opensearch-project.
the class MultiSearchRequestTests method testMultiLineSerialization.
public void testMultiLineSerialization() throws IOException {
int iters = 16;
for (int i = 0; i < iters; i++) {
// The only formats that support stream separator
XContentType xContentType = randomFrom(XContentType.JSON, XContentType.SMILE);
MultiSearchRequest originalRequest = createMultiSearchRequest();
byte[] originalBytes = MultiSearchRequest.writeMultiLineFormat(originalRequest, xContentType.xContent());
MultiSearchRequest parsedRequest = new MultiSearchRequest();
CheckedBiConsumer<SearchRequest, XContentParser, IOException> consumer = (r, p) -> {
SearchSourceBuilder searchSourceBuilder = SearchSourceBuilder.fromXContent(p, false);
if (searchSourceBuilder.equals(new SearchSourceBuilder()) == false) {
r.source(searchSourceBuilder);
}
parsedRequest.add(r);
};
MultiSearchRequest.readMultiLineFormat(new BytesArray(originalBytes), xContentType.xContent(), consumer, null, null, null, null, null, xContentRegistry(), true, deprecationLogger);
assertEquals(originalRequest, parsedRequest);
}
}
use of org.opensearch.common.logging.DeprecationLogger in project OpenSearch by opensearch-project.
the class OpenSearchLoggerUsageTests method checkDeprecationLogger.
public void checkDeprecationLogger() {
DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(OpenSearchLoggerUsageTests.class);
deprecationLogger.deprecate("key", "message {}", 123);
}
Aggregations