我正在 Jackrabbit 存储库上实现全文搜索。在浏览了http://jackrabbit.apache.org/ocm-search.html中给出的示例之后,当谓词中只需要“and”时,我可以编写对存储库执行全文搜索。例如:
select * from test where name like '%abc%' and type = 'mainPage' and language = 'english'
可以写成
Filter filter = queryManager.createFilter(Paragraph.class);
filter.addContains('name', 'abc');
filter.addEqualTo('type', 'mainPage');
filter.addEqualTo('language ', 'english');
但是,如果我尝试为以下查询编写 OCM 实现
select * from test where (name like '%abc%' or name like '%def%' ) and type = 'mainPage' and language = 'english'
如下所示,我得到空列表
Filter mainFilter= queryManager.createFilter(Paragraph.class);
Filter filter = queryManager.createFilter(Paragraph.class);
filter.addContains('name', 'abc');
Filter filter1 = queryManager.createFilter(Paragraph.class);
filter.addContains('name', 'def');
mainFilter = filter .addOrFilter(filter1 );
mainFilter .addEqualTo('type', 'mainPage');
mainFilter .addEqualTo('language ', 'english');
我认为我无法正确使用 OCM 全文搜索。请建议我实施 OCM 全文搜索的正确方法,其中谓词包含大量“和”和“或”条件。