github.com/weaviate/weaviate@v1.24.6/adapters/repos/db/aggregations_fixtures_for_test.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 //go:build integrationTest 13 // +build integrationTest 14 15 package db 16 17 import ( 18 "fmt" 19 20 "github.com/go-openapi/strfmt" 21 "github.com/weaviate/weaviate/entities/models" 22 "github.com/weaviate/weaviate/entities/schema" 23 enthnsw "github.com/weaviate/weaviate/entities/vectorindex/hnsw" 24 ) 25 26 var productClass = &models.Class{ 27 Class: "AggregationsTestProduct", 28 VectorIndexConfig: enthnsw.NewDefaultUserConfig(), 29 InvertedIndexConfig: invertedConfig(), 30 Properties: []*models.Property{ 31 { 32 Name: "name", 33 DataType: schema.DataTypeText.PropString(), 34 Tokenization: models.PropertyTokenizationWhitespace, 35 }, 36 }, 37 } 38 39 var companyClass = &models.Class{ 40 Class: "AggregationsTestCompany", 41 VectorIndexConfig: enthnsw.NewDefaultUserConfig(), 42 InvertedIndexConfig: invertedConfig(), 43 Properties: []*models.Property{ 44 { 45 Name: "sector", 46 DataType: schema.DataTypeText.PropString(), 47 Tokenization: models.PropertyTokenizationWhitespace, 48 }, 49 { 50 Name: "location", 51 DataType: []string{"text"}, 52 Tokenization: "word", 53 }, 54 { 55 Name: "dividendYield", 56 DataType: []string{"number"}, 57 }, 58 { 59 Name: "price", 60 DataType: []string{"int"}, // unrealistic for this to be an int, but 61 // we've already tested another number prop ;-) 62 }, 63 { 64 Name: "listedInIndex", 65 DataType: []string{"boolean"}, 66 }, 67 { 68 Name: "makesProduct", 69 DataType: []string{"AggregationsTestProduct"}, 70 }, 71 }, 72 } 73 74 var arrayTypesClass = &models.Class{ 75 Class: "AggregationsTestArrayTypes", 76 VectorIndexConfig: enthnsw.NewDefaultUserConfig(), 77 InvertedIndexConfig: invertedConfig(), 78 Properties: []*models.Property{ 79 { 80 Name: "strings", 81 DataType: schema.DataTypeTextArray.PropString(), 82 Tokenization: models.PropertyTokenizationWhitespace, 83 }, 84 { 85 Name: "numbers", 86 DataType: []string{"number[]"}, 87 }, 88 }, 89 } 90 91 var customerClass = &models.Class{ 92 Class: "AggregationsTestCustomer", 93 VectorIndexConfig: enthnsw.NewDefaultUserConfig(), 94 InvertedIndexConfig: invertedConfig(), 95 Properties: []*models.Property{ 96 { 97 Name: "internalId", 98 DataType: schema.DataTypeText.PropString(), 99 Tokenization: models.PropertyTokenizationWhitespace, 100 }, 101 { 102 Name: "timeArrived", 103 DataType: []string{"date"}, 104 }, 105 { 106 Name: "countryOfOrigin", 107 DataType: schema.DataTypeText.PropString(), 108 Tokenization: models.PropertyTokenizationWhitespace, 109 }, 110 }, 111 } 112 113 var products = []map[string]interface{}{ 114 { 115 "name": "Superbread", 116 }, 117 } 118 119 var productsIds = []strfmt.UUID{ 120 "1295c052-263d-4aae-99dd-920c5a370d06", 121 } 122 123 // company objects are imported not just once each, but each is imported 124 // importFactor times. This should even out shard imbalances a bit better. 125 var importFactor = 10 126 127 var companies = []map[string]interface{}{ 128 { 129 "sector": "Financials", 130 "location": "New York", 131 "dividendYield": 1.3, 132 "price": int64(150), 133 "listedInIndex": true, 134 }, 135 { 136 "sector": "Financials", 137 "location": "New York", 138 "dividendYield": 4.0, 139 "price": int64(600), 140 "listedInIndex": true, 141 }, 142 { 143 "sector": "Financials", 144 "location": "San Francisco", 145 "dividendYield": 1.3, 146 "price": int64(47), 147 "listedInIndex": true, 148 }, 149 { 150 "sector": "Food", 151 "location": "Atlanta", 152 "dividendYield": 1.3, 153 "price": int64(160), 154 "listedInIndex": true, 155 }, 156 { 157 "sector": "Food", 158 "location": "Atlanta", 159 "dividendYield": 2.0, 160 "price": int64(70), 161 "listedInIndex": true, 162 }, 163 { 164 "sector": "Food", 165 "location": "Los Angeles", 166 "dividendYield": 0.0, 167 "price": int64(800), 168 "listedInIndex": false, 169 }, 170 { 171 "sector": "Food", 172 "location": "Detroit", 173 "dividendYield": 8.0, 174 "price": int64(10), 175 "listedInIndex": true, 176 "makesProduct": models.MultipleRef{ 177 &models.SingleRef{ 178 Beacon: strfmt.URI(fmt.Sprintf("weaviate://localhost/%s", productsIds[0])), 179 }, 180 }, 181 }, 182 { 183 "sector": "Food", 184 "location": "San Francisco", 185 "dividendYield": 0.0, 186 "price": int64(200), 187 "listedInIndex": true, 188 }, 189 { 190 "sector": "Food", 191 "location": "New York", 192 "dividendYield": 1.1, 193 "price": int64(70), 194 "listedInIndex": true, 195 }, 196 } 197 198 // Use fixed ids to make the test deterministic. The length of this must match 199 // the len(companies)*importFactor These are somewhat carefully arranged to 200 // make sure that we prevent the flakiness that was described in 201 // https://github.com/weaviate/weaviate/issues/1884 202 var companyIDs = []strfmt.UUID{ 203 "9ee7640f-b4fc-45f1-b502-580e79062c99", 204 "f745485b-f6ef-4785-bd54-574cc4923899", 205 "0109289b-88d5-48d5-9f3e-1e5edb7e56c1", 206 "ce7c2930-2af8-44ec-8789-eceee930c37d", 207 "3f7b1ea2-e6e8-49d4-b44c-30916dbab43a", 208 "ed3b417f-2b7e-456e-9599-744541728950", 209 "175c22ea-190a-4b8c-9fd0-fbffa5b1b8be", 210 "e0165a52-f504-47d3-b947-b3829eca3563", 211 "19ede86d-86d6-4ea8-9ae3-a10a1607b433", 212 "034c8d0b-50d7-4753-811c-abbfad44c653", 213 "99564c6b-8529-4f56-9c3f-f808385f034a", 214 "adc362ea-105d-4544-b981-dedc100d25b9", 215 "21e1dc5b-49e1-4d35-acb4-be969e4e3a30", 216 "cb278f74-c632-4460-ae78-2c2c140c0e12", 217 "4d552f33-552a-41aa-b732-da3d0f708b79", 218 "faf509ad-bdb6-4aa1-ae9f-e9f410210419", 219 "59992957-65cf-44bd-8894-d8b2364f080f", 220 "529217e6-9ec3-41c6-bb6d-13e8f380960a", 221 "058ec709-782d-4b58-a38f-01593d97f181", 222 "d027204b-805c-46ae-8a61-7d35f9c6eaba", 223 "0fce8fea-6ca7-4c80-bc81-55d26e1fd0bd", 224 "1f4832c7-d164-441e-b197-aa193b4d128f", 225 "15ad080d-49fc-4b8b-b621-d47f98aa5fdb", 226 "cb40966d-963d-4283-94be-7da5de70992e", 227 "6516f7d9-c505-40b3-94de-a42498eea22d", 228 "9dbcbd08-1067-4bec-84a4-4f3ad19286d3", 229 "dabd68eb-27b9-462b-a271-300058c5798b", 230 "9a33f431-cb28-49ae-b9c9-94e97f752a2a", 231 "4aa27f5c-f475-444b-9279-94b8a5da14c9", 232 "e71cf490-9a59-4475-80c1-b6c872f3b33c", 233 "a8e7e8bf-237b-4d95-99be-6af332bdf942", 234 "08c239c3-e19e-4d88-b0fd-861853dd5e36", 235 "0209ab7c-2573-4d66-9917-942450e02750", 236 "0a71a4da-d9c9-423e-8dd8-ebd5c2a86a2d", 237 "f312aa16-992e-4505-82aa-04da30ea5fe3", 238 "5b9f9449-1336-44e3-88f9-979f3c752bd7", 239 "dcec96ab-9377-4272-8a48-07568c4ed533", 240 "3f28352d-9960-4251-aa05-ce4c612e1ab7", 241 "4a08101e-f280-41f9-9e7b-fe12d7216c3c", 242 "0dd7383f-c71b-483c-9253-e180f8763405", 243 "cfb83c85-cf8f-49da-952f-5bd954b7e616", 244 "b016bb0f-9e07-4d40-9878-a6bbaa67d866", 245 "311d7423-552b-4d4c-b7b6-cdcd15e1009b", 246 "895877d6-9cf3-4d79-989e-4d89f6867e09", 247 "92bdb79c-6870-44e2-ab71-c3137c78cb2d", 248 "b16cb9c4-5a6c-444c-bbf5-7b0ef2c1ac12", 249 "efb09d97-09c4-4976-aa14-abfd520c114d", 250 "6431f59d-9ed8-4963-9ed7-7336a5795d8b", 251 "1ad26844-6f6b-4007-834d-09ec8668fe7b", 252 "6d83b349-6ec8-49bb-b438-7f29a16216d3", 253 "68156360-1cae-406e-8baf-177178f0815e", 254 "3c726a50-ec82-4828-8967-f704477dfef7", 255 "46f702b2-e1c3-4e4a-868e-10ec1e260c75", 256 "51ff679a-87d8-4bef-830d-327e7b4c8f8e", 257 "aea6fc5c-8eb0-4cd7-8cfe-1285239d16bd", 258 "b70bbf68-5ebc-4315-9819-deb65b241f3f", 259 "6069853f-8822-434f-9d59-c881800e0a27", 260 "9a287ef6-6920-4d01-a44a-7561d2fb627d", 261 "fa057d95-9ba8-418a-aeb2-fe4b2acd31b0", 262 "9b0fb28f-21f1-4df1-a55b-67bf6be79911", 263 "044403fb-25f6-461f-ad92-8f9533908070", 264 "35d09151-c469-4901-8092-2114060cb86b", 265 "85884aa2-5d0b-4dff-80f6-8ca7cbab9fef", 266 "bd36a31a-f14e-4040-ad11-0ec5b6217b6a", 267 "fe20620f-c612-4712-9475-d4cfc59e8bba", 268 "09ba0773-e81d-4cb9-968a-552e1cbaf143", 269 "7a7378a5-2d05-4457-b2d4-1fe068535167", 270 "6867d1e5-2d30-4f91-90d2-2b453ffd5cd5", 271 "2fef1b16-3dd1-4ad5-bc55-cf8f9783b40c", 272 "0590f51b-7c9f-41a0-b81e-cdbc205ebdd9", 273 "7ed55b94-86d5-440a-9a8a-5f83dabcb69b", 274 "2daca92a-c8a6-4ab4-a528-3d99ce6f72f2", 275 "24187e67-947d-436d-ae7f-d20b03874b56", 276 "864ff42d-00fe-44a8-8163-8af459dc1c0c", 277 "0c2cc9a5-089a-4d10-882a-837c154117ea", 278 "fb256f18-e812-4355-b41a-c69d933f2a61", 279 "b631c4df-8229-43c0-9e5e-189c5d666ac2", 280 "8da03018-3272-4bd3-987c-1dd1e807bc1d", 281 "bf736b76-fccc-4d1b-8d9f-2e78fdb0d972", 282 "1fc9dffc-da23-4b99-8330-44c5598919db", 283 "1ed74402-bc81-4245-8275-c2862a4d6a86", 284 "6a91adb4-23df-43bd-9564-f97e76382a52", 285 "d1661202-c568-4032-8ec6-99fe4238de84", 286 "e4b4186d-f02e-47d7-8214-d3854ee475fd", 287 "664e6157-bfcc-4513-8f04-c095d3ecb2d5", 288 "b3b9951f-0867-453d-bf20-9f22bdb5a38b", 289 "52adfeae-ab75-4250-ae45-61af9e231e86", 290 "e994c378-ac0b-4f08-bd56-462990be36dd", 291 "a012f65a-28a7-4005-95bb-f55783bcdda0", 292 "0cbc7fb6-843c-4aad-b540-e37ddb7c84c6", 293 } 294 295 var arrayTypes = []map[string]interface{}{ 296 { 297 "strings": []string{"a", "b", "c"}, 298 "numbers": []float64{1.0, 2.0, 2.0, 3.0, 3.0}, 299 }, 300 { 301 "strings": []string{"a"}, 302 "numbers": []float64{1.0, 2.0}, 303 }, 304 } 305 306 var customers = []map[string]interface{}{ 307 { 308 "internalId": "customer 1", 309 "countryOfOrigin": "US", 310 "timeArrived": mustStringToTime("2022-06-16T17:30:17.231346Z"), 311 "isNewCustomer": false, 312 }, 313 { 314 "internalId": "customer 2", 315 "countryOfOrigin": "US", 316 "timeArrived": mustStringToTime("2022-06-16T17:30:17.231346Z"), 317 "isNewCustomer": false, 318 }, 319 { 320 "internalId": "customer 3", 321 "countryOfOrigin": "US", 322 "timeArrived": mustStringToTime("2022-06-16T17:30:17.231346Z"), 323 "isNewCustomer": false, 324 }, 325 { 326 "internalId": "customer 4", 327 "countryOfOrigin": "US", 328 "timeArrived": mustStringToTime("2022-06-16T17:30:20.123546Z"), 329 "isNewCustomer": true, 330 }, 331 { 332 "internalId": "customer 5", 333 "countryOfOrigin": "US", 334 "timeArrived": mustStringToTime("2022-06-16T17:30:20.123546Z"), 335 "isNewCustomer": true, 336 }, 337 { 338 "internalId": "customer 6", 339 "countryOfOrigin": "US", 340 "timeArrived": mustStringToTime("2022-06-16T17:30:22.112435Z"), 341 "isNewCustomer": false, 342 }, 343 { 344 "internalId": "customer 7", 345 "countryOfOrigin": "US", 346 "timeArrived": mustStringToTime("2022-06-16T17:30:23.754272Z"), 347 "isNewCustomer": false, 348 }, 349 { 350 "internalId": "customer 8", 351 "countryOfOrigin": "US", 352 "timeArrived": mustStringToTime("2022-06-16T17:30:24.325698Z"), 353 "isNewCustomer": true, 354 }, 355 { 356 "internalId": "customer 9", 357 "countryOfOrigin": "US", 358 "timeArrived": mustStringToTime("2022-06-16T17:30:25.524536Z"), 359 "isNewCustomer": false, 360 }, 361 { 362 "internalId": "customer 10", 363 "countryOfOrigin": "US", 364 "timeArrived": mustStringToTime("2022-06-16T17:30:26.451235Z"), 365 "isNewCustomer": true, 366 }, 367 }