Skip to content

Commit 61fcd2b

Browse files
authored
Update PrefixQuery, MatchQuery, ConstantScoreQuery and FuzzyQuery (opensearch-project#249)
* Update PrefixQuery, MatchQuery, ConstantScoreQuery and FuzzyQuery Signed-off-by: xil <fridalu66@gmail.com> * update Signed-off-by: xil <fridalu66@gmail.com> --------- Signed-off-by: xil <fridalu66@gmail.com>
1 parent 86579d8 commit 61fcd2b

2 files changed

Lines changed: 69 additions & 143 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66
### Added
77

88
### Changed
9+
- update `PrefixQuery`, `MatchQuery`, `ConstantScoreQuery` and `FuzzyQuery` ([#249](https://github.com/opensearch-project/opensearch-protobufs/pull/249))
910

1011
### Removed
1112

protos/schemas/common.proto

Lines changed: 68 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ message QueryContainer {
439439
WildcardQuery wildcard = 15;
440440

441441
// Use the match query for full-text search on a specific document field. If you run a match query on a text field, the match query analyzes the provided search string and returns documents that match any of the string's terms. If you run a match query on an exact-value field, it returns documents that match the exact value. The preferred way to search exact-value fields is to use a filter because, unlike a query, a filter is cached.
442-
MatchQueryTypeless match = 16;
442+
MatchQuery match = 16;
443443

444444
// The match_bool_prefix query analyzes the provided search string and creates a Boolean query from the string's terms. It uses every term except the last term as a whole word for matching. The last term is used as a prefix. The match_bool_prefix query returns documents that contain either the whole-word terms or terms that start with the prefix term, in any order.
445445
MatchBoolPrefixQuery match_bool_prefix = 17;
@@ -1315,89 +1315,37 @@ message KnnQueryRescore {
13151315
}
13161316
}
13171317

1318-
message MatchQueryTypeless {
1319-
string field = 1;
1320-
oneof match_query_typeless {
1321-
// Standard match query for performing a full-text search, including options for fuzzy matching.
1322-
MatchQuery match_query = 2;
1323-
// Simplified match query syntax by combining the <field> and query parameters
1324-
ObjectMap object_map = 3;
1325-
}
1326-
}
1327-
13281318
message MatchQuery {
1329-
1319+
// [required] Specifies the field against which to run a search query
1320+
string field = 1;
1321+
// [required] The query string to use for search.
1322+
FieldValue query = 2;
13301323
// [optional] Floating point number used to decrease or increase the relevance scores of the query. Boost values are relative to the default value of 1.0. A boost value between 0 and 1.0 decreases the relevance score. A value greater than 1.0 increases the relevance score.
1331-
optional float boost = 1;
1332-
1324+
optional float boost = 3;
13331325
// [optional] Query name for query tagging.
1334-
optional string x_name = 2;
1335-
1336-
// [optional]
1337-
// The analyzer used to tokenize the query string text.
1338-
// Default is the index-time analyzer specified for the default_field. If no analyzer is specified for the default_field, the analyzer is the default analyzer for the index.
1339-
string analyzer = 3;
1340-
1341-
// [optional]
1342-
// Specifies whether to create a match phrase query automatically for multi-term synonyms.
1343-
// For example, if you specify ba,batting average as synonyms and search for ba, OpenSearch searches for ba OR "batting average" (if this option is true) or ba OR (batting AND average) (if this option is false).
1344-
// Default is true.
1345-
bool auto_generate_synonyms_phrase_query = 4;
1346-
1347-
// [x-deprecated]
1348-
float cutoff_frequency = 5;
1349-
1350-
// [optional]
1351-
// The number of character edits (insertions, deletions, substitutions, or transpositions) that it takes to change one word to another when determining whether a term matched a value.
1352-
// For example, the distance between wined and wind is 1. Valid values are non-negative integers or AUTO.
1353-
// The default, AUTO, chooses a value based on the length of each term and is a good choice for most use cases.
1354-
Fuzziness fuzziness = 6;
1355-
1356-
// [optional]
1357-
// Determines how OpenSearch rewrites the query.
1358-
// Default is constant_score.
1359-
MultiTermQueryRewrite fuzzy_rewrite = 7;
1360-
// [optional]
1361-
// Setting fuzzy_transpositions to true (default) adds swaps of adjacent characters to the insert, delete, and substitute operations of the fuzziness option.
1362-
// For example, the distance between wind and wnid is 1 if fuzzy_transpositions is true (swap “n” and “i”) and 2 if it is false (delete “n”, insert “n”). If fuzzy_transpositions is false, rewind and wnid have the same distance (2) from wind, despite the more human-centric opinion that wnid is an obvious typo.
1363-
// The default(true) is a good choice for most use cases.
1364-
bool fuzzy_transpositions = 8;
1365-
1366-
// [optional]
1367-
// Setting lenient to true ignores data type mismatches between the query and the document field.
1368-
// For example, a query string of "8.2" could match a field of type float.
1369-
// Default is false.
1370-
bool lenient = 9;
1371-
1372-
// [optional]
1373-
// The maximum number of terms to which the query can expand. Fuzzy queries “expand to” a number of matching terms that are within the distance specified in fuzziness. Then OpenSearch tries to match those terms.
1374-
// Default is 50.
1375-
int32 max_expansions = 10;
1376-
1377-
// [optional]
1378-
// If the query string contains multiple search terms and you use the or operator, the number of terms that need to match for the document to be considered a match.
1379-
// For example, if minimum_should_match is 2, wind often rising does not match The Wind Rises. If minimum_should_match is 1, it matches.
1380-
MinimumShouldMatch minimum_should_match = 11;
1381-
1382-
// [optional]
1383-
// If the query string contains multiple search terms, whether all terms need to match (AND) or only one term needs to match (OR) for a document to be considered a match.
1384-
// Default is OR.
1385-
Operator operator = 12;
1386-
1387-
// [optional]
1388-
// The number of leading characters that are not considered in fuzziness.
1389-
// Default is 0.
1390-
int32 prefix_length = 13;
1391-
// [required]
1392-
// The query string to use for search.
1393-
FieldValue query = 14;
1394-
1395-
// [optional]
1396-
// In some cases, the analyzer removes all terms from a query string.
1397-
// For example, the stop analyzer removes all terms from the string an but this. In those cases, zero_terms_query specifies whether to match no documents (none) or all documents (all). Valid values are none and all.
1398-
// Default is none.
1399-
ZeroTermsQuery zero_terms_query = 15;
1400-
1326+
optional string x_name = 4;
1327+
// [optional] The analyzer used to tokenize the query string text. Default is the index-time analyzer specified for the default_field. If no analyzer is specified for the default_field, the analyzer is the default analyzer for the index.
1328+
optional string analyzer = 5;
1329+
// [optional] Specifies whether to create a match phrase query automatically for multi-term synonyms. For example, if you specify ba,batting average as synonyms and search for ba, OpenSearch searches for ba OR "batting average" (if this option is true) or ba OR (batting AND average) (if this option is false).
1330+
optional bool auto_generate_synonyms_phrase_query = 6;
1331+
// [optional] The number of character edits (insertions, deletions, substitutions, or transpositions) that it takes to change one word to another when determining whether a term matched a value. For example, the distance between wined and wind is 1. Valid values are non-negative integers or AUTO.
1332+
optional Fuzziness fuzziness = 7;
1333+
// [optional] Determines how OpenSearch rewrites the query. Default is constant_score.
1334+
optional MultiTermQueryRewrite fuzzy_rewrite = 8;
1335+
// [optional] Setting fuzzy_transpositions to true (default) adds swaps of adjacent characters to the insert, delete, and substitute operations of the fuzziness option. For example, the distance between wind and wnid is 1 if fuzzy_transpositions is true (swap “n” and “i”) and 2 if it is false (delete “n”, insert “n”). If fuzzy_transpositions is false, rewind and wnid have the same distance (2) from wind, despite the more human-centric opinion that wnid is an obvious typo. The default(true) is a good choice for most use cases.
1336+
optional bool fuzzy_transpositions = 9;
1337+
// [optional] Setting lenient to true ignores data type mismatches between the query and the document field. For example, a query string of "8.2" could match a field of type float. Default is false.
1338+
optional bool lenient = 10;
1339+
// [optional] The maximum number of terms to which the query can expand. Fuzzy queries “expand to” a number of matching terms that are within the distance specified in fuzziness. Then OpenSearch tries to match those terms. Default is 50.
1340+
optional int32 max_expansions = 11;
1341+
// [optional] If the query string contains multiple search terms and you use the or operator, the number of terms that need to match for the document to be considered a match. For example, if minimum_should_match is 2, wind often rising does not match The Wind Rises. If minimum_should_match is 1, it matches.
1342+
optional MinimumShouldMatch minimum_should_match = 12;
1343+
// [optional] If the query string contains multiple search terms, whether all terms need to match (AND) or only one term needs to match (OR) for a document to be considered a match. Default is OR.
1344+
optional Operator operator = 13;
1345+
// [optional] The number of leading characters that are not considered in fuzziness. Default is 0.
1346+
optional int32 prefix_length = 14;
1347+
// [optional] In some cases, the analyzer removes all terms from a query string. For example, the stop analyzer removes all terms from the string an but this. In those cases, zero_terms_query specifies whether to match no documents (none) or all documents (all). Valid values are none and all. Default is none.
1348+
optional ZeroTermsQuery zero_terms_query = 15;
14011349
}
14021350

14031351
message Query {
@@ -1465,15 +1413,12 @@ message BoostingQuery {
14651413
}
14661414

14671415
message ConstantScoreQuery {
1468-
1416+
// [required] The filter query that a document must match to be returned in the results.
1417+
QueryContainer filter = 1;
14691418
// [optional] Floating point number used to decrease or increase the relevance scores of the query. Boost values are relative to the default value of 1.0. A boost value between 0 and 1.0 decreases the relevance score. A value greater than 1.0 increases the relevance score.
1470-
optional float boost = 1;
1471-
1419+
optional float boost = 2;
14721420
// [optional] Query name for query tagging.
1473-
optional string x_name = 2;
1474-
1475-
QueryContainer filter = 3;
1476-
1421+
optional string x_name = 3;
14771422
}
14781423

14791424
message DisMaxQuery {
@@ -1738,26 +1683,16 @@ message IntervalsContainer {
17381683
message PrefixQuery {
17391684
// [required] Specifies the field against which to run a search query
17401685
string field = 1;
1741-
1686+
// [required] The term to search for in the field specified in <field>.
1687+
string value = 2;
17421688
// [optional] Floating point number used to decrease or increase the relevance scores of the query. Boost values are relative to the default value of 1.0. A boost value between 0 and 1.0 decreases the relevance score. A value greater than 1.0 increases the relevance score.
1743-
optional float boost = 2;
1744-
1689+
optional float boost = 3;
17451690
// [optional] Query name for query tagging.
1746-
optional string x_name = 3;
1747-
1748-
// [optional]
1749-
// Determines how OpenSearch rewrites the query.
1750-
// Default is constant_score.
1751-
MultiTermQueryRewrite rewrite = 4;
1752-
1753-
// [required]
1754-
// The term to search for in the field specified in <field>.
1755-
string value = 5;
1756-
1757-
// [optional]
1758-
// Allows ASCII case insensitive matching of the value with the indexed field values when set to `true`. Default is `false` which means the case sensitivity of matching depends on the underlying field's mapping.
1759-
bool case_insensitive = 6;
1760-
1691+
optional string x_name = 4;
1692+
// [optional] Determines how OpenSearch rewrites the query. Default is constant_score.
1693+
optional MultiTermQueryRewrite rewrite = 5;
1694+
// [optional] Allows ASCII case insensitive matching of the value with the indexed field values when set to `true`. Default is `false` which means the case sensitivity of matching depends on the underlying field's mapping.
1695+
optional bool case_insensitive = 6;
17611696
}
17621697

17631698
message TermsLookupFieldStringArrayMap {
@@ -2121,35 +2056,22 @@ message RegexpQuery {
21212056
message FuzzyQuery {
21222057
// [required] Specifies the field against which to run a search query
21232058
string field = 1;
2124-
2059+
// [required] Term you wish to find in the provided <field>.
2060+
FieldValue value = 2;
21252061
// [optional] Floating point number used to decrease or increase the relevance scores of the query. Boost values are relative to the default value of 1.0. A boost value between 0 and 1.0 decreases the relevance score. A value greater than 1.0 increases the relevance score.
2126-
optional float boost = 2;
2127-
2062+
optional float boost = 3;
21282063
// [optional] Query name for query tagging.
2129-
optional string x_name = 3;
2130-
2131-
// [optional]
2132-
// The maximum number of terms to which the query can expand. Fuzzy queries "expand to" a number of matching terms that are within the distance specified in fuzziness. Then OpenSearch tries to match those terms. Default is 50.
2133-
int32 max_expansions = 4;
2134-
2135-
// [optional]
2136-
// The number of leading characters that are not considered in fuzziness. Default is 0.
2137-
int32 prefix_length = 5;
2138-
2139-
// [optional]
2140-
// Determines how OpenSearch rewrites the query.
2141-
// Default is constant_score.
2142-
MultiTermQueryRewrite rewrite = 6;
2143-
// [optional]
2144-
// Specifies whether to allow transpositions of two adjacent characters (ab to ba) as edits. Default is true.
2145-
bool transpositions = 7;
2146-
// [optional]
2147-
// The number of character edits (insert, delete, substitute) needed to change one word to another when determining whether a term matched a value.
2148-
Fuzziness fuzziness = 8;
2149-
2150-
// [required]
2151-
// Term you wish to find in the provided <field>.
2152-
FieldValue value = 9;
2064+
optional string x_name = 4;
2065+
// [optional] The maximum number of terms to which the query can expand. Fuzzy queries "expand to" a number of matching terms that are within the distance specified in fuzziness. Then OpenSearch tries to match those terms. Default is 50.
2066+
optional int32 max_expansions = 5;
2067+
// [optional] The number of leading characters that are not considered in fuzziness. Default is 0.
2068+
optional int32 prefix_length = 6;
2069+
// [optional] Determines how OpenSearch rewrites the query. Default is constant_score.
2070+
optional MultiTermQueryRewrite rewrite = 7;
2071+
// [optional] Specifies whether to allow transpositions of two adjacent characters (ab to ba) as edits. Default is true.
2072+
optional bool transpositions = 8;
2073+
// [optional] The number of character edits (insert, delete, substitute) needed to change one word to another when determining whether a term matched a value.
2074+
optional Fuzziness fuzziness = 9;
21532075
}
21542076

21552077
message Fuzziness{
@@ -2387,36 +2309,39 @@ message MultiMatchQuery {
23872309
// [optional] Determines how OpenSearch rewrites the query. Valid values are constant_score, scoring_boolean, constant_score_boolean, top_terms_N, top_terms_boost_N, and top_terms_blended_freqs_N. If the fuzziness parameter is not 0, the query uses a fuzzy_rewrite method of top_terms_blended_freqs_${max_expansions} by default. Default is constant_score.
23882310
optional string fuzzy_rewrite = 7;
23892311

2312+
// [optional] The number of character edits (insert, delete, substitute) that it takes to change one word to another when determining whether a term matched a value.
2313+
optional Fuzziness fuzziness = 8;
2314+
23902315
// [optional] Setting fuzzy_transpositions to true (default) adds swaps of adjacent characters to the insert, delete, and substitute operations of the fuzziness option. For example, the distance between wind and wnid is 1 if fuzzy_transpositions is true (swap “n” and “i”) and 2 if it is false (delete “n”, insert “n”). If fuzzy_transpositions is false, rewind and wnid have the same distance (2) from wind, despite the more human-centric opinion that wnid is an obvious typo. The default is a good choice for most use cases.
2391-
optional bool fuzzy_transpositions = 8;
2316+
optional bool fuzzy_transpositions = 9;
23922317

23932318
// [optional] Setting lenient to true ignores data type mismatches between the query and the document field. For example, a query string of "8.2" could match a field of type float. Default is false.
2394-
optional bool lenient = 9;
2319+
optional bool lenient = 10;
23952320

23962321
// [optional] The maximum number of terms to which the query can expand. Fuzzy queries “expand to” a number of matching terms that are within the distance specified in fuzziness. Then OpenSearch tries to match those terms. Default is 50.
2397-
optional int32 max_expansions = 10;
2322+
optional int32 max_expansions = 11;
23982323

23992324
// [optional] If the query string contains multiple search terms and you use the or operator, the number of terms that need to match for the document to be considered a match. For example, if minimum_should_match is 2, wind often rising does not match The Wind Rises. If minimum_should_match is 1, it matches. For details, see Minimum should match.
24002325

2401-
optional MinimumShouldMatch minimum_should_match = 11;
2326+
optional MinimumShouldMatch minimum_should_match = 12;
24022327

24032328
// [optional] If the query string contains multiple search terms, whether all terms need to match (AND) or only one term needs to match (OR) for a document to be considered a match. Valid values are: 1) OR: The string to be is interpreted as to OR be. 2) AND: The string to be is interpreted as to AND be. Default is OR.
2404-
optional Operator operator = 12;
2329+
optional Operator operator = 13;
24052330

24062331
// [optional] The number of leading characters that are not considered in fuzziness. Default is 0.
2407-
optional int32 prefix_length = 13;
2332+
optional int32 prefix_length = 14;
24082333

24092334
// [optional] Controls the degree to which words in a query can be misordered and still be considered a match. From the Lucene documentation: “The number of other words permitted between words in query phrase. For example, to switch the order of two words requires two moves (the first move places the words atop one another), so to permit reorderings of phrases, the slop must be at least two. A value of zero requires an exact match.” Supported for phrase and phrase_prefix query types.
2410-
optional int32 slop = 14;
2335+
optional int32 slop = 15;
24112336

24122337
// [optional] A factor between 0 and 1.0 that is used to give more weight to documents that match multiple query clauses. For more information, see The tie_breaker parameter`.
2413-
optional float tie_breaker = 15;
2338+
optional float tie_breaker = 16;
24142339

24152340
// [optional] The multi-match query type. Valid values are best_fields, most_fields, cross_fields, phrase, phrase_prefix, bool_prefix. Default is best_fields.
2416-
optional TextQueryType type = 16;
2341+
optional TextQueryType type = 17;
24172342

24182343
// [optional] In some cases, the analyzer removes all terms from a query string. For example, the stop analyzer removes all terms from the string an but this. In those cases, zero_terms_query specifies whether to match no documents (none) or all documents (all). Valid values are none and all. Default is none.
2419-
optional ZeroTermsQuery zero_terms_query = 17;
2344+
optional ZeroTermsQuery zero_terms_query = 18;
24202345
}
24212346

24222347
message FieldValueFactorScoreFunction {

0 commit comments

Comments
 (0)