diff --git a/modules/ROOT/pages/query-tuning/indexes.adoc b/modules/ROOT/pages/query-tuning/indexes.adoc index a32db2c53..42136fe17 100644 --- a/modules/ROOT/pages/query-tuning/indexes.adoc +++ b/modules/ROOT/pages/query-tuning/indexes.adoc @@ -84,6 +84,26 @@ In summary, `TEXT` indexes support the following predicates: |=== +=== Ensuring text index use + +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. +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. +To ensure text indexes are used in these cases, the xref:functions/string.adoc#functions-tostring[`toString`] function should be used. + +.Text index not used +[source,cypher] +---- +WITH {name: 'John'} AS varName +MERGE (:Person {name:varName.name}) +---- + +.Text index used +[source,cypher] +---- +WITH {name: 'John'} AS varName +MERGE (:Person {name: toString(varName.name)}) +---- + == Index preference When multiple indexes are available and able to solve a predicate, there is an order defined that decides which index to use.