github.com/weaviate/weaviate@v1.24.6/entities/models/inverted_index_config.go (about) 1 // _ _ 2 // __ _____ __ ___ ___ __ _| |_ ___ 3 // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ 4 // \ V V / __/ (_| |\ V /| | (_| | || __/ 5 // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| 6 // 7 // Copyright © 2016 - 2024 Weaviate B.V. All rights reserved. 8 // 9 // CONTACT: hello@weaviate.io 10 // 11 12 // Code generated by go-swagger; DO NOT EDIT. 13 14 package models 15 16 // This file was generated by the swagger tool. 17 // Editing this file might prove futile when you re-run the swagger generate command 18 19 import ( 20 "context" 21 22 "github.com/go-openapi/errors" 23 "github.com/go-openapi/strfmt" 24 "github.com/go-openapi/swag" 25 ) 26 27 // InvertedIndexConfig Configure the inverted index built into Weaviate 28 // 29 // swagger:model InvertedIndexConfig 30 type InvertedIndexConfig struct { 31 32 // bm25 33 Bm25 *BM25Config `json:"bm25,omitempty"` 34 35 // Asynchronous index clean up happens every n seconds 36 CleanupIntervalSeconds int64 `json:"cleanupIntervalSeconds,omitempty"` 37 38 // Index each object with the null state 39 IndexNullState bool `json:"indexNullState,omitempty"` 40 41 // Index length of properties 42 IndexPropertyLength bool `json:"indexPropertyLength,omitempty"` 43 44 // Index each object by its internal timestamps 45 IndexTimestamps bool `json:"indexTimestamps,omitempty"` 46 47 // stopwords 48 Stopwords *StopwordConfig `json:"stopwords,omitempty"` 49 } 50 51 // Validate validates this inverted index config 52 func (m *InvertedIndexConfig) Validate(formats strfmt.Registry) error { 53 var res []error 54 55 if err := m.validateBm25(formats); err != nil { 56 res = append(res, err) 57 } 58 59 if err := m.validateStopwords(formats); err != nil { 60 res = append(res, err) 61 } 62 63 if len(res) > 0 { 64 return errors.CompositeValidationError(res...) 65 } 66 return nil 67 } 68 69 func (m *InvertedIndexConfig) validateBm25(formats strfmt.Registry) error { 70 if swag.IsZero(m.Bm25) { // not required 71 return nil 72 } 73 74 if m.Bm25 != nil { 75 if err := m.Bm25.Validate(formats); err != nil { 76 if ve, ok := err.(*errors.Validation); ok { 77 return ve.ValidateName("bm25") 78 } else if ce, ok := err.(*errors.CompositeError); ok { 79 return ce.ValidateName("bm25") 80 } 81 return err 82 } 83 } 84 85 return nil 86 } 87 88 func (m *InvertedIndexConfig) validateStopwords(formats strfmt.Registry) error { 89 if swag.IsZero(m.Stopwords) { // not required 90 return nil 91 } 92 93 if m.Stopwords != nil { 94 if err := m.Stopwords.Validate(formats); err != nil { 95 if ve, ok := err.(*errors.Validation); ok { 96 return ve.ValidateName("stopwords") 97 } else if ce, ok := err.(*errors.CompositeError); ok { 98 return ce.ValidateName("stopwords") 99 } 100 return err 101 } 102 } 103 104 return nil 105 } 106 107 // ContextValidate validate this inverted index config based on the context it is used 108 func (m *InvertedIndexConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 109 var res []error 110 111 if err := m.contextValidateBm25(ctx, formats); err != nil { 112 res = append(res, err) 113 } 114 115 if err := m.contextValidateStopwords(ctx, formats); err != nil { 116 res = append(res, err) 117 } 118 119 if len(res) > 0 { 120 return errors.CompositeValidationError(res...) 121 } 122 return nil 123 } 124 125 func (m *InvertedIndexConfig) contextValidateBm25(ctx context.Context, formats strfmt.Registry) error { 126 127 if m.Bm25 != nil { 128 if err := m.Bm25.ContextValidate(ctx, formats); err != nil { 129 if ve, ok := err.(*errors.Validation); ok { 130 return ve.ValidateName("bm25") 131 } else if ce, ok := err.(*errors.CompositeError); ok { 132 return ce.ValidateName("bm25") 133 } 134 return err 135 } 136 } 137 138 return nil 139 } 140 141 func (m *InvertedIndexConfig) contextValidateStopwords(ctx context.Context, formats strfmt.Registry) error { 142 143 if m.Stopwords != nil { 144 if err := m.Stopwords.ContextValidate(ctx, formats); err != nil { 145 if ve, ok := err.(*errors.Validation); ok { 146 return ve.ValidateName("stopwords") 147 } else if ce, ok := err.(*errors.CompositeError); ok { 148 return ce.ValidateName("stopwords") 149 } 150 return err 151 } 152 } 153 154 return nil 155 } 156 157 // MarshalBinary interface implementation 158 func (m *InvertedIndexConfig) MarshalBinary() ([]byte, error) { 159 if m == nil { 160 return nil, nil 161 } 162 return swag.WriteJSON(m) 163 } 164 165 // UnmarshalBinary interface implementation 166 func (m *InvertedIndexConfig) UnmarshalBinary(b []byte) error { 167 var res InvertedIndexConfig 168 if err := swag.ReadJSON(b, &res); err != nil { 169 return err 170 } 171 *m = res 172 return nil 173 }