Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] Replace non-ASCII characters in code and docs. #1486

Merged
merged 1 commit into from
Mar 30, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,22 @@ public void test006_testLoadPatternFromFileIso_8859_1() throws IOException, Grok
try (FileOutputStream fis = new FileOutputStream(temp);
BufferedWriter bw = new BufferedWriter(
new OutputStreamWriter(fis, StandardCharsets.ISO_8859_1))) {
bw.write("TEST §");
bw.write("TEST \\u2022");
}

GrokCompiler compiler = GrokCompiler.newInstance();
compiler.register(new FileInputStream(temp), StandardCharsets.ISO_8859_1);
Grok grok = compiler.compile("%{TEST}");
assertEquals("(?<name0>§)", grok.getNamedRegex());
assertEquals("(?<name0>\\u2022)", grok.getNamedRegex());
}

@Test
public void test007_testLoadPatternFromReader() throws IOException, GrokException {
Reader reader = new StringReader("TEST ");
Reader reader = new StringReader("TEST \\u20AC");
GrokCompiler compiler = GrokCompiler.newInstance();
compiler.register(reader);
Grok grok = compiler.compile("%{TEST}");
assertEquals("(?<name0>)", grok.getNamedRegex());
assertEquals("(?<name0>\\u20AC)", grok.getNamedRegex());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ private DefaultFunctionResolver dayOfMonth(BuiltinFunctionName name) {

/**
* DAYOFWEEK(STRING/DATE/DATETIME/TIME/TIMESTAMP).
* return the weekday index for date (1 = Sunday, 2 = Monday, , 7 = Saturday).
* return the weekday index for date (1 = Sunday, 2 = Monday, ..., 7 = Saturday).
*/
private DefaultFunctionResolver dayOfWeek(FunctionName name) {
return define(name,
Expand Down
6 changes: 3 additions & 3 deletions docs/user/dql/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ If an argument of type TIME is provided, the local date is used.
* - %c
- Month, numeric (0..12)
* - %D
- Day of the month with English suffix (0th, 1st, 2nd, 3rd, )
- Day of the month with English suffix (0th, 1st, 2nd, 3rd, ...)
* - %d
- Day of the month, numeric (00..31)
* - %e
Expand Down Expand Up @@ -1722,7 +1722,7 @@ DAYOFWEEK
Description
>>>>>>>>>>>

Usage: dayofweek(date) returns the weekday index for date (1 = Sunday, 2 = Monday, , 7 = Saturday).
Usage: dayofweek(date) returns the weekday index for date (1 = Sunday, 2 = Monday, ..., 7 = Saturday).

The `day_of_week` function is also provided as an alias.

Expand Down Expand Up @@ -2903,7 +2903,7 @@ The functions `weekofyear` and `week_of_year` is also provided as an alias.
* - Mode
- First day of week
- Range
- Week 1 is the first week
- Week 1 is the first week ...
* - 0
- Sunday
- 0-53
Expand Down
6 changes: 3 additions & 3 deletions docs/user/ppl/functions/datetime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ If an argument of type TIME is provided, the local date is used.
* - %c
- Month, numeric (0..12)
* - %D
- Day of the month with English suffix (0th, 1st, 2nd, 3rd, )
- Day of the month with English suffix (0th, 1st, 2nd, 3rd, ...)
* - %d
- Day of the month, numeric (00..31)
* - %e
Expand Down Expand Up @@ -694,7 +694,7 @@ DAYOFWEEK
Description
>>>>>>>>>>>

Usage: dayofweek(date) returns the weekday index for date (1 = Sunday, 2 = Monday, , 7 = Saturday).
Usage: dayofweek(date) returns the weekday index for date (1 = Sunday, 2 = Monday, ..., 7 = Saturday).

Argument type: STRING/DATE/DATETIME/TIMESTAMP

Expand Down Expand Up @@ -1505,7 +1505,7 @@ Usage: week(date[, mode]) returns the week number for date. If the mode argument
* - Mode
- First day of week
- Range
- Week 1 is the first week
- Week 1 is the first week ...
* - 0
- Sunday
- 0-53
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ protected void init() throws Exception {
}

/**
* query 搜索就是 , lucene 原生的搜素方式 注意这个例子中value可以随便命名 "query" :
* {query_string" : {"query" : "address:880 Holmes Lane"}
* query
* "query" : {
* query_string" : {
* "query" : "address:880 Holmes Lane"
* }
* }
*
* @throws IOException
*/
Expand All @@ -43,8 +47,15 @@ public void queryTest() throws IOException {
}

/**
* matchQuery 是利用分词结果进行单个字段的搜索. "query" : { "match" : { "address" :
* {"query":"880 Holmes Lane", "type" : "boolean" } } }
* matchQuery
* "query" : {
* "match" : {
* "address" : {
* "query" : "880 Holmes Lane",
* "type" : "boolean"
* }
* }
* }
*
* @throws IOException
*/
Expand All @@ -58,11 +69,45 @@ public void matchQueryTest() throws IOException {
}

/**
* matchQuery 是利用分词结果进行单个字段的搜索. "query" : { "bool" : { "must" : { "bool" : {
* "should" : [ { "constant_score" : { "query" : { "match" : { "address" : {
* "query" : "Lane", "type" : "boolean" } } }, "boost" : 100.0 } }, {
* "constant_score" : { "query" : { "match" : { "address" : { "query" :
* "Street", "type" : "boolean" } } }, "boost" : 0.5 } } ] } } } }
* matchQuery
* {
* "query": {
* "bool": {
* "must": {
* "bool": {
* "should": [
* {
* "constant_score": {
* "query": {
* "match": {
* "address": {
* "query": "Lane",
* "type": "boolean"
* }
* }
* },
* "boost": 100
* }
* },
* {
* "constant_score": {
* "query": {
* "match": {
* "address": {
* "query": "Street",
* "type": "boolean"
* }
* }
* },
* "boost": 0.5
* }
* }
* ]
* }
* }
* }
* }
* }
*
* @throws IOException
*/
Expand Down Expand Up @@ -102,8 +147,13 @@ public void negativeRegexpQueryTest() throws IOException {
}

/**
* wildcardQuery 是用通配符的方式查找某个term  比如例子中 l*e means leae ltae ....
* "wildcard": { "address" : { "wildcard" : "l*e" } }
* wildcardQuery
* l*e means leae ltae ...
* "wildcard": {
* "address" : {
* "wildcard" : "l*e"
* }
* }
*
* @throws IOException
*/
Expand All @@ -117,10 +167,10 @@ public void wildcardQueryTest() throws IOException {
}

/**
* matchPhraseQueryTest 短语查询完全匹配.
* matchPhraseQuery
* "address" : {
* "query" : "671 Bristol Street",
* "type" : "phrase"
* "query" : "671 Bristol Street",
* "type" : "phrase"
* }
*
* @throws IOException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.opensearch.sql.legacy.utils.StringUtils;

/**
* 过滤条件
*
*
* @author ansj
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.opensearch.sql.legacy.parser.NestedType;

/**
* 搜索域
*
*
* @author ansj
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.opensearch.sql.legacy.utils.Util;

/**
* 搜索域
*
*
* @author ansj
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
package org.opensearch.sql.legacy.domain;

/**
* 排序规则
*
*
* @author ansj
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

public class SearchResult {
/**
* 查询结果
*
*/
private List<Map<String, Object>> results;

Expand Down Expand Up @@ -82,7 +82,7 @@ public SearchResult(SearchResponse resp, Select select) throws SqlParseException
}

/**
* 讲es的field域转换为你Object
*
*
* @param fields
* @return
Expand All @@ -101,7 +101,7 @@ private Map<String, Object> toFieldsMap(Map<String, DocumentField> fields) {
}

/**
* 讲es的field域转换为你Object
*
*
* @param fields
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


/**
* 将sql语句转换为select 对象
* sql select
*
* @author ansj
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
* 'type': integer
* },
* 'state': {
* 'type': text
* 'type': text
* }
* 'name': {
* 'type': text
* 'type': text
* 'fields': {
* 'keyword': {
* 'type': keyword,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import org.opensearch.sql.legacy.utils.Util;

/**
* 一些具有参数的一般在 select 函数.或者group by 函数
*
*
* @author ansj
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class AggMaker {
private Where where;

/**
* 分组查的聚合函数
*
*
* @param field
* @return
Expand Down Expand Up @@ -535,7 +535,7 @@ private ValuesSourceAggregationBuilder dateRange(MethodField field) {
}

/**
* 按照时间范围分组
*
*
* @param field
* @return
Expand Down Expand Up @@ -663,7 +663,7 @@ private HistogramAggregationBuilder histogram(MethodField field) throws SqlParse
}

/**
* 构建范围查询
*
*
* @param field
* @return
Expand Down Expand Up @@ -723,7 +723,7 @@ private ValuesSourceAggregationBuilder makeCountAgg(MethodField field) {
}

/**
* TOPHITS查询
* TOPHITS
*
* @param field
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected Maker(Boolean isQuery) {
}

/**
* 构建过滤条件
*
*
* @param cond
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public class QueryMaker extends Maker {

/**
* 将where条件构建成query
*
*
* @param where
* @return
Expand Down Expand Up @@ -58,7 +58,7 @@ private void explanWhere(BoolQueryBuilder boolQuery, Where where) throws SqlPars
}

/**
* 增加嵌套插
*
*
* @param boolQuery
* @param where
Expand Down