diff --git a/docs/user/dql/functions.rst b/docs/user/dql/functions.rst index e36efe8ce6..1589fd11e0 100644 --- a/docs/user/dql/functions.rst +++ b/docs/user/dql/functions.rst @@ -2963,7 +2963,7 @@ Description ``query_string([field_expression+], query_expression[, option=]*)`` -The query_string function maps to the query_string query used in search engine (also used by `query`_), to return the documents that match a provided text, number, date or boolean value with a given field or fields. +The query_string function maps to the query_string query used in search engine, to return the documents that match a provided text, number, date or boolean value with a given field or fields. The **^** lets you *boost* certain fields. Boosts are multipliers that weigh matches in one field more heavily than matches in other fields. The syntax allows to specify the fields in double quotes, single quotes, backticks or without any wrap. All fields search using star ``"*"`` is also available (star symbol should be wrapped). The weight is optional and should be specified after the field name, it could be delimeted by the `caret` character or by whitespace. Please refer to examples below: | ``query_string(["Tags" ^ 2, 'Title' 3.4, `Body`, Comments ^ 0.3], ...)`` @@ -3025,7 +3025,7 @@ Description ``query("query_expression" [, option=]*)`` -This is an alternative syntax to the `query_string`_ function. The query function maps to the query_string query used in search engine, to return the documents that match a provided text, number, date or boolean value with a given field or fields. +The `query` function is an alternative syntax to the `query_string`_ function. It maps to the query_string query used in search engine, to return the documents that match a provided text, number, date or boolean value with a given query expression. ``query_expression`` must be a string provided in Lucene query string syntax. Please refer to examples below: | ``query('Tags:taste OR Body:taste', ...)`` diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/RelevanceQuery.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/RelevanceQuery.java index 51254aa2a3..1512214615 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/RelevanceQuery.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/RelevanceQuery.java @@ -45,12 +45,12 @@ protected void checkValidArguments(String argNormalized, T queryBuilder) { protected T loadArguments(List arguments) throws SemanticCheckException { // Aggregate parameters by name, so getting a Map arguments.stream().collect(Collectors.groupingBy(a -> a.getArgName().toLowerCase())) - .forEach((k, v) -> { - if (v.size() > 1) { - throw new SemanticCheckException( - String.format("Parameter '%s' can only be specified once.", k)); - } - }); + .forEach((k, v) -> { + if (v.size() > 1) { + throw new SemanticCheckException( + String.format("Parameter '%s' can only be specified once.", k)); + } + }); T queryBuilder = createQueryBuilder(arguments); @@ -64,9 +64,9 @@ protected T loadArguments(List arguments) throws Semant checkValidArguments(argNormalized, queryBuilder); (Objects.requireNonNull( - queryBuildActions - .get(argNormalized))) - .apply(queryBuilder, arg.getValue().valueOf(null)); + queryBuildActions + .get(argNormalized))) + .apply(queryBuilder, arg.getValue().valueOf(null)); } return queryBuilder; @@ -102,5 +102,4 @@ public Map> getQueryBuildActions() { protected interface QueryBuilderStep extends BiFunction { } - } diff --git a/sql/src/test/java/org/opensearch/sql/sql/parser/AstExpressionBuilderTest.java b/sql/src/test/java/org/opensearch/sql/sql/parser/AstExpressionBuilderTest.java index a6979da2a0..cb00ea2f18 100644 --- a/sql/src/test/java/org/opensearch/sql/sql/parser/AstExpressionBuilderTest.java +++ b/sql/src/test/java/org/opensearch/sql/sql/parser/AstExpressionBuilderTest.java @@ -523,7 +523,6 @@ public void relevanceSimple_query_string() { + "analyzer='keyword', operator='AND')")); } - @Test public void relevanceQuery_string() { assertEquals(AstDSL.function("query_string",