在Neo4j中跨多个字段进行全文搜索的示例? [英] Example of full-text search across multiple fields in Neo4j?
问题描述
我看过一些简单的示例文本搜索STARTS WITH
name
,例如:
I've seen some simple examples text searching STARTS WITH
name
such as:
- http://www.jexp.de/blog/html/full-text-and-spatial-search-in-neo4j-3.html
- https://blog. knoldus.com/2016/12/11/neo4j-with-scala-neo4j-vs-elasticsearch/
- http://www.jexp.de/blog/html/full-text-and-spatial-search-in-neo4j-3.html
- https://blog.knoldus.com/2016/12/11/neo4j-with-scala-neo4j-vs-elasticsearch/
但是我正在寻找跨多个字段的全文搜索的更多内容:title
,content
:
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?
推荐答案
You can do this using the APOC Neo4j procedure library. Let's say you have node labels
Book
andAuthor
and you want to make a full text query across:Book(title)
,:Book(content)
, and:Author(name)
and:Author(address)
. First, useapoc.index.addAllNodes
to create an index calledbookIndex
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屋!