Neo4j:全文 Lucene 遗留索引 (node_auto_index) 在迁移后不起作用
Neo4j: full-text lucene legacy indexes (node_auto_index) does not work after migration
使用 official faq 从 Neo4j 2.2.8 成功迁移到 3.0.4 后,全文搜索无法按预期工作。模糊没有以前那么模糊了
示例:
START n=node:node_auto_index('name:(+Target~0.85)') MATCH (n) RETURN n;
return 字段 name
的节点是否应该像 'Target'.
一样工作 85%
在匹配以下内容之前:
- 目标
- 目标 v2
迁移后:
- 目标
为什么以及如何解决这个问题?
原因是迁移后 lucene node_auto_index
配置不正确。可能迁移工具不遵守其配置或已损坏。
解决方案是正确设置索引并重建它们。
步骤:
- 检查您的
/etc/neo4j/neo4j.conf
是否启用了 auto_index 并且键设置为您要自动索引的字段:
dbms.auto_index.nodes.enabled=true
dbms.auto_index.nodes.keys=name
- 检查 运行ning 是否正确配置了
node_auto_index
:
neo4j-shell -c 'index --get-config node_auto_index'
{
"analyzer": "org.apache.lucene.analysis.standard.StandardAnalyzer",
"provider": "lucene",
"to_lower_case": "true",
"type": "fulltext"
}
- 如果不符合你的要求,比如
type
不是fulltext
那么你运行如下:
neo4j-shell -c 'index --set-config node_auto_index type fulltext'
neo4j-shell -c 'index --set-config node_auto_index to_lower_case true'
neo4j-shell -c 'index --set-config node_auto_index analyzer org.apache.lucene.analysis.standard.StandardAnalyzer'
- 之后您需要重新索引您的数据。基于
dbms.auto_index.nodes.keys
设置(本例中的 name
字段),运行 数据集上的以下密码:
MATCH (n) WHERE EXISTS(n.name) WITH (n) SKIP 0 LIMIT 50000 SET n.name=n.name;
MATCH (n) WHERE EXISTS(n.name) WITH (n) SKIP 50000 LIMIT 50000 SET n.name=n.name;
MATCH (n) WHERE EXISTS(n.name) WITH (n) SKIP 100000 LIMIT 50000 SET n.name=n.name;
// ...
以下步骤将帮助您在 Neo4j 3.0 中设置全文 lucene 索引并重新索引现有数据。
使用 official faq 从 Neo4j 2.2.8 成功迁移到 3.0.4 后,全文搜索无法按预期工作。模糊没有以前那么模糊了
示例:
START n=node:node_auto_index('name:(+Target~0.85)') MATCH (n) RETURN n;
return 字段 name
的节点是否应该像 'Target'.
在匹配以下内容之前:
- 目标
- 目标 v2
迁移后:
- 目标
为什么以及如何解决这个问题?
原因是迁移后 lucene node_auto_index
配置不正确。可能迁移工具不遵守其配置或已损坏。
解决方案是正确设置索引并重建它们。
步骤:
- 检查您的
/etc/neo4j/neo4j.conf
是否启用了 auto_index 并且键设置为您要自动索引的字段:
dbms.auto_index.nodes.enabled=true
dbms.auto_index.nodes.keys=name
- 检查 运行ning 是否正确配置了
node_auto_index
:
neo4j-shell -c 'index --get-config node_auto_index'
{
"analyzer": "org.apache.lucene.analysis.standard.StandardAnalyzer",
"provider": "lucene",
"to_lower_case": "true",
"type": "fulltext"
}
- 如果不符合你的要求,比如
type
不是fulltext
那么你运行如下:
neo4j-shell -c 'index --set-config node_auto_index type fulltext'
neo4j-shell -c 'index --set-config node_auto_index to_lower_case true'
neo4j-shell -c 'index --set-config node_auto_index analyzer org.apache.lucene.analysis.standard.StandardAnalyzer'
- 之后您需要重新索引您的数据。基于
dbms.auto_index.nodes.keys
设置(本例中的name
字段),运行 数据集上的以下密码:
MATCH (n) WHERE EXISTS(n.name) WITH (n) SKIP 0 LIMIT 50000 SET n.name=n.name;
MATCH (n) WHERE EXISTS(n.name) WITH (n) SKIP 50000 LIMIT 50000 SET n.name=n.name;
MATCH (n) WHERE EXISTS(n.name) WITH (n) SKIP 100000 LIMIT 50000 SET n.name=n.name;
// ...
以下步骤将帮助您在 Neo4j 3.0 中设置全文 lucene 索引并重新索引现有数据。