|
1 | 1 | //
|
2 | 2 | // DISCLAIMER
|
3 | 3 | //
|
4 |
| -// Copyright 2017 ArangoDB GmbH, Cologne, Germany |
| 4 | +// Copyright 2017-2024 ArangoDB GmbH, Cologne, Germany |
5 | 5 | //
|
6 | 6 | // Licensed under the Apache License, Version 2.0 (the "License");
|
7 | 7 | // you may not use this file except in compliance with the License.
|
|
17 | 17 | //
|
18 | 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany
|
19 | 19 | //
|
20 |
| -// Author Ewout Prangsma |
21 |
| -// |
22 | 20 |
|
23 | 21 | package driver
|
24 | 22 |
|
@@ -50,6 +48,7 @@ type indexData struct {
|
50 | 48 | LegacyPolygons *bool `json:"legacyPolygons,omitempty"`
|
51 | 49 | CacheEnabled *bool `json:"cacheEnabled,omitempty"`
|
52 | 50 | StoredValues []string `json:"storedValues,omitempty"`
|
| 51 | + PrefixFields []string `json:"prefixFields,omitempty"` |
53 | 52 |
|
54 | 53 | ArangoError `json:",inline"`
|
55 | 54 | }
|
@@ -320,6 +319,49 @@ func (c *collection) EnsureZKDIndex(ctx context.Context, fields []string, option
|
320 | 319 | return idx, created, nil
|
321 | 320 | }
|
322 | 321 |
|
| 322 | +func (c *collection) EnsureMDIIndex(ctx context.Context, fields []string, options *EnsureMDIIndexOptions) (Index, bool, error) { |
| 323 | + input := indexData{ |
| 324 | + Type: string(MDIIndex), |
| 325 | + Fields: fields, |
| 326 | + // fieldValueTypes is required and the only allowed value is "double". Future extensions of the index will allow other types. |
| 327 | + FieldValueTypes: "double", |
| 328 | + } |
| 329 | + if options != nil { |
| 330 | + input.InBackground = &options.InBackground |
| 331 | + input.Name = options.Name |
| 332 | + input.Unique = &options.Unique |
| 333 | + input.Sparse = &options.Sparse |
| 334 | + input.StoredValues = options.StoredValues |
| 335 | + } |
| 336 | + idx, created, err := c.ensureIndex(ctx, input) |
| 337 | + if err != nil { |
| 338 | + return nil, false, WithStack(err) |
| 339 | + } |
| 340 | + return idx, created, nil |
| 341 | +} |
| 342 | + |
| 343 | +func (c *collection) EnsureMDIPrefixedIndex(ctx context.Context, fields []string, options *EnsureMDIPrefixedIndexOptions) (Index, bool, error) { |
| 344 | + input := indexData{ |
| 345 | + Type: string(MDIPrefixedIndex), |
| 346 | + Fields: fields, |
| 347 | + // fieldValueTypes is required and the only allowed value is "double". Future extensions of the index will allow other types. |
| 348 | + FieldValueTypes: "double", |
| 349 | + } |
| 350 | + if options != nil { |
| 351 | + input.InBackground = &options.InBackground |
| 352 | + input.Name = options.Name |
| 353 | + input.Unique = &options.Unique |
| 354 | + input.Sparse = &options.Sparse |
| 355 | + input.StoredValues = options.StoredValues |
| 356 | + input.PrefixFields = options.PrefixFields |
| 357 | + } |
| 358 | + idx, created, err := c.ensureIndex(ctx, input) |
| 359 | + if err != nil { |
| 360 | + return nil, false, WithStack(err) |
| 361 | + } |
| 362 | + return idx, created, nil |
| 363 | +} |
| 364 | + |
323 | 365 | type invertedIndexData struct {
|
324 | 366 | InvertedIndexOptions
|
325 | 367 | Type string `json:"type"`
|
|
0 commit comments