Skip to content

Commit

Permalink
Update usage of Strings.toString (opensearch-project#1309)
Browse files Browse the repository at this point in the history
Signed-off-by: MaxKsyunz <[email protected]>
  • Loading branch information
Max Ksyunz authored Jan 30, 2023
1 parent 15d3ce0 commit 6108ca1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.Map;
import java.util.Objects;
import org.opensearch.common.Strings;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.index.query.BoolQueryBuilder;
import org.opensearch.sql.legacy.query.planner.core.ExecuteParams;
import org.opensearch.sql.legacy.query.planner.physical.PhysicalOperator;
Expand Down Expand Up @@ -97,7 +98,7 @@ private BoolQueryBuilder queryForPushedDownOnConds() {
);

if (LOG.isTraceEnabled()) {
LOG.trace("Terms filter optimization: {}", Strings.toString(andQuery));
LOG.trace("Terms filter optimization: {}", Strings.toString(XContentType.JSON, andQuery));
}
orQuery.should(andQuery);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Objects;

import org.opensearch.action.search.ClearScrollResponse;
import org.opensearch.action.search.SearchResponse;
import org.opensearch.client.Client;
import org.opensearch.common.Strings;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.common.xcontent.MediaType;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.index.query.BoolQueryBuilder;
import org.opensearch.index.query.QueryBuilder;
import org.opensearch.search.SearchHit;
Expand Down Expand Up @@ -94,7 +97,7 @@ public void open(ExecuteParams params) throws Exception {
generateNewQueryWithExtraFilter((BoolQueryBuilder) filter));

if (LOG.isDebugEnabled()) {
LOG.debug("Received extra query filter, re-build query: {}", Strings.toString(
LOG.debug("Received extra query filter, re-build query: {}", Strings.toString(XContentType.JSON,
request.getRequestBuilder().request().source(), true, true
));
}
Expand Down Expand Up @@ -194,6 +197,6 @@ private String describeTable() {
*********************************************/

public String getRequest() {
return Strings.toString(request.getRequestBuilder().request().source());
return Strings.toString(XContentType.JSON, request.getRequestBuilder().request().source());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.mockito.Mockito;
import org.opensearch.client.Client;
import org.opensearch.common.Strings;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.index.query.AbstractQueryBuilder;
import org.opensearch.index.query.MultiMatchQueryBuilder;
import org.opensearch.search.builder.SearchSourceBuilder.ScriptField;
Expand Down Expand Up @@ -302,6 +303,6 @@ private String query(String sql) {
}

private Matcher<String> contains(AbstractQueryBuilder queryBuilder) {
return containsString(Strings.toString(queryBuilder, false, false));
return containsString(Strings.toString(XContentType.JSON, queryBuilder, false, false));
}
}

0 comments on commit 6108ca1

Please sign in to comment.