lucene 如何与 Neo4j 配合使用 [英] How lucene works with Neo4j

查看:31
本文介绍了lucene 如何与 Neo4j 配合使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Neo4jSolr/Lucene 的新手.我读到我们可以在 Neo4j 中使用 lucene 查询,这是如何工作的?Neo4j中使用lucene查询有什么用?

I am new to Neo4j and Solr/Lucene. i have read that we can use lucene query in Neo4j how does this works? What is the use of using lucene query in Neo4j.?

我还需要一个建议.我需要编写一个应用程序来搜索和分析数据.哪个可以帮助我 Neo4j 或 Solr?

And also i need a suggestion. I need to write an application to search and analyse the data. which might help me Neo4j Or Solr?

推荐答案

Neo4J 使用 lucene 作为其 传统索引.目前,Neo4J 支持多种索引,例如在节点上创建标签,以及在节点属性上创建索引.

Neo4J uses lucene as part of its legacy indexing. Right now, Neo4J supports several kinds of indexes, like creating labels on nodes, and indexes on node properties.

但是在 neo4j 支持这些新功能之前,它主要(并且仍然)使用 Lucene 进行索引.大多数开发人员会在特定节点属性上创建 lucene 索引,以使他们能够使用 lucene 的查询语法在密码查询中查找节点.

But before neo4j supported those new features, it primarily (and still) used Lucene for indexing. Most developers would create lucene indexes on particular node properties, to enable them to use lucene's query syntax to find nodes within a cypher query.

例如,如果您根据文档创建索引,然后您可以在索引中搜索特定值,如下所示:

For example, if you created an index according to the documentation, you could then search the index for particular values like this:

IndexHits<Node> hits = actors.get( "name", "Keanu Reeves" );
Node reeves = hits.getSingle();

实际上是在幕后进行这种发现的 lucene.

It's lucene behind the scenes that's actually doing that finding.

在密码中,它可能是这样的:

In cypher, it might look like this:

start n=node:node_auto_index('name:M* OR name:N*')
return n;

在这种情况下,您正在为名称属性以M"或N"开头的所有节点搜索特定索引.单引号表达式中的内容只是根据 lucene 查询语法.

In this case, you're searching a particular index for all nodes that have a name property that starts either with an "M" or an "N". What's inside of that single quote expression there is just a query according to the lucene query syntax.

好的,这就是 Neo4J 使用 lucene 的方式.在最近的版本中,我只将这些遗留索引"用于全文索引,这正是 lucene 的优势所在.如果我只想要快速的相等性检查(其中 name="Neo"),那么我使用 常规的neo4j架构索引.

OK, so that's how Neo4J uses lucene. In recent versions, I only use these "legacy indexes" for fulltext indexing, which is where lucene's strength is. If I just want fast equality checks (where name="Neo") then I use regular neo4j schema indexes.

至于 Solr,我还没有看到它与 neo4j 结合使用——也许有人会跳进来提供一个反例,但通常我认为 Solr 运行在一个大的 lucene 索引之上,并且在Neo4j 的情况,它有点在中间,我不确定运行 Solr 是否合适.

As for Solr, I haven't seen it used in conjunction with neo4j - maybe someone will jump in and provide a counter-example, but usually I think of Solr as running on top of a big lucene index, and in the case of neo4j, it's kind of in the middle there, and I'm not sure running Solr would be a good fit.

至于您需要编写一个应用程序来搜索和分析数据,我无法给您推荐 - Neo4J 或 Solr 可能会有所帮助,具体取决于您的应用程序和您想要做什么.一般而言,当您需要表达和搜索图形时,请使用 neo4j.当您需要组织和搜索大量文本文档时,更多地使用 Solr.

As for you needing to write an application to search and analyze data, I can't give you a recommendation - either Neo4J or Solr might help, depending on your application and what you want to do. In generalities, use neo4j when you need to express and search graphs. Use Solr more when you need to organize and search large volumes of text documents.

这篇关于lucene 如何与 Neo4j 配合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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