-
Notifications
You must be signed in to change notification settings - Fork 79
/
edge_collection_indexes_impl.go
162 lines (147 loc) · 7.37 KB
/
edge_collection_indexes_impl.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
//
// DISCLAIMER
//
// Copyright 2017-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package driver
import "context"
// Index opens a connection to an existing index within the collection.
// If no index with given name exists, an NotFoundError is returned.
func (c *edgeCollection) Index(ctx context.Context, name string) (Index, error) {
result, err := c.rawCollection().Index(ctx, name)
if err != nil {
return nil, WithStack(err)
}
return result, nil
}
// IndexExists returns true if an index with given name exists within the collection.
func (c *edgeCollection) IndexExists(ctx context.Context, name string) (bool, error) {
result, err := c.rawCollection().IndexExists(ctx, name)
if err != nil {
return false, WithStack(err)
}
return result, nil
}
// Indexes returns a list of all indexes in the collection.
func (c *edgeCollection) Indexes(ctx context.Context) ([]Index, error) {
result, err := c.rawCollection().Indexes(ctx)
if err != nil {
return nil, WithStack(err)
}
return result, nil
}
// Deprecated: since 3.10 version. Use ArangoSearch view instead.
// EnsureFullTextIndex creates a fulltext index in the collection, if it does not already exist.
//
// Fields is a slice of attribute names. Currently, the slice is limited to exactly one attribute.
// The index is returned, together with a boolean indicating if the index was newly created (true) or pre-existing (false).
func (c *edgeCollection) EnsureFullTextIndex(ctx context.Context, fields []string, options *EnsureFullTextIndexOptions) (Index, bool, error) {
result, created, err := c.rawCollection().EnsureFullTextIndex(ctx, fields, options)
if err != nil {
return nil, false, WithStack(err)
}
return result, created, nil
}
// EnsureGeoIndex creates a hash index in the collection, if it does not already exist.
//
// Fields is a slice with one or two attribute paths. If it is a slice with one attribute path location,
// then a geo-spatial index on all documents is created using location as path to the coordinates.
// The value of the attribute must be a slice with at least two double values. The slice must contain the latitude (first value)
// and the longitude (second value). All documents, which do not have the attribute path or with value that are not suitable, are ignored.
// If it is a slice with two attribute paths latitude and longitude, then a geo-spatial index on all documents is created
// using latitude and longitude as paths the latitude and the longitude. The value of the attribute latitude and of the
// attribute longitude must a double. All documents, which do not have the attribute paths or which values are not suitable, are ignored.
// The index is returned, together with a boolean indicating if the index was newly created (true) or pre-existing (false).
func (c *edgeCollection) EnsureGeoIndex(ctx context.Context, fields []string, options *EnsureGeoIndexOptions) (Index, bool, error) {
result, created, err := c.rawCollection().EnsureGeoIndex(ctx, fields, options)
if err != nil {
return nil, false, WithStack(err)
}
return result, created, nil
}
// EnsureHashIndex creates a hash index in the collection, if it does not already exist.
// Fields is a slice of attribute paths.
// The index is returned, together with a boolean indicating if the index was newly created (true) or pre-existing (false).
func (c *edgeCollection) EnsureHashIndex(ctx context.Context, fields []string, options *EnsureHashIndexOptions) (Index, bool, error) {
result, created, err := c.rawCollection().EnsureHashIndex(ctx, fields, options)
if err != nil {
return nil, false, WithStack(err)
}
return result, created, nil
}
// EnsurePersistentIndex creates a persistent index in the collection, if it does not already exist.
// Fields is a slice of attribute paths.
// The index is returned, together with a boolean indicating if the index was newly created (true) or pre-existing (false).
func (c *edgeCollection) EnsurePersistentIndex(ctx context.Context, fields []string, options *EnsurePersistentIndexOptions) (Index, bool, error) {
result, created, err := c.rawCollection().EnsurePersistentIndex(ctx, fields, options)
if err != nil {
return nil, false, WithStack(err)
}
return result, created, nil
}
// EnsureSkipListIndex creates a skiplist index in the collection, if it does not already exist.
// Fields is a slice of attribute paths.
// The index is returned, together with a boolean indicating if the index was newly created (true) or pre-existing (false).
func (c *edgeCollection) EnsureSkipListIndex(ctx context.Context, fields []string, options *EnsureSkipListIndexOptions) (Index, bool, error) {
result, created, err := c.rawCollection().EnsureSkipListIndex(ctx, fields, options)
if err != nil {
return nil, false, WithStack(err)
}
return result, created, nil
}
// EnsureTTLIndex creates a TLL collection, if it does not already exist.
// The index is returned, together with a boolean indicating if the index was newly created (true) or pre-existing (false).
func (c *edgeCollection) EnsureTTLIndex(ctx context.Context, field string, expireAfter int, options *EnsureTTLIndexOptions) (Index, bool, error) {
result, created, err := c.rawCollection().EnsureTTLIndex(ctx, field, expireAfter, options)
if err != nil {
return nil, false, WithStack(err)
}
return result, created, nil
}
// EnsureZKDIndex creates a ZKD index in the collection, if it does not already exist.
// Fields is a slice of attribute paths.
// The index is returned, together with a boolean indicating if the index was newly created (true) or pre-existing (false).
func (c *edgeCollection) EnsureZKDIndex(ctx context.Context, fields []string, options *EnsureZKDIndexOptions) (Index, bool, error) {
result, created, err := c.rawCollection().EnsureZKDIndex(ctx, fields, options)
if err != nil {
return nil, false, WithStack(err)
}
return result, created, nil
}
func (c *edgeCollection) EnsureMDIIndex(ctx context.Context, fields []string, options *EnsureMDIIndexOptions) (Index, bool, error) {
result, created, err := c.rawCollection().EnsureMDIIndex(ctx, fields, options)
if err != nil {
return nil, false, WithStack(err)
}
return result, created, nil
}
func (c *edgeCollection) EnsureMDIPrefixedIndex(ctx context.Context, fields []string, options *EnsureMDIPrefixedIndexOptions) (Index, bool, error) {
result, created, err := c.rawCollection().EnsureMDIPrefixedIndex(ctx, fields, options)
if err != nil {
return nil, false, WithStack(err)
}
return result, created, nil
}
// EnsureInvertedIndex creates an inverted index in the collection, if it does not already exist.
// Available in ArangoDB 3.10 and later.
func (c *edgeCollection) EnsureInvertedIndex(ctx context.Context, options *InvertedIndexOptions) (Index, bool, error) {
result, created, err := c.rawCollection().EnsureInvertedIndex(ctx, options)
if err != nil {
return nil, false, WithStack(err)
}
return result, created, nil
}