Neo4j:全文Lucene旧式索引(node_auto_index)在迁移后不起作用 [英] Neo4j: full-text lucene legacy indexes (node_auto_index) does not work after migration

查看:87
本文介绍了Neo4j:全文Lucene旧式索引(node_auto_index)在迁移后不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用官方常见问题解答成功地从Neo4j 2.2.8迁移到3.0.4后,无法按预期进行全文搜索.模糊性并不像以前那样模糊.

After successful migration from Neo4j 2.2.8 to 3.0.4 using official faq, full text search does not work as expected. Fuzziness is not that fuzzy as it was before.

示例:

START n=node:node_auto_index('name:(+Target~0.85)') MATCH (n) RETURN n;

应返回字段为name的节点,其中包含的工作类似于目标"的85%.

Should return nodes with field name that contain work like 85% similar to 'Target'.

在匹配以下内容之前:

  1. 目标
  2. 目标v2

迁移后:

  1. 目标

为什么以及如何解决?

推荐答案

原因是在迁移后,lucene node_auto_index的配置不正确.迁移工具可能不尊重其配置或损坏.

Reason was that after migration lucene node_auto_index wasn't configured properly. Probably migration tools does not respect its configuration or broken.

解决方案是正确设置索引并重建它们.

The solution was to setup indexes correctly and rebuild them.

步骤:

  1. 检查您的/etc/neo4j/neo4j.conf启用了auto_index并将键设置为要自动索引的字段:
  1. Check your /etc/neo4j/neo4j.conf that auto_index is enabled and keys are set to fields that you want to auto index:

dbms.auto_index.nodes.enabled=true                                                                                                                                                                                 
dbms.auto_index.nodes.keys=name 

  1. 通过运行以下命令检查node_auto_index的配置是否正确:
  1. Check that node_auto_index configured correctly by running:

neo4j-shell -c 'index --get-config node_auto_index'
{
    "analyzer": "org.apache.lucene.analysis.standard.StandardAnalyzer",
    "provider": "lucene",
    "to_lower_case": "true",
    "type": "fulltext"
}

  1. 如果它不满足您的要求,例如type不是fulltext,则您可以执行以下操作:
  1. If it does not meet your requirements, for example type is not fulltext then you run following:

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'

  1. 之后,您需要重新索引数据.根据dbms.auto_index.nodes.keys设置(在此示例中为name字段),在数据集上运行以下密码:
  1. After that you need to re-index your data. Based on dbms.auto_index.nodes.keys setting (name field in this example), run the following cypher on your data set:

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索引并重新索引现有数据.

The following steps will help you to setup full-text lucene indexes in Neo4j 3.0 and re-index your existing data.

这篇关于Neo4j:全文Lucene旧式索引(node_auto_index)在迁移后不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