How to rewrite create full-text search index for Neo4j 4.4

153 Views Asked by At

Currently we are using the old method db.index.fulltext.createNodeIndex to create a full-text search index, but since this is deprecated in 4.4 how to rewrite with CREATE FULLTEXT INDEX?

CALL db.propertyKeys() YIELD propertyKey CALL db.labels() YIELD label WITH 
collect(DISTINCT propertyKey) AS properties, 
collect(DISTINCT label) AS labels 
CALL db.index.fulltext.createNodeIndex("fullSearchIndex", labels, properties) RETURN labels, properties
1

There are 1 best solutions below

0
leon22 On BEST ANSWER

A possible solution with APOC:

CALL db.propertyKeys() YIELD propertyKey
CALL db.labels() YIELD label
WITH apoc.text.join(collect(DISTINCT propertyKey), ", n.") as properties, apoc.text.join(collect(DISTINCT label), "|") AS labels
CALL apoc.cypher.runSchema("CREATE FULLTEXT INDEX fullSearchIndex FOR (n:" + labels + ") ON EACH [n."+properties+"]", {}) YIELD value RETURN value

Remark: runSchema needs to be used for schema manipulation operations.