Skip to content
Snippets Groups Projects
Select Git revision
  • 3a2e23b80410e65d8a6a27282fcbca1bd74d5f13
  • main default protected
  • trading_hours
  • refactor_trading_hours
  • audit_cleaning_cater_for_non_struct_fields
  • remove-info-logs
  • sl-refactor
  • 18-use-scan-for-param-values
  • 17-order-search-results
  • 4-simplify-framework-2
  • 1-http-error
  • v1.297.0
  • v1.296.0
  • v1.295.0
  • v1.294.0
  • v1.293.0
  • v1.292.0
  • v1.291.0
  • v1.290.0
  • v1.289.0
  • v1.288.0
  • v1.287.0
  • v1.286.0
  • v1.285.0
  • v1.284.0
  • v1.283.0
  • v1.282.0
  • v1.281.0
  • v1.280.0
  • v1.279.0
  • v1.278.0
31 results

opensearch_types.go

Blame
  • opensearch_types.go 6.46 KiB
    package search
    
    import "time"
    
    //Mapping configures an index in OpenSearch
    type Settings struct {
    	Index *SettingsIndex `json:"index,omitempty"`
    }
    
    type SettingsIndex struct {
    	NumberOfShards   int `json:"number_of_shards,omitempty"`
    	NumberOfReplicas int `json:"number_of_replicas,omitempty"`
    }
    
    type Mappings struct {
    	Properties map[string]MappingProperty `json:"properties,omitempty"`
    }
    
    type MappingProperty struct {
    	Type       string                            `json:"type,omitempty"` //empty for sub-structs described with properties
    	Enabled    bool                              `json:"enabled,omitempty"`
    	Fields     map[string]MappingFieldProperties `json:"fields,omitempty"`
    	Properties map[string]MappingProperty        `json:"properties,omitempty"`
    	//Index      bool                              `json:"index,omitempty"` //set true to make text field searchable
    }
    
    type MappingFieldProperties struct {
    	Keyword *MappingKeyword `json:"keyword"`
    }
    
    type MappingKeyword struct {
    	Type        string `json:"type"`         //="keyword"
    	IgnoreAbove int    `json:"ignore_above"` //e.g. 256
    }
    
    type SearchRequestBody struct {
    	Size  int64 `json:"size,omitempty"`
    	Query Query `json:"query"`
    }
    
    type Query struct {
    	//one of:
    	Match       *QueryNameValue  `json:"match,omitempty" doc:"<field>:<value>"`
    	Term        *QueryNameValue  `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"`
    }
    
    type QueryMultiMatch struct {
    	Query  string   `json:"query" doc:"Full value match search in selected fields"`
    	Fields []string `json:"fields,omitempty" doc:"List of fields"`
    }
    
    type QueryString struct {
    	Query string `json:"query" doc:"Text search with partial matches, using asterisk for optional or question mark for required wildcards before and/or after text"`
    }
    
    //https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html
    type QueryBool struct {
    	Must    []Query `json:"must,omitempty" docs:"List of things that must appear in matching documents and will contribute to the score."`
    	Filter  []Query `json:"filter,omitempty" doc:"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" doc:"List of things that should appear in the matching document."`
    	MustNot []Query `json:"must_not,omitempty" doc:"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."`
    }
    
    //<name>:<value> can be shorthanded to just a text value "...", but for sake of go type def, we always use an object meaning the same, allowing more options
    //https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html#query-dsl-match-query-short-ex
    type QueryNameValue map[string]QueryValue