Spring数据jpa Query动态传递where子句

时间:2016-07-22 12:13:33

标签: spring postgresql hibernate lucene spring-data-jpa

我的实体就是这样

public class event
    {
        String title;

        String description;

        String city;
    }

我是Spring数据jpa的新手,当用户输入" Hello Hyderabad Fest" 我希望令牌大小为字符串并拆分成单词,并在实体上的任何属性上找到任何单词匹配,搜索查询命中为db。

  

标题喜欢'%Hello%'或者标题喜欢'%Hyderabad%'或标题喜欢   '%思特%'或描述喜欢'%Hello%'或说明喜欢   '%海得拉巴%'或描述喜欢'%Fest%'城市喜欢'%Hello%'要么   cityitle LIKE'%Hyderabad%'或城市喜欢'%Fest%'

我们如何在spring数据jpa中实现这一目标。

  1. 我们可以动态传递Spring数据jpa命名查询中的条件
  2. 我们可以在nosql dbs中使用lucene种类查询。
  3. 任何其他建议
  4. 提前致谢。

1 个答案:

答案 0 :(得分:0)

Postgresql全文搜索查询解决了上述问题http://rachbelaid.com/postgres-full-text-search-is-good-enough/