查询应该如何工作?弹性搜索 Java API

How should query does it work ? ElasticSearch Java API

我只想从一个简单的伪 SQL 查询中获取所有结果:

[...] WHERE 'idGroups' = '7078' AND ('titre' LIKE '%fuite%' OR 'tag' LIKE '%fuite%' OR 'message' LIKE '%fuite%')

完成了:

        BoolQueryBuilder qb = QueryBuilders
                .boolQuery()
                .must(QueryBuilders.termQuery("idGroups", 7078))
                .should(QueryBuilders.termQuery("titre", "fuite"))
                .should(QueryBuilders.termQuery("tag", "fuite"))
                .should(QueryBuilders.termQuery("message", "fuite"));

显然,这没有返回我想要的结果.. 怎么了?

谢谢:)

你能试试这个吗:

QueryBuilders
            .boolQuery()
            .must(QueryBuilders.termQuery("idGroups", 7078))
            .should(QueryBuilders.wildcardQuery("titre", "*fuite*"))
            .should(QueryBuilders.wildcardQuery("tag", "*fuite*"))
            .should(QueryBuilders.wildcardQuery("message", "*fuite*")).minimumShouldMatch(1);