Skip to content
Snippets Groups Projects
Commit 3f8beba2 authored by Francé Wilke's avatar Francé Wilke
Browse files

Update OpenSearch query fields

parent e61cc9ce
No related branches found
No related tags found
No related merge requests found
......@@ -39,10 +39,15 @@ type SearchRequestBody struct {
Timeout string `json:"timeout,omitempty"` // timeout for search
}
// Query NOTE: We are only using bool filter queries, to be able to always do the correct sorting, not based on the relevancy score
// https://opensearch.org/docs/latest/opensearch/query-dsl/bool/
type Query struct {
Match *QueryMatch `json:"match,omitempty" doc:"<field>:<value>"`
Term *QueryTerm `json:"term,omitempty"`
Range *QueryRange `json:"range,omitempty"`
MultiMatch *QueryMultiMatch `json:"multi_match,omitempty"`
Bool *QueryBool `json:"bool,omitempty"`
QueryString *QueryString `json:"query_string,omitempty"`
SimpleQueryString *QueryString `json:"simple_query_string,omitempty"`
}
type QueryBool struct {
......@@ -50,6 +55,7 @@ type QueryBool struct {
Filter []FilterQuery `json:"filter,omitempty"` // List of things that must appear in matching documents. However, unlike must the score of the query will be ignored. Filter clauses are executed in filter context, meaning that scoring is ignored and clauses are considered for caching
Should []Query `json:"should,omitempty"` // List of things that should appear in the matching document.
MustNot []FilterQuery `json:"must_not,omitempty"` // List of things that must not appear in the matching documents. Clauses are executed in filter context meaning that scoring is ignored and clauses are considered for caching. Because scoring is ignored, a score of 0 for all documents is returned
MinimumShouldMatch int64 `json:"minimum_should_match"`
}
type FilterQuery struct {
......@@ -60,9 +66,17 @@ type FilterQuery struct {
MultiMatch *QueryMultiMatch `json:"multi_match,omitempty"`
Bool *QueryBool `json:"bool,omitempty"`
QueryString *QueryString `json:"query_string,omitempty"`
SimpleQueryString *QueryString `json:"simple_query_string,omitempty"`
Wildcard *QueryWildcard `json:"wildcard,omitempty"` // https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html
}
type QueryValue struct {
Query string `json:"query"`
Operator string `json:"operator,omitempty"` // defaults to "or", accepted values: or|and
Fuzziness string `json:"fuzziness,omitempty"` // https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#fuzziness
ZeroTermsQuery string `json:"zero_terms_query,omitempty"`
}
type QueryMatch map[string]string
type QueryTerm map[string]string
......@@ -73,17 +87,20 @@ type QueryMultiMatch struct {
Query string `json:"query"` // Full value match search in selected fields
Fields []string `json:"fields,omitempty" doc:"List of fields"`
Type QueryMultiMatchType `json:"type,omitempty"`
Operator string `json:"operator,omitempty"`
}
type QueryMultiMatchType string
const (
QueryMultiMatchTypePhrase QueryMultiMatchType = "phrase"
QueryMultiMatchTypeCrossFields QueryMultiMatchType = "cross_fields"
)
type QueryString struct {
Query string `json:"query"` // Text search with partial matches, using asterisk for optional or question mark for required wildcards before and/or after text
Fields []string `json:"fields,omitempty" doc:"List of fields"`
DefaultOperator string `json:"default_operator,omitempty"`
}
type QueryRange map[string]QueryExpr
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment