Skip to content

Commit

Permalink
feat: add text options
Browse files Browse the repository at this point in the history
  • Loading branch information
niki committed Dec 8, 2022
1 parent ea1fdb9 commit 26b3333
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 9 deletions.
36 changes: 34 additions & 2 deletions src/Builders/Text/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Boost,
CaseInsensitive,
DefaultField,
Fields,
Fuzziness,
FuzzyPrefixLength,
FuzzyTranspositions,
Expand Down Expand Up @@ -41,6 +42,7 @@ export interface TextSchema extends Schema {
};

opts?: Fuzziness &
Boost &
MaxExpansions &
PrefixLength &
MinimumShouldMatch &
Expand All @@ -57,7 +59,37 @@ export interface TextSchema extends Schema {
params: {
query: string;
};
opts?: ZeroTermsQuery | Analyzer;
opts?: ZeroTermsQuery | (Analyzer & Boost);
};
/**
* The simple_query_string query supports the following operators:
*
* + signifies AND operation
* | signifies OR operation
* - negates a single token
* " wraps a number of tokens to signify a phrase for searching
* * at the end of a term signifies a prefix query
* ( and ) signify precedence
* ~N after a word signifies edit distance (fuzziness)
* ~N after a phrase signifies slop amount
* To use one of these characters literally, escape it with a preceding backslash (\).
*/
simple_query_string: {
params: {
query: string;
};
opts?: AllowLeadingWildcard &
AutoGenerateSynonymsPhraseQuery &
Boost &
Fields &
Operator &
Analyzer &
DefaultField &
MinimumShouldMatch &
AnalyzeWildcard &
FuzzyTranspositions &
FuzzyPrefixLength &
Lenient;
};
query_string: {
params: {
Expand All @@ -81,7 +113,7 @@ export interface TextSchema extends Schema {
query: string;
fields: string[];
};
opts?: Operator & AutoGenerateSynonymsPhraseQuery & MinimumShouldMatch & ZeroTermsQuery;
opts?: Operator & AutoGenerateSynonymsPhraseQuery & MinimumShouldMatch & ZeroTermsQuery & Boost;
};
wildcard: {
params: {
Expand Down
22 changes: 15 additions & 7 deletions src/Types/QueryOptions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,26 @@ export interface Rewrite {
* You can use this method to avoid exceeding the clause limit in the indices.query.bool.max_clause_count setting.
*/
rewrite?:
| 'constant_score'
| 'constant_score_boolean'
| 'scoring_boolean'
| 'top_terms_blended_freqs_N'
| 'top_terms_boost_N'
| 'top_terms_N';
| 'constant_score'
| 'constant_score_boolean'
| 'scoring_boolean'
| 'top_terms_blended_freqs_N'
| 'top_terms_boost_N'
| 'top_terms_N';
}


export interface CaseInsensitive {
/**
* Allows case insensitive matching of the pattern 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.
*/
case_insensitive?: boolean;
}

export interface Fields {
/**
* (Optional, array of strings) Array of fields you wish to search.
* This field accepts wildcard expressions. You also can boost relevance scores for matches to particular fields using a caret (^) notation. See Wildcards and per-field boosts in the fields parameter for examples.
* Defaults to the index.query.default_field index setting, which has a default value of *. The * value extracts all fields that are eligible to term queries and filters the metadata fields. All extracted fields are then combined to build a query if no prefix is specified.
*/
fields?: string[];
}

0 comments on commit 26b3333

Please sign in to comment.