@index
directive.
Here are some examples:
int
, float
, bool
and geo
have only a default index each: with
tokenizers named int
, float
, bool
and geo
.
Types string
and dateTime
have a number of indices.
Type float32vector
supports hnsw
index.
Dgraph function | Required index / tokenizer | Notes |
---|---|---|
eq | hash , exact , term , or fulltext | The most performant index for eq is hash . Only use term or fulltext if you also require term or full-text search. If youβre already using term , there is no need to use hash or exact as well. |
le , ge , lt , gt | exact | Allows faster sorting. |
allofterms , anyofterms | term | Allows searching by a term in a sentence. |
alloftext , anyoftext | fulltext | Matching with language specific stemming and stopwords. |
regexp | trigram | Regular expression matching. Can also be used for equality checking. |
float32vector
are as follows.
Dgraph function | Required index / tokenizer | Notes |
---|---|---|
similar_to | hnsw | HNSW index supports parameters metric and exponent . |
hnsw
(Hierarchical Navigable Small World) index supports the following
parameters
cosine
, euclidean
, and dotproduct
. Default is euclidean
.
dateTime
are as follows.
Index name / Tokenizer | Part of date indexed |
---|---|
year | index on year (default) |
month | index on year and month |
day | index on year, month and day |
hour | index on year, month, day and hour |
dateTime
index allow selecting the precision of the index.
Apps, such as the movies examples in these docs, that require searching over
dates but have relatively few nodes per year may prefer the year
tokenizer;
apps that are dependent on fine grained date searches, such as real-time sensor
readings, may prefer the hour
index.
All the dateTime
indices are sortable.
int
and float
are sortable.string
index exact
is sortable.dateTime
indices are sortable.name
of string
type, to sort by name
or perform
inequality filtering on names, the exact
index must have been specified. In
which case a schema query would return at least the following tokenizers.
@count
Dgraph indexes the number of edges out of each
node. This enables fast queries of the form:
[]
to indicate that its a
list type.
["e1", "e1", "e2"]
may
get stored as ["e2", "e1"]
, i.e., duplicate values will not be stored and
order may not be preserved.@filter(eq(occupations, "Teacher"))
at the root of the query or
the parent edge will display all the occupations from a list of each node in an
array but will only include nodes which have Teacher
as one of the
occupations. However, filtering on value edge is not supported.
@reverse
is specified in the schema.
The reverse edge of anEdge
is ~anEdge
.
For existing data, Dgraph computes all reverse edges. For data added after the
schema mutation, Dgraph computes and stores the reverse edge for each added
triple.
~owner
in the result, the query can be written
with the wanted label (cars
in this case):
car
:
owner
edge should be set on the Car
: