Neo4j autoindex, deprecated index and shortcut schema: differences for full text search relative to-aa-w630>
this question is partially given in neo4j-legacy-indexes-and-auto-index-vs-new-label-bases-schema-indexes and also -distinguishing between legacy-indexing-auto-indexing-and-new-index-approach
I can't comment on them yet and write a new thread here. In my db I have a deprecated "theme" index and a "Theme" label.
I know that:
- and. MATCH template (n: Label) scans nodes;
- b. pattern START (n: Index) will search at the stale index
- from. auto-index is kind of a deprecated index and should give the same results as (b), but that's not my case
- e. The START clause should be replaced by MATCH for "good practice".
I have inconsistent results between a. and b. (see below) can't figure out how to use the correct syntax with MATCH for indexing incremental label searches.
Here are some examples:
1 #
start n=node:topic('name:(keyword1 AND keyword2)') return n
6 lines, 3ms
start n=node:node_auto_index('name:(keyword1 AND keyword2)') return n;
0 lines
MATCH (n:Topic) where n.name =~ '(?i).*keyword1*.AND.*keyword2*.' return n;
0 lines, 10 thousand ms
2 #
start n=node:topic('name:(keyword1)') return n
212 lines, 122 ms [all coherent results containing the substring keyword1]
start n=node:node_auto_index('name:(keyword1)') return n
0 lines
MATCH (n:Topic) where n.name =~ '(?i).*keyword1*.'return n
835 lines, 8K ms [also not coherent, subscript]
MATCH (n:Topic) where n.name =~ 'keyword1' return n;
1 line,> 6K ms [exact match]
MATCH (n:Topic) where n.name =~ 'keyword1' return n;
no results (I used the index "topic" here, not the label "Topic"!)
MATCH (node:topic) where node.name =~ 'keyword1' return node;
no results (trying to use node "object" directly like in auto index syntax)
Can you please help shed some light:
-
What's the difference between legacy index and auto-indexing and why inconsistent results between them?
-
How do I use the MATCH clause with indices rather than labels? I want to reproduce the results of a full text search.
-
What syntax for full text search applies ONLY to the sibling node and not the full db? COINCIDENCE? START? legacy-index? label? I am embarrassed.
source to share
Autoindex (there is only one) is the index of the manual (aka old) having a name node_auto_index
. This special index keeps track of schedule changes by connecting to transaction processing. Therefore, if you declared name
as part of your automatic index for nodes in configuration, any change to a node that has a name property is reflected in that index.
Note that automatic indexes are not automatically populated on an existing dataset when added, for example. new automatic indexing property.
Note that manual or automatic indexes are completely independent of labels.
The only way to request a manual or automatic index is with the START clause:
START n=node:<indexName>(<lucene query expression>) // index query
START n=node:<indexName>(key='<value>') // exact index lookup
The schema indices are completely different and are used as MATCH
needed.
A blog post covers all the features of the neo4j index.
In general, you use an index on graph databases to determine starting points for traversals. When you have a link inside a graph, you just follow the relationship and no longer do index queries.
For full text indexing, see the other blog post .
updates based on codes below
In fact, MATCH (p:Topic {name: 'DNA'}) RETURN p
they MATCH (n:Topic) where n.name = 'DNA' return n
are equal. Both results result in the same query plan. If the label Topic
has a schema index Topic
and the property name
has a schema index. (C CREATE INDEX ON :Topic(name)
), Cypher will implicitly use the schema index to find the specified node (s).
You cannot currently use full text search based on schema indexes. The full text is only available in manual / automatic indexing.
The whole example you provided with help START n=node:topic(...)
relies on a manual index. It is your responsibility to keep them in sync with your graph content, so I am assuming the differences are due to inconsistent changes in the graph and do not reflect changes in the manual index.
In any case, if you do, you will START n=node:topic(....)
never use the schema index.
source to share