Skip to content

Commit d56b7ae

Browse files
Add information about Text indexes and dictionary variables (#1026)
1 parent 42abd34 commit d56b7ae

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

modules/ROOT/pages/indexes/search-performance-indexes/using-indexes.adoc

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,35 @@ Text indexes do not store `STRING` properties alphabetically, and are instead op
235235
That said, if no range index had been present on the name property, the previous query would still have been able to utilize the text index.
236236
It would have done so less efficiently than a range index, but it still would have been useful.
237237

238-
239238
For more information about range index ordering, see the section on xref:indexes/search-performance-indexes/using-indexes.adoc#range-index-backed-order-by[Range index-backed ORDER BY].
240239

241240
[TIP]
242241
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.
243242

244243
For more information about the predicates supported by text indexes, see xref:indexes/search-performance-indexes/managing-indexes.adoc#text-indexes-supported-predicates[Create, show, and delete indexes -> Text indexes: supported predicates].
245244

245+
[[text-index-dictionary-variables]]
246+
=== Ensuring text index use
247+
248+
In order for the planner to use text indexes, it must be able to confirm that the properties included in the predicate are `STRING` values.
249+
This is not possible when accessing property values within nodes or relationships, or values within a `MAP`, since Cypher does not store the type information of these values.
250+
To ensure text indexes are used in these cases, the xref:functions/string.adoc#functions-tostring[`toString`] function should be used.
251+
252+
.Text index not used
253+
[source,cypher]
254+
----
255+
WITH {name: 'William Shakespeare'} AS varName
256+
MERGE (:PointOfInterest {name:varName.name})
257+
----
258+
259+
.Text index used
260+
[source,cypher]
261+
----
262+
WITH {name: 'William Shakespeare'} AS varName
263+
MERGE (ws:PointOfInterest {name: toString(varName.name)})
264+
----
265+
266+
For information about how to ensure the use of text indexes when predicates may contain `null` values, see xref:indexes/search-performance-indexes/using-indexes/indexes-and-null[Indexes and `null` values].
246267

247268
[[text-index-string-size]]
248269
=== Text indexes and `STRING` sizes

0 commit comments

Comments
 (0)