【问题标题】:Hibernate search on multi fields多字段的休眠搜索
【发布时间】:2019-06-21 12:33:06
【问题描述】:

我想对实体进行全文搜索。

当我使用单个关键字但不再使用时,它可以工作。

        Query luceneQuery = qb
        .keyword()
        .wildcard()
        .onFields("description", "brand" )
        .matching("*" + searchTerm + "*").createQuery();

在一种情况下,我有一个描述等于“汽车”和品牌等于“福特”的实体

如果查询是“car”或“ford”但不是“car ford”,则搜索返回预期结果

有什么想法吗?

谢谢

【问题讨论】:

    标签: elasticsearch lucene hibernate-search


    【解决方案1】:
    Query query = qb.bool()
                .should( qb.keyword().fuzzy().onField("description").ignoreFieldBridge().matching(searchTerm).createQuery() )
                .should( qb.keyword().fuzzy().onField("color").ignoreFieldBridge().matching(searchTerm).createQuery() )
                .should(qb.keyword().fuzzy().onField("brand").matching(searchTerm).createQuery() )
                .createQuery();
    

    【讨论】:

      猜你喜欢
      • 2015-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多