如何重写为 Neo4j 4.4 创建全文搜索索引
How to rewrite create full-text search index for Neo4j 4.4
目前我们正在使用旧方法db.index.fulltext.createNodeIndex
创建全文搜索索引,但由于这在 4.4 中已弃用如何使用 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
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
备注:runSchema
需要用于模式操作。
目前我们正在使用旧方法db.index.fulltext.createNodeIndex
创建全文搜索索引,但由于这在 4.4 中已弃用如何使用 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
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
备注:runSchema
需要用于模式操作。