【问题标题】:Neo4j fuzzy searchNeo4j 模糊搜索
【发布时间】:2017-06-09 05:44:15
【问题描述】:

在我的 Spring Data Neo4j 4 项目 Neo4j 数据库中,我有一个带有 namedescription 字符串属性的 Product 节点。

我需要在这些属性上添加模糊搜索功能。 Neo4j/Spring Data Neo4j 中是否有任何开箱即用的功能来实现这一点?如果是/否,您能否建议如何实施?

【问题讨论】:

  • 我认为没有 - Cypher 中有正则表达式,但仅此而已。
  • 目前,不...您可能想要添加弹性搜索。

标签: neo4j cypher spring-data-neo4j-4


【解决方案1】:

如果您有一个名为:

public interface ProductRepository extends CrudRepository<Product, Long> {

    List<Product> findByNameLike(String name);

    List<Product> findByDescriptionLike(String description);
}

然后您可以执行以下操作(从 4.2.0 开始):

List<Product> products = productRepository.findByNameLike("*on*");

它将使用正则表达式进行通配符匹配(请参阅 Cypher =~ 运算符)。

这个的否定版本;还支持名称findByNameNotLike()

【讨论】:

    猜你喜欢
    • 2014-06-11
    • 2020-03-15
    • 2014-08-20
    • 2011-10-28
    • 2016-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多