Neo4j: full-text lucene legacy indexes (node_auto_index) does not work after migration

萝らか妹 提交于 2020-01-05 04:18:12

问题


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.

Example:

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

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

Before it was matching the following:

  1. Target
  2. Target v2

After migration:

  1. Target

Why and how to fix that?


回答1:


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.

Steps:

  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. 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. 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. 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;
// ...

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



来源:https://stackoverflow.com/questions/39268710/neo4j-full-text-lucene-legacy-indexes-node-auto-index-does-not-work-after-mig

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!