Skip to content

Commit

Permalink
post-review update
Browse files Browse the repository at this point in the history
  • Loading branch information
JPryce-Aklundh committed Jan 10, 2024
1 parent 3b28307 commit d25ba6d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 61 deletions.
17 changes: 5 additions & 12 deletions modules/ROOT/pages/indexes/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,9 @@ In short, much like indexes in a book, their function in a Neo4j graph database

Once an index has been created, it will be automatically populated and updated by the DBMS.

Neo4j supports two categories of indexes: xref:indexes/search-performance-indexes/overview.adoc[search-performance indexes] (including range, text, point, and token lookup indexes) and xref:indexes/semantic-indexes/overview.adoc[semantic indexes] (including full-text and vector indexes).
Neo4j supports two categories of indexes:

[[naming-rules-and-recommendations]]
== Naming rules and best practices

The following is true for naming indexes:

* Best practice is to give the index a name when it is created.
If the index is not explicitly named, it gets an auto-generated name.
* The index name must be unique among both indexes and xref:constraints/index.adoc[constraints].
* Index creation is by default not idempotent, and an error will be thrown if you attempt to create the same index twice.
Using the keyword `IF NOT EXISTS` makes the command idempotent, and no error will be thrown if you attempt to create the same index twice.
* As of Neo4j 5.16, indexes can be named using parameters.
- xref:indexes/search-performance-indexes/overview.adoc[Search-performance indexes], for speeding up data retrieval based on _exact_ matches.
This category includes range, text, point, and token lookup indexes.
- xref:indexes/semantic-indexes/overview.adoc[Semantic indexes], for _approximate_ matches and to compute similarity scores between a query string and the matching data.
This category includes full-text and vector indexes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
:description: A planner hint is used to influence the decisions of the planner when building an execution plan for a query.

[[query-using]]
= Index hints
= Index hints for the Cypher planner

A planner hint is used to influence the decisions of the planner when building an execution plan for a query.
Planner hints are specified in a query with the `USING` keyword.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
:description: This page explains how to manage indexes used for search performance.
= Managing search-performance indexes
= Create, show, and delete indexes

This page describes how to create, list, and delete search-performance indexes.
The following index types are included in this category:
Expand Down Expand Up @@ -207,15 +207,11 @@ Note that the index name must be unique.

Text indexes have no supported index configuration and, as of Neo4j 5.1, they have two index providers available, `text-2.0` (default) and `text-1.0` (deprecated).

[TIP]
Text indexes only store `STRING` values and do not support multiple properties.

[[text-indexes-supported-predicates]]
[discrete]
==== Supported predicates

Text indexes only solve predicates operating on `STRING` values.
That means that text indexes are only used in Cypher queries when it is known that the predicate evaluates to `null` or `false` for all non-`STRING` values.

The following predicates that only operate on `STRING` values are always solvable by a text index:

Expand Down Expand Up @@ -274,11 +270,10 @@ CONTAINS
|===

As of Neo4j 5.11, the above set of predicates can be extended with the use of type constraints.
See xref:indexes/search-performance-indexes/using-indexes.adoc#index-compatibility-type-constraints[Index compatibility and type constraints] for more information.
See the section about xref:indexes/search-performance-indexes/using-indexes.adoc#type-constraints[index compatibility and type constraints] for more information.

[TIP]
Unlike text indexes, full-text indexes can search the content of `STRING` properties.
For more information, see the page about xref:indexes/semantic-indexes/full-text-indexes.adoc[full-text indexes].
Text indexes are only used for exact query matches. To perform approximate matches (including, for example, variations and typos), and to compute a similarity score between `STRING` values, use semantic xref:indexes/semantic-indexes/full-text-indexes.adoc[full-text indexes] instead.

[discrete]
[[text-indexes-examples]]
Expand Down Expand Up @@ -377,16 +372,11 @@ Note that the index name must be unique.

Point indexes have supported index configuration, but only one index provider available, `point-1.0`.

[TIP]
Point indexes only store `POINT` values and do not support multiple properties.

[discrete]
[[point-indexes-supported-predicates]]
==== Supported predicates

Point indexes only solve predicates operating on `POINT` values.
Therefore, point indexes are only used when it is known that the predicate evaluates to `null` or `false` for all non-`POINT` values.


Point indexes support the following predicates:

Expand Down Expand Up @@ -634,18 +624,10 @@ Only one relationship type lookup index can exist at a time.

If it is not known whether an index exists or not, add `IF NOT EXISTS` to ensure it does.

.Parameters
[source,javascript, indent=0]
----
{
"name": "node_label_lookup"
}
----

.Creating a node label lookup index with `IF NOT EXISTS`
[source, cypher]
----
CREATE LOOKUP INDEX $name IF NOT EXISTS FOR (n) ON EACH labels(n)
CREATE LOOKUP INDEX node_label_lookup IF NOT EXISTS FOR (n) ON EACH labels(n)
----

The index will not be created if there already exists an index with the same schema and type, same name or both.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ Search-performance indexes enable quicker retrieval of exact matches between an
There are four different search-performance indexes available in Neo4j:

* *Range indexes*: Neo4j’s default index.
Supports most types of predicates, including node label and relationship types.
Supports most types of predicates.
* *Text indexes*: solves predicates operating on `STRING` values.
Optimized for queries filtering `STRING` properties for what they `CONTAIN` or `ENDS WITH`.
Optimized for queries filtering with the `STRING` operators `CONTAINS` and `ENDS WITH`.
* *Point indexes*: solves predicates on spatial `POINT` values.
Optimized for queries filtered on distance or within bounding boxes.
Optimized for queries filtering on distance or within bounding boxes.
* *Token lookup indexes*: only solves node label and relationship type predicates (i.e. they cannot solve any predicates filtered on properties).
* *Token lookup indexes*: only solves node label and relationship type predicates (i.e. they cannot solve any predicates filtering on properties).
Two token lookup indexes (one for node labels and one for relationship types) are present when a database is created in Neo4j.
To learn more about creating, listing, and deleting these indexes, as well as more details about the predicates supported by each index type, see xref:indexes/search-performance-indexes/managing-indexes.adoc[Managing search-performance Indexes].
To learn more about creating, listing, and deleting these indexes, as well as more details about the predicates supported by each index type, see xref:indexes/search-performance-indexes/managing-indexes.adoc[].

For information about how Cypher uses the various types of search-performance indexes, as well as some heuristics for when to use (and not to use) a search-performance index, see xref:indexes/search-performance-indexes/using-indexes.adoc[Using search-performance indexes].
For information about how indexes impact the performance of Cypher queries, as well as some heuristics for when to use (and not to use) a search-performance index, see xref:indexes/search-performance-indexes/using-indexes.adoc[].

Search-performance indexes are used automatically, and if several indexes are available, the xref:planning-and-tuning/execution-plans.adoc[Cypher planner] will try to use the index (or indexes) that can most efficiently solve a particular predicate.
It is, however, possible to explicitly force a query to use a particular index with the `USING` keyword. For more information, see xref:indexes/search-performance-indexes/index-hints.adoc[Index hints].
It is, however, possible to explicitly force a query to use a particular index with the `USING` keyword. For more information, see xref:indexes/search-performance-indexes/index-hints.adoc[].
Loading

0 comments on commit d25ba6d

Please sign in to comment.