Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Named indices #8370

Merged
merged 33 commits into from
Mar 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
fb72bc7
Initial Index API changes.
Feb 22, 2019
cb82935
Add initial automatic naming.
Feb 22, 2019
2673b68
Merge branch 'devel' into feature/named-indices
Feb 25, 2019
1234742
Handle duplicate name checking.
Feb 25, 2019
7d44711
Add name field to frontend creation form.
Feb 25, 2019
85587ba
Merge branch 'devel' into feature/named-indices
Feb 26, 2019
f2701aa
Merge branch 'devel' into feature/named-indices
Feb 26, 2019
d38d295
Add index name display to frontend.
Feb 26, 2019
78af046
Fix cluster support.
Feb 28, 2019
2b93591
Merge branch 'devel' into feature/named-indices
Feb 28, 2019
3a4bd57
Merge branch 'devel' into feature/named-indices
Mar 1, 2019
9028a17
First attempt at single-server upgrade procedure.
Mar 1, 2019
2fbc461
Add missing static strings for ClusterEngine.
Mar 5, 2019
a7079c3
Some debugging efforts.
Mar 5, 2019
fbfb0ad
Merge branch 'devel' into feature/named-indices
Mar 8, 2019
79e4cfd
Replace upgrade procedure with no-name handling.
Mar 8, 2019
daaad87
Fix bug with ID formatting.
Mar 11, 2019
c170027
Merge branch 'devel' into feature/named-indices
Mar 11, 2019
96f8d9e
Add CHANGELOG entry.
Mar 11, 2019
075cbde
Add name validation.
Mar 11, 2019
6528f28
Add correct support for index lookup by name.
Mar 11, 2019
e149412
Add documentation about index names.
Mar 11, 2019
722575c
Fix jslint issue.
Mar 11, 2019
42180d4
Fix isNaN usage.
Mar 11, 2019
45ac619
Merge branch 'devel' into feature/named-indices
Mar 12, 2019
fa2f7ab
Merge branch 'devel' into feature/named-indices
Mar 12, 2019
95c41ee
Delete package-lock.json
Mar 12, 2019
5368e1e
Merge branch 'devel' into feature/named-indices
Mar 12, 2019
08bcf59
Additional documentation changes.
Mar 12, 2019
c7c8002
Change name/ID collision behavior.
Mar 12, 2019
66c129d
Merge branch 'devel' into feature/named-indices
jsteemann Mar 13, 2019
1f9832a
Add more tests.
Mar 13, 2019
11187f1
Merge branch 'feature/named-indices' of github.com:arangodb/arangodb …
Mar 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ Fetches information about the index with the given _indexHandle_ and returns it.

The handle of the index to look up. This can either be a fully-qualified
identifier or the collection-specific key of the index. If the value is an
object, its _id_ property will be used instead.
object, its _id_ property will be used instead. Alternatively, the index
may be looked up by name.

**Examples**

Expand All @@ -243,6 +244,12 @@ assert.equal(result.id, index.id);

const result = await collection.index(index.id.split("/")[1]);
assert.equal(result.id, index.id);

// -- or --

const result = await collection.index(index.name);
assert.equal(result.id, index.id);
assert.equal(result.name, index.name);
// result contains the properties of the index
```

Expand Down
22 changes: 17 additions & 5 deletions Documentation/Books/Manual/Indexing/WorkingWithIndexes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Learn how to use different indexes efficiently by going through the
Index Identifiers and Handles
-----------------------------

An *index handle* uniquely identifies an index in the database. It is a string and
consists of the collection name and an *index identifier* separated by a `/`. The
An *index handle* uniquely identifies an index in the database. It is a string and
consists of the collection name and an *index identifier* separated by a `/`. The
index identifier part is a numeric value that is auto-generated by ArangoDB.

A specific index of a collection can be accessed using its *index handle* or
Expand All @@ -35,6 +35,15 @@ Because the index handle is unique within the database, you can leave out the
db._index("demo/362549736");
```

