问题
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:
- Target
- Target v2
After migration:
- 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:
- 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
- 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"
}
- If it does not meet your requirements, for example
type
is notfulltext
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'
- 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