this question is partially answered in neo4j-legacy-indexes-and-auto-index-vs-new-label-bases-schema-indexes and the-difference-between-legacy-indexing-auto-indexing-and-the-new-indexing-approach
I can't comment on them yet and write a new thread here. In my db, I have a legacy index 'topic' and label 'Topic'.
I know that:
- a. pattern MATCH (n:Label) will scan the nodes;
- b. pattern START (n:Index) will search on legacy index
- c. auto-index is a sort of legacy index and should gimme same results as (b) but it does not in my case
- d. START clause should be replaced by MATCH for "good practices".
I have inconsistent results between a. and b. (see below), cannot figure out how to use proper syntax with MATCH for searching on indexing insted of labels.
Here some examples:
1#
start n=node:topic('name:(keyword1 AND keyword2)') return n
6 rows, 3ms
start n=node:node_auto_index('name:(keyword1 AND keyword2)') return n;
0 rows
MATCH (n:Topic) where n.name =~ '(?i).*keyword1*.AND.*keyword2*.' return n;
0 rows, 10K ms
2#
start n=node:topic('name:(keyword1)') return n
212 rows, 122 ms [all coherent results containing substring keyword1]
start n=node:node_auto_index('name:(keyword1)') return n
0 rows
MATCH (n:Topic) where n.name =~ '(?i).*keyword1*.'return n
835 rows, 8K ms [also results not coherent, containing substring eyword]
MATCH (n:Topic) where n.name =~ 'keyword1' return n;
1 row, >6K ms [exact match]
MATCH (n:topic) where n.name =~ 'keyword1' return n;
no results (here I used an index 'topic' not a label 'Topic'!)
MATCH (node:topic) where node.name =~ 'keyword1' return node;
no results (attempt to use node "object" directly, as in auto-index syntax)
Could you help shed some light:
What's the difference between a legacy index and auto-index and why inconsistent results between the two?
How to use MATCH clause with Indexes rather than labels? I want to reproduce results of full-text search.
Which syntax to do a full-text search applied to ONLY the neighbor of a node, not the full-db? MATCH ? START clause? legacy-index ? label? I am confused.