An index may also be looked up by its name. Since names are only unique within
a collection, rather than within the database, the lookup must also include the
collection name.

```js
db._index("demo/primary")
db.demo.index("primary")
```

Collection Methods
------------------

Expand Down Expand Up @@ -86,6 +95,10 @@ Other attributes may be necessary, depending on the index type.
- *fulltext*: fulltext index
- *geo*: geo index, with _one_ or _two_ attributes

**name** can be a string. Index names are subject to the same character
restrictions as collection names. If omitted, a name will be auto-generated so
that it is unique with respect to the collection, e.g. `idx_832910498`.

**sparse** can be *true* or *false*.

For *hash*, and *skiplist* the sparsity can be controlled, *fulltext* and *geo*
Expand All @@ -98,7 +111,7 @@ object existed before the call is indicated in the return attribute
*isNewlyCreated*.

**deduplicate** can be *true* or *false* and is supported by array indexes of
type *hash* or *skiplist*. It controls whether inserting duplicate index values
type *hash* or *skiplist*. It controls whether inserting duplicate index values
from the same document into a unique array index will lead to a unique constraint
error or not. The default value is *true*, so only a single instance of each
non-unique index value will be inserted into the index per document. Trying to
Expand Down Expand Up @@ -248,7 +261,7 @@ finds an index
So you've created an index, and since its maintainance isn't for free,
you definitely want to know whether your query can utilize it.

You can use explain to verify whether **skiplists** or **hash indexes** are
You can use explain to verify whether **skiplists** or **hash indexes** are
used (if you omit `colors: false` you will get nice colors in ArangoShell):

@startDocuBlockInline IndexVerify
Expand All @@ -260,4 +273,3 @@ used (if you omit `colors: false` you will get nice colors in ArangoShell):
~db._drop("example");
@END_EXAMPLE_ARANGOSH_OUTPUT
@endDocuBlock IndexVerify

9 changes: 9 additions & 0 deletions Documentation/Books/Manual/ReleaseNotes/NewFeatures35.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,15 @@ entries, and will continue to work.

Existing `_modules` collections will also remain functional.

### Named indices

Indices now have an additional `name` field, which allows for more useful
identifiers. System indices, like the primary and edge indices, have default
names (`primary` and `edge`, respectively). If no `name` value is specified
on index creation, one will be auto-generated (e.g. `idx_13820395`). The index
name _cannot_ be changed after index creation. No two indices on the same
collection may share the same name, but two indices on different collections
may.

Client tools
------------
Expand Down
11 changes: 11 additions & 0 deletions Documentation/Books/Manual/ReleaseNotes/UpgradingChanges35.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,14 @@ undefined.
This change is about making queries as the above fail with a parse error, as an
unknown variable `key1` is accessed here, avoiding the undefined behavior. This is
also in line with what the documentation states about variable invalidation.

Miscellaneous
-------------

### Index creation

In previous versions of ArangoDB, if one attempted to create an index with a
specified `_id`, and that `_id` was already in use, the server would typically
return the existing index with matching `_id`. This is somewhat unintuitive, as
it would ignore if the rest of the definition did not match. This behavior has
been changed so that the server will now return a duplicate identifier error.
5 changes: 4 additions & 1 deletion Documentation/DocuBlocks/Rest/Indexes/post_api_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ Indexing the system attribute *_id* is not supported for user-defined indexes.
Manually creating an index using *_id* as an index attribute will fail with
an error.

Optionally, an index name may be specified as a string in the *name* attribute.
Index names have the same restrictions as collection names. If no value is
specified, one will be auto-generated.

Some indexes can be created as unique or non-unique variants. Uniqueness
can be controlled for most indexes by specifying the *unique* flag in the
index details. Setting it to *true* will create a unique index.
Expand Down Expand Up @@ -76,4 +80,3 @@ target index will not support, then an *HTTP 400* is returned.
@RESTRETURNCODE{404}
If *collection* is unknown, then an *HTTP 404* is returned.
@endDocuBlock