Neo4j 中跨多个字段的全文搜索示例? [英] Example of full-text search across multiple fields in Neo4j?

查看:17
本文介绍了Neo4j 中跨多个字段的全文搜索示例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过一些简单的文本搜索示例STARTS WITH name 例如:

I've seen some simple examples text searching STARTS WITH name such as:

但我正在寻找更多类似跨多个字段的全文搜索的内容:titlecontent:

But I'm looking for something more along the lines of full-text search across multiple fields: title, content:

我可以看看如何使用 Neo4j 完成此操作的示例吗?

Can I see an example of how this should be done with Neo4j?

推荐答案

您可以使用 APOC Neo4j 程序库.假设您有节点标签 BookAuthor,并且您想要跨 :Book(title) 进行全文查询:Book(content):Author(name):Author(address).首先,使用 apoc.index.addAllNodes 创建一个名为 bookIndex 的索引,并指定要包含在索引中的标签和属性:

You can do this using the APOC Neo4j procedure library. Let's say you have node labels Book and Author and you want to make a full text query across :Book(title), :Book(content), and :Author(name) and :Author(address). First, use apoc.index.addAllNodes to create an index called bookIndex and specify the labels and properties to include in the index:

CALL apoc.index.addAllNodes('bookIndex',{
  Book: ["title","content"],
  Author:  ["name","address"]
})

然后,搜索索引:

CALL apoc.index.search('bookIndex', 'River Runs Through It')

您也可以将其用于更复杂的图形查询:

You can use this with more complex graph queries as well:

CALL apoc.index.search('bookIndex, 'River Runs Through It')
YIELD node AS book
MATCH (book)-[:IN_GENRE]->(g:Genre)
RETURN g

使用Lucene查询语法,所以你可以做模糊搜索,需要的组件字符串等:'Norman Maclean~''Norman~ +Maclean'

Lucene query syntax is used so you can do fuzzy search, required components of the string, etc: 'Norman Maclean~' or 'Norman~ +Maclean'

有关详细信息,请参阅 APOC 文档.

See the APOC docs for more info.

这篇关于Neo4j 中跨多个字段的全文搜索示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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