Lucene OR查询条件

时间:2015-01-26 15:59:35

标签: lucene

我将默认运算符设置为QueryParser.Operator.AND并希望运行查询(在2个字段上)

(apple OR windows) AND source:(40 OR 41)

但这是Lucene正在做的事情

(windows) AND source:(40 OR 41)

为什么它以这种方式运行以及如何修复它?

更新

更多代码以及2个字段的含义

        QueryParser parser = new MultiFieldQueryParser(CURRENT_LUCENE_VERSION,
                new String[]{Config.TITLE_FIELD, Config.DESCRIPTION_FIELD}, getAnalyzer());
            parser.setDefaultOperator(QueryParser.Operator.AND);
            query = parser.parse(QueryParser.escape(searchString));
            collector = TopFieldCollector.create(new Sort(
                new SortField(Config.TIME_FIELD, SortField.LONG, true)),
                Math.max(lastDoc, 1), true, true, true, true);
            Filter fl = new TermRangeFilter(Config.TIME_FIELD,
                "" + crit.getFilter().getStartDate().getTime(),
                "" + crit.getFilter().getEndDate().getTime(), true, true);
            indexSearcher.search(query, fl, collector);

----------------------------------------------- ---

我无法使用

+(content:apple content:windows) +(source:40 source:41)

因为我必须搜索2个字段

----------------------------------------------- ---

你如何得到Lucene正在做的事情?

我通过比较结果得到它。这是我通过toString()

得到的
(title:apple content:apple) +(title:windows content:windows) +(source:40 source:41)

如何从第二个表达式中删除加号?

0 个答案:

没有答案
相关问题