Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

buildscript {
ext {
opensearch_version = System.getProperty("opensearch.version", "3.6.0-SNAPSHOT")
opensearch_version = System.getProperty("opensearch.version", "3.7.0-SNAPSHOT")
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
version_tokens = opensearch_version.tokenize('-')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@

package org.opensearch.sql.legacy.domain.hints;

import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLParser;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.opensearch.common.xcontent.LoggingDeprecationHandler;
import org.opensearch.common.xcontent.yaml.YamlXContentParser;
import org.opensearch.common.xcontent.yaml.YamlXContent;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.core.xcontent.XContentParser;
import org.opensearch.sql.legacy.exception.SqlParseException;

/** Created by Eliran on 5/9/2015. */
Expand Down Expand Up @@ -104,13 +103,9 @@ public static Hint getHintFromString(String hintAsString) throws SqlParseExcepti
builder.append(highlights[i]);
}
String heighlightParam = builder.toString();
YAMLFactory yamlFactory = new YAMLFactory();
YAMLParser yamlParser = null;
try {
yamlParser = yamlFactory.createParser(heighlightParam.toCharArray());
YamlXContentParser yamlXContentParser =
new YamlXContentParser(
NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, yamlParser);
try (XContentParser yamlXContentParser =
YamlXContent.yamlXContent.createParser(
NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, heighlightParam)) {
Map<String, Object> map = yamlXContentParser.map();
hintParams.add(map);
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package org.opensearch.sql.legacy.query;

import com.fasterxml.jackson.core.JsonFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -14,8 +13,9 @@
import org.opensearch.action.search.SearchRequestBuilder;
import org.opensearch.action.support.IndicesOptions;
import org.opensearch.common.xcontent.LoggingDeprecationHandler;
import org.opensearch.common.xcontent.json.JsonXContentParser;
import org.opensearch.common.xcontent.json.JsonXContent;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.core.xcontent.XContentParser;
import org.opensearch.index.query.QueryBuilders;
import org.opensearch.search.collapse.CollapseBuilder;
import org.opensearch.search.fetch.subphase.highlight.HighlightBuilder;
Expand Down Expand Up @@ -88,16 +88,15 @@ public Optional<List<String>> getFieldNames() {

protected void updateRequestWithCollapse(Select select, SearchRequestBuilder request)
throws SqlParseException {
JsonFactory jsonFactory = new JsonFactory();
for (Hint hint : select.getHints()) {
if (hint.getType() == HintType.COLLAPSE
&& hint.getParams() != null
&& 0 < hint.getParams().length) {
try (JsonXContentParser parser =
new JsonXContentParser(
try (XContentParser parser =
JsonXContent.jsonXContent.createParser(
NamedXContentRegistry.EMPTY,
LoggingDeprecationHandler.INSTANCE,
jsonFactory.createParser(hint.getParams()[0].toString()))) {
hint.getParams()[0].toString())) {
request.setCollapse(CollapseBuilder.fromXContent(parser));
} catch (IOException e) {
throw new SqlParseException("could not parse collapse hint: " + e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package org.opensearch.sql.legacy.query.maker;

import com.alibaba.druid.sql.ast.expr.SQLAggregateOption;
import com.fasterxml.jackson.core.JsonFactory;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.ZoneOffset;
Expand All @@ -19,7 +18,6 @@
import org.apache.commons.lang3.StringUtils;
import org.opensearch.common.xcontent.LoggingDeprecationHandler;
import org.opensearch.common.xcontent.json.JsonXContent;
import org.opensearch.common.xcontent.json.JsonXContentParser;
import org.opensearch.core.common.ParsingException;
import org.opensearch.core.common.Strings;
import org.opensearch.core.xcontent.NamedXContentRegistry;
Expand Down Expand Up @@ -340,11 +338,9 @@ private AggregationBuilder termsAgg(MethodField field) throws SqlParseException
terms.order(BucketOrder.key(false));
} else {
List<BucketOrder> orderElements = new ArrayList<>();
try (JsonXContentParser parser =
new JsonXContentParser(
NamedXContentRegistry.EMPTY,
LoggingDeprecationHandler.INSTANCE,
new JsonFactory().createParser(value))) {
try (XContentParser parser =
JsonXContent.jsonXContent.createParser(
NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, value)) {
XContentParser.Token currentToken = parser.nextToken();
if (currentToken == XContentParser.Token.START_OBJECT) {
orderElements.add(InternalOrder.Parser.parseOrderParam(parser));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@

package org.opensearch.sql.legacy.request;

import com.fasterxml.jackson.core.JsonFactory;
import java.io.IOException;
import java.util.Collections;
import org.json.JSONException;
import org.json.JSONObject;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.xcontent.LoggingDeprecationHandler;
import org.opensearch.common.xcontent.json.JsonXContentParser;
import org.opensearch.common.xcontent.json.JsonXContent;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.core.xcontent.XContentParser;
import org.opensearch.index.query.BoolQueryBuilder;
Expand Down Expand Up @@ -90,10 +89,10 @@ private void addFilterFromJson(BoolQueryBuilder boolQuery) throws SqlParseExcept
String filter = getFilterObjectAsString(jsonContent);
SearchModule searchModule = new SearchModule(Settings.EMPTY, Collections.emptyList());
XContentParser parser =
new JsonXContentParser(
JsonXContent.jsonXContent.createParser(
new NamedXContentRegistry(searchModule.getNamedXContents()),
LoggingDeprecationHandler.INSTANCE,
new JsonFactory().createParser(filter));
filter);

// nextToken is called before passing the parser to fromXContent since the fieldName will be
// null if the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@

package org.opensearch.sql.legacy.utils;

import com.fasterxml.jackson.core.JsonFactory;
import java.io.IOException;
import org.opensearch.common.xcontent.LoggingDeprecationHandler;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.common.xcontent.json.JsonXContentParser;
import org.opensearch.common.xcontent.json.JsonXContent;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.core.xcontent.XContentParser;
Expand All @@ -26,10 +25,8 @@ public static String format(String jsonString) throws IOException {
// turn _explain response into pretty formatted Json
XContentBuilder contentBuilder = XContentFactory.jsonBuilder().prettyPrint();
try (XContentParser contentParser =
new JsonXContentParser(
NamedXContentRegistry.EMPTY,
LoggingDeprecationHandler.INSTANCE,
new JsonFactory().createParser(jsonString))) {
JsonXContent.jsonXContent.createParser(
NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, jsonString)) {
contentBuilder.copyCurrentStructure(contentParser);
}
return contentBuilder.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.opensearch.common.Numbers;
import org.opensearch.common.geo.GeoPoint;
import org.opensearch.common.geo.GeoUtils;
import org.opensearch.common.xcontent.json.JsonXContentParser;
import org.opensearch.common.xcontent.json.JsonXContent;
import org.opensearch.core.xcontent.DeprecationHandler;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.core.xcontent.XContentParser;
Expand Down Expand Up @@ -149,10 +149,10 @@ public Object objectValue() {
public Pair<Double, Double> geoValue() {
final JsonNode value = value();
try (XContentParser parser =
new JsonXContentParser(
JsonXContent.jsonXContent.createParser(
NamedXContentRegistry.EMPTY,
DeprecationHandler.IGNORE_DEPRECATIONS,
value.traverse())) {
value.toString())) {
parser.nextToken();
GeoPoint point = new GeoPoint();
GeoUtils.parseGeoPoint(parser, point, true);
Expand Down
Loading