Neo4j 自动索引、遗留索引和标签模式:相对于节点全文搜索的差异 [英] Neo4j auto-index, legacy index and label schema: differences for a relative-to-a-node full-text search

查看:19
本文介绍了Neo4j 自动索引、遗留索引和标签模式:相对于节点全文搜索的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题部分回答在neo4j-legacy-indexes-and-auto-index-vs-new-label-bases-schema-indexesthe-difference-between-legacy-索引自动索引和新索引方法

我还不能对它们发表评论,也不能在这里写一个新线程.在我的数据库中,我有一个旧索引主题"和标签主题".

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'.

我知道:

  • a.pattern MATCH (n:Label) 将扫描节点;
  • b.模式 START (n:Index) 将搜索旧索引
  • c.自动索引是一种遗留索引,应该给出与 (b) 相同的结果,但在我的情况下不是
  • d.START 子句应替换为 MATCH 以表示良好做法".

我在a之间有不一致的结果.和 b.(见下文),无法弄清楚如何使用正确的语法与 MATCH 搜索索引插入标签.

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.

这里有一些例子:

1#

start n=node:topic('name:(keyword1 AND keyword2)') return n

6 行,3 毫秒

start n=node:node_auto_index('name:(keyword1 AND keyword2)') return n;

0 行

MATCH (n:Topic) where n.name =~ '(?i).*keyword1*.AND.*keyword2*.' return n;

0 行,10K 毫秒

2#

start n=node:topic('name:(keyword1)') return n

212 行,122 毫秒 [所有包含子字符串关键字 1 的相关结果]

212 rows, 122 ms [all coherent results containing substring keyword1]

start n=node:node_auto_index('name:(keyword1)') return n

0 行

MATCH (n:Topic) where n.name =~ '(?i).*keyword1*.'return n

835 行,8K ms [结果不连贯,包含子串 eyword]

835 rows, 8K ms [also results not coherent, containing substring eyword]

MATCH (n:Topic) where n.name =~ 'keyword1' return n;

1 行,>6K ms [完全匹配]

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?

如何使用带有索引而不是标签的 MATCH 子句?我想重现全文搜索的结果.

How to use MATCH clause with Indexes rather than labels? I want to reproduce results of full-text search.

进行全文搜索的哪种语法仅适用于节点的邻居,而不适用于完整数据库?比赛 ?START 条款?遗留索引?标签?我很困惑.

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.

推荐答案

自动索引(只有一个)是手动(又名遗留)索引,名称为 node_auto_index.这个特殊的索引通过连接到事务处理来跟踪图形的变化.因此,如果您将 name 声明为配置中节点的自动索引的一部分,则对具有 name 属性的节点的任何更改都会反映到该索引中.

The auto index (there is only one) is a manual (aka legacy) index having the name node_auto_index. This special index tracks changes to the graph by hooking into the transaction processing. So if you declared name as part of your auto index for nodes in the config, any change to a node having a name property is reflected to that index.

请注意,当您添加例如自动索引时,自动索引不会自动填充到现有数据集上.用于自动索引的新属性.

Note that auto indexes do not automatically populate on an existing dataset when you add e.g. a new property for auto indexing.

进一步注意手动或自动索引完全独立于标签.

Note further that manual or auto indexes are totally independent of labels.

查询手动或自动索引的唯一方法是使用 START 子句:

The only way to query a manual or auto index is by using the START clause:

START n=node:<indexName>(<lucene query expression>) // index query
START n=node:<indexName>(key='<value>') // exact index lookup

Schema 索引完全不同,会在适当的时候在 MATCH 中使用.

Schema indexes are completely different and are used in MATCH when appropriate.

我的博文涵盖了neo4j的所有索引能力.

A blog post of mine covers all the index capabilities of neo4j.

通常,您在图形数据库中使用索引来标识遍历的起点.一旦您在图表中获得了引用,您只需遵循关系,不再进行索引查找.

In general you use an index in graph databases to identify the start points for traversals. Once you've got a reference inside the graph you just follow relationships and do no longer do index lookups.

有关全文索引,请参阅另一篇博文.

For full text indexing, see another blog post.

事实上 MATCH (p:Topic {name: 'DNA'}) RETURN pMATCH (n:Topic) where n.name = 'DNA' return n 都是等价的.两者都产生相同的查询计划.如果标签 Topic 和属性 name 上有模式索引(通过 CREATE INDEX ON :Topic(name)),Cypher 将隐式使用模式索引以查找指定的节点.

In fact MATCH (p:Topic {name: 'DNA'}) RETURN p and MATCH (n:Topic) where n.name = 'DNA' return n are both equvalent. Both result in the same query plan. If there is a schema index on label Topic and property name (by CREATE INDEX ON :Topic(name)) Cypher will implicitly use the schema index to find the specified node(s).

目前您不能使用基于架构索引的全文搜索.全文仅在手动/自动索引中可用.

At the moment you cannot use full text searches based on schema indexes. Full text is only available in manual / auto indexing.

您通过 START n=node:topic(...) 提供的所有示例都依赖于手动索引.您有责任让它们与您的图表内容保持同步,因此我认为差异是由于图表中的修改不一致造成的,而不是反映对手动索引的更改.

All the example you've provided with START n=node:topic(...) rely on a manual index. It's your responsibility to keep them in sync with your graph contents, so I assume the differences are due to inconsistent modifications in the graph and not reflecting the change to the manual index.

无论如何,如果您使用 START n=node:topic(....) 将永远不会使用架构索引.

In any case if you use START n=node:topic(....) will never use a schema index.

这篇关于Neo4j 自动索引、遗留索引和标签模式:相对于节点全文搜索的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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