java – Lucene 6.0!如何实例化BooleanQuery并在其中添加其他搜索查询?

栏目: 后端 · 发布时间: 7年前

内容简介:翻译自:https://stackoverflow.com/questions/37904977/lucene-6-0-how-to-instantiate-a-booleanquery-and-add-other-search-queries-in-it

如何在Lucene 6.x中实例化一个BooleanQuery?

如何使用布尔查询在其中添加其他查询?

在Lucene 4.x中,我们使用BooleanQuery如下:

BooleanQuery booleanQuery = new BooleanQuery();
    booleanQuery.add(query1, BooleanClause.Occur.MUST);
    booleanQuery.add(query2, BooleanClause.Occur.MUST);

如何在Lucene 6中实现这一目标.

BooleanQuery现在是不可变的(您可以阅读有关 Migration guide

和链接的JIRA问题的更改).

相反,您现在将使用BooleanQuery.Builder:

BooleanQuery booleanQuery = new BooleanQuery.Builder()
    .add(query1, BooleanClause.Occur.MUST)
    .add(query2, BooleanClause.Occur.MUST)
    .build();

翻译自:https://stackoverflow.com/questions/37904977/lucene-6-0-how-to-instantiate-a-booleanquery-and-add-other-search-queries-in-it


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Hacker's Delight

Hacker's Delight

Henry S. Warren Jr. / Addison-Wesley / 2002-7-27 / USD 59.99

A collection useful programming advice the author has collected over the years; small algorithms that make the programmer's task easier. * At long last, proven short-cuts to mastering difficult aspec......一起来看看 《Hacker's Delight》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

URL 编码/解码
URL 编码/解码

URL 编码/解码