clauses() {
- return clauses;
- }
-
- /** Returns an iterator on the clauses in this query. It implements the {@link Iterable} interface to
- * make it possible to do:
- * for (FilterClause clause : booleanFilter) {}
- */
- @Override
- public final Iterator iterator() {
- return clauses().iterator();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if ((obj == null) || (obj.getClass() != this.getClass())) {
- return false;
- }
-
- final BooleanFilter other = (BooleanFilter)obj;
- return clauses.equals(other.clauses);
- }
-
- @Override
- public int hashCode() {
- return 657153718 ^ clauses.hashCode();
- }
-
- /** Prints a user-readable version of this Filter. */
- @Override
- public String toString(String field) {
- final StringBuilder buffer = new StringBuilder("BooleanFilter(");
- final int minLen = buffer.length();
- for (final FilterClause c : clauses) {
- if (buffer.length() > minLen) {
- buffer.append(' ');
- }
- buffer.append(c);
- }
- return buffer.append(')').toString();
- }
-}
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/FilterClause.java b/lucene/queries/src/java/org/apache/lucene/queries/FilterClause.java
deleted file mode 100644
index 9ed3a86ff24..00000000000
--- a/lucene/queries/src/java/org/apache/lucene/queries/FilterClause.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package org.apache.lucene.queries;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.apache.lucene.search.BooleanClause.Occur;
-import org.apache.lucene.search.Filter;
-
-/**
- * A Filter that wrapped with an indication of how that filter
- * is used when composed with another filter.
- * (Follows the boolean logic in BooleanClause for composition
- * of queries.)
- */
-public final class FilterClause {
-
- private final Occur occur;
- private final Filter filter;
-
- /**
- * Create a new FilterClause
- * @param filter A Filter object containing a BitSet
- * @param occur A parameter implementation indicating SHOULD, MUST or MUST NOT
- */
-
- public FilterClause(Filter filter, Occur occur) {
- this.occur = occur;
- this.filter = filter;
- }
-
- /**
- * Returns this FilterClause's filter
- * @return A Filter object
- */
- public Filter getFilter() {
- return filter;
- }
-
- /**
- * Returns this FilterClause's occur parameter
- * @return An Occur object
- */
- public Occur getOccur() {
- return occur;
- }
-
- @Override
- public boolean equals(Object o) {
- if (o == this)
- return true;
- if (o == null || !(o instanceof FilterClause))
- return false;
- final FilterClause other = (FilterClause)o;
- return this.filter.equals(other.filter)
- && this.occur == other.occur;
- }
-
- @Override
- public int hashCode() {
- return filter.hashCode() ^ occur.hashCode();
- }
-
- public String toString(String field) {
- return occur.toString() + filter.toString(field);
- }
-
- @Override
- public String toString() {
- return toString("");
- }
-
-}
diff --git a/lucene/queries/src/test/org/apache/lucene/queries/BooleanFilterTest.java b/lucene/queries/src/test/org/apache/lucene/queries/BooleanFilterTest.java
deleted file mode 100644
index 52552bc644c..00000000000
--- a/lucene/queries/src/test/org/apache/lucene/queries/BooleanFilterTest.java
+++ /dev/null
@@ -1,370 +0,0 @@
-package org.apache.lucene.queries;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.io.IOException;
-
-import org.apache.lucene.analysis.MockAnalyzer;
-import org.apache.lucene.analysis.MockTokenizer;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.index.LeafReader;
-import org.apache.lucene.index.LeafReaderContext;
-import org.apache.lucene.index.RandomIndexWriter;
-import org.apache.lucene.index.SlowCompositeReaderWrapper;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.BooleanClause.Occur;
-import org.apache.lucene.search.DocIdSet;
-import org.apache.lucene.search.DocIdSetIterator;
-import org.apache.lucene.search.Filter;
-import org.apache.lucene.search.QueryWrapperFilter;
-import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.TermRangeFilter;
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.BitDocIdSet;
-import org.apache.lucene.util.FixedBitSet;
-import org.apache.lucene.util.LuceneTestCase;
-
-public class BooleanFilterTest extends LuceneTestCase {
- private Directory directory;
- private LeafReader reader;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- directory = newDirectory();
- RandomIndexWriter writer = new RandomIndexWriter(random(), directory, new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false));
-
- //Add series of docs with filterable fields : acces rights, prices, dates and "in-stock" flags
- addDoc(writer, "admin guest", "010", "20040101", "Y");
- addDoc(writer, "guest", "020", "20040101", "Y");
- addDoc(writer, "guest", "020", "20050101", "Y");
- addDoc(writer, "admin", "020", "20050101", "Maybe");
- addDoc(writer, "admin guest", "030", "20050101", "N");
- reader = SlowCompositeReaderWrapper.wrap(writer.getReader());
- writer.close();
- }
-
- @Override
- public void tearDown() throws Exception {
- reader.close();
- directory.close();
- super.tearDown();
- }
-
- private void addDoc(RandomIndexWriter writer, String accessRights, String price, String date, String inStock) throws IOException {
- Document doc = new Document();
- doc.add(newTextField("accessRights", accessRights, Field.Store.YES));
- doc.add(newTextField("price", price, Field.Store.YES));
- doc.add(newTextField("date", date, Field.Store.YES));
- doc.add(newTextField("inStock", inStock, Field.Store.YES));
- writer.addDocument(doc);
- }
-
- private Filter getRangeFilter(String field, String lowerPrice, String upperPrice) {
- Filter f = TermRangeFilter.newStringRange(field, lowerPrice, upperPrice, true, true);
- return f;
- }
-
- private Filter getTermsFilter(String field, String text) {
- return new TermsFilter(new Term(field, text));
- }
-
- private Filter getWrappedTermQuery(String field, String text) {
- return new QueryWrapperFilter(new TermQuery(new Term(field, text)));
- }
-
- private Filter getEmptyFilter() {
- return new Filter() {
- @Override
- public DocIdSet getDocIdSet(LeafReaderContext context, Bits acceptDocs) {
- return new BitDocIdSet(new FixedBitSet(context.reader().maxDoc()));
- }
- @Override
- public String toString(String field) {
- return "emptyFilter";
- }
- };
- }
-
- private Filter getNullDISFilter() {
- return new Filter() {
- @Override
- public DocIdSet getDocIdSet(LeafReaderContext context, Bits acceptDocs) {
- return null;
- }
- @Override
- public String toString(String field) {
- return "nullDISFilter";
- }
- };
- }
-
- private Filter getNullDISIFilter() {
- return new Filter() {
- @Override
- public DocIdSet getDocIdSet(LeafReaderContext context, Bits acceptDocs) {
- return DocIdSet.EMPTY;
- }
- @Override
- public String toString(String field) {
- return "nullDISIFilter";
- }
- };
- }
-
- private void tstFilterCard(String mes, int expected, Filter filt)
- throws Exception {
- final DocIdSet docIdSet = filt.getDocIdSet(reader.getContext(), reader.getLiveDocs());
- int actual = 0;
- if (docIdSet != null) {
- DocIdSetIterator disi = docIdSet.iterator();
- while (disi.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
- actual++;
- }
- }
- assertEquals(mes, expected, actual);
- }
-
-
- public void testShould() throws Exception {
- BooleanFilter booleanFilter = new BooleanFilter();
- booleanFilter.add(getTermsFilter("price", "030"), Occur.SHOULD);
- tstFilterCard("Should retrieves only 1 doc", 1, booleanFilter);
-
- // same with a real DISI (no OpenBitSetIterator)
- booleanFilter = new BooleanFilter();
- booleanFilter.add(getWrappedTermQuery("price", "030"), Occur.SHOULD);
- tstFilterCard("Should retrieves only 1 doc", 1, booleanFilter);
- }
-
- public void testShoulds() throws Exception {
- BooleanFilter booleanFilter = new BooleanFilter();
- booleanFilter.add(getRangeFilter("price", "010", "020"), Occur.SHOULD);
- booleanFilter.add(getRangeFilter("price", "020", "030"), Occur.SHOULD);
- tstFilterCard("Shoulds are Ored together", 5, booleanFilter);
- }
-
- public void testShouldsAndMustNot() throws Exception {
- BooleanFilter booleanFilter = new BooleanFilter();
- booleanFilter.add(getRangeFilter("price", "010", "020"), Occur.SHOULD);
- booleanFilter.add(getRangeFilter("price", "020", "030"), Occur.SHOULD);
- booleanFilter.add(getTermsFilter("inStock", "N"), Occur.MUST_NOT);
- tstFilterCard("Shoulds Ored but AndNot", 4, booleanFilter);
-
- booleanFilter.add(getTermsFilter("inStock", "Maybe"), Occur.MUST_NOT);
- tstFilterCard("Shoulds Ored but AndNots", 3, booleanFilter);
-
- // same with a real DISI (no OpenBitSetIterator)
- booleanFilter = new BooleanFilter();
- booleanFilter.add(getRangeFilter("price", "010", "020"), Occur.SHOULD);
- booleanFilter.add(getRangeFilter("price", "020", "030"), Occur.SHOULD);
- booleanFilter.add(getWrappedTermQuery("inStock", "N"), Occur.MUST_NOT);
- tstFilterCard("Shoulds Ored but AndNot", 4, booleanFilter);
-
- booleanFilter.add(getWrappedTermQuery("inStock", "Maybe"), Occur.MUST_NOT);
- tstFilterCard("Shoulds Ored but AndNots", 3, booleanFilter);
- }
-
- public void testShouldsAndMust() throws Exception {
- BooleanFilter booleanFilter = new BooleanFilter();
- booleanFilter.add(getRangeFilter("price", "010", "020"), Occur.SHOULD);
- booleanFilter.add(getRangeFilter("price", "020", "030"), Occur.SHOULD);
- booleanFilter.add(getTermsFilter("accessRights", "admin"), Occur.MUST);
- tstFilterCard("Shoulds Ored but MUST", 3, booleanFilter);
-
- // same with a real DISI (no OpenBitSetIterator)
- booleanFilter = new BooleanFilter();
- booleanFilter.add(getRangeFilter("price", "010", "020"), Occur.SHOULD);
- booleanFilter.add(getRangeFilter("price", "020", "030"), Occur.SHOULD);
- booleanFilter.add(getWrappedTermQuery("accessRights", "admin"), Occur.MUST);
- tstFilterCard("Shoulds Ored but MUST", 3, booleanFilter);
- }
-
- public void testShouldsAndMusts() throws Exception {
- BooleanFilter booleanFilter = new BooleanFilter();
- booleanFilter.add(getRangeFilter("price", "010", "020"), Occur.SHOULD);
- booleanFilter.add(getRangeFilter("price", "020", "030"), Occur.SHOULD);
- booleanFilter.add(getTermsFilter("accessRights", "admin"), Occur.MUST);
- booleanFilter.add(getRangeFilter("date", "20040101", "20041231"), Occur.MUST);
- tstFilterCard("Shoulds Ored but MUSTs ANDED", 1, booleanFilter);
- }
-
- public void testShouldsAndMustsAndMustNot() throws Exception {
- BooleanFilter booleanFilter = new BooleanFilter();
- booleanFilter.add(getRangeFilter("price", "030", "040"), Occur.SHOULD);
- booleanFilter.add(getTermsFilter("accessRights", "admin"), Occur.MUST);
- booleanFilter.add(getRangeFilter("date", "20050101", "20051231"), Occur.MUST);
- booleanFilter.add(getTermsFilter("inStock", "N"), Occur.MUST_NOT);
- tstFilterCard("Shoulds Ored but MUSTs ANDED and MustNot", 0, booleanFilter);
-
- // same with a real DISI (no OpenBitSetIterator)
- booleanFilter = new BooleanFilter();
- booleanFilter.add(getRangeFilter("price", "030", "040"), Occur.SHOULD);
- booleanFilter.add(getWrappedTermQuery("accessRights", "admin"), Occur.MUST);
- booleanFilter.add(getRangeFilter("date", "20050101", "20051231"), Occur.MUST);
- booleanFilter.add(getWrappedTermQuery("inStock", "N"), Occur.MUST_NOT);
- tstFilterCard("Shoulds Ored but MUSTs ANDED and MustNot", 0, booleanFilter);
- }
-
- public void testJustMust() throws Exception {
- BooleanFilter booleanFilter = new BooleanFilter();
- booleanFilter.add(getTermsFilter("accessRights", "admin"), Occur.MUST);
- tstFilterCard("MUST", 3, booleanFilter);
-
- // same with a real DISI (no OpenBitSetIterator)
- booleanFilter = new BooleanFilter();
- booleanFilter.add(getWrappedTermQuery("accessRights", "admin"), Occur.MUST);
- tstFilterCard("MUST", 3, booleanFilter);
- }
-
- public void testJustMustNot() throws Exception {
- BooleanFilter booleanFilter = new BooleanFilter();
- booleanFilter.add(getTermsFilter("inStock", "N"), Occur.MUST_NOT);
- tstFilterCard("MUST_NOT", 4, booleanFilter);
-
- // same with a real DISI (no OpenBitSetIterator)
- booleanFilter = new BooleanFilter();
- booleanFilter.add(getWrappedTermQuery("inStock", "N"), Occur.MUST_NOT);
- tstFilterCard("MUST_NOT", 4, booleanFilter);
- }
-
- public void testMustAndMustNot() throws Exception {
- BooleanFilter booleanFilter = new BooleanFilter();
- booleanFilter.add(getTermsFilter("inStock", "N"), Occur.MUST);
- booleanFilter.add(getTermsFilter("price", "030"), Occur.MUST_NOT);
- tstFilterCard("MUST_NOT wins over MUST for same docs", 0, booleanFilter);
-
- // same with a real DISI (no OpenBitSetIterator)
- booleanFilter = new BooleanFilter();
- booleanFilter.add(getWrappedTermQuery("inStock", "N"), Occur.MUST);
- booleanFilter.add(getWrappedTermQuery("price", "030"), Occur.MUST_NOT);
- tstFilterCard("MUST_NOT wins over MUST for same docs", 0, booleanFilter);
- }
-
- public void testEmpty() throws Exception {
- BooleanFilter booleanFilter = new BooleanFilter();
- tstFilterCard("empty BooleanFilter returns no results", 0, booleanFilter);
- }
-
- public void testCombinedNullDocIdSets() throws Exception {
- BooleanFilter booleanFilter = new BooleanFilter();
- booleanFilter.add(getTermsFilter("price", "030"), Occur.MUST);
- booleanFilter.add(getNullDISFilter(), Occur.MUST);
- tstFilterCard("A MUST filter that returns a null DIS should never return documents", 0, booleanFilter);
-
- booleanFilter = new BooleanFilter();
- booleanFilter.add(getTermsFilter("price", "030"), Occur.MUST);
- booleanFilter.add(getNullDISIFilter(), Occur.MUST);
- tstFilterCard("A MUST filter that returns a null DISI should never return documents", 0, booleanFilter);
-
- booleanFilter = new BooleanFilter();
- booleanFilter.add(getTermsFilter("price", "030"), Occur.SHOULD);
- booleanFilter.add(getNullDISFilter(), Occur.SHOULD);
- tstFilterCard("A SHOULD filter that returns a null DIS should be invisible", 1, booleanFilter);
-
- booleanFilter = new BooleanFilter();
- booleanFilter.add(getTermsFilter("price", "030"), Occur.SHOULD);
- booleanFilter.add(getNullDISIFilter(), Occur.SHOULD);
- tstFilterCard("A SHOULD filter that returns a null DISI should be invisible", 1, booleanFilter);
-
- booleanFilter = new BooleanFilter();
- booleanFilter.add(getTermsFilter("price", "030"), Occur.MUST);
- booleanFilter.add(getNullDISFilter(), Occur.MUST_NOT);
- tstFilterCard("A MUST_NOT filter that returns a null DIS should be invisible", 1, booleanFilter);
-
- booleanFilter = new BooleanFilter();
- booleanFilter.add(getTermsFilter("price", "030"), Occur.MUST);
- booleanFilter.add(getNullDISIFilter(), Occur.MUST_NOT);
- tstFilterCard("A MUST_NOT filter that returns a null DISI should be invisible", 1, booleanFilter);
- }
-
- public void testJustNullDocIdSets() throws Exception {
- BooleanFilter booleanFilter = new BooleanFilter();
- booleanFilter.add(getNullDISFilter(), Occur.MUST);
- tstFilterCard("A MUST filter that returns a null DIS should never return documents", 0, booleanFilter);
-
- booleanFilter = new BooleanFilter();
- booleanFilter.add(getNullDISIFilter(), Occur.MUST);
- tstFilterCard("A MUST filter that returns a null DISI should never return documents", 0, booleanFilter);
-
- booleanFilter = new BooleanFilter();
- booleanFilter.add(getNullDISFilter(), Occur.SHOULD);
- tstFilterCard("A single SHOULD filter that returns a null DIS should never return documents", 0, booleanFilter);
-
- booleanFilter = new BooleanFilter();
- booleanFilter.add(getNullDISIFilter(), Occur.SHOULD);
- tstFilterCard("A single SHOULD filter that returns a null DISI should never return documents", 0, booleanFilter);
-
- booleanFilter = new BooleanFilter();
- booleanFilter.add(getNullDISFilter(), Occur.MUST_NOT);
- tstFilterCard("A single MUST_NOT filter that returns a null DIS should be invisible", 5, booleanFilter);
-
- booleanFilter = new BooleanFilter();
- booleanFilter.add(getNullDISIFilter(), Occur.MUST_NOT);
- tstFilterCard("A single MUST_NOT filter that returns a null DIS should be invisible", 5, booleanFilter);
- }
-
- public void testNonMatchingShouldsAndMusts() throws Exception {
- BooleanFilter booleanFilter = new BooleanFilter();
- booleanFilter.add(getEmptyFilter(), Occur.SHOULD);
- booleanFilter.add(getTermsFilter("accessRights", "admin"), Occur.MUST);
- tstFilterCard(">0 shoulds with no matches should return no docs", 0, booleanFilter);
-
- booleanFilter = new BooleanFilter();
- booleanFilter.add(getNullDISFilter(), Occur.SHOULD);
- booleanFilter.add(getTermsFilter("accessRights", "admin"), Occur.MUST);
- tstFilterCard(">0 shoulds with no matches should return no docs", 0, booleanFilter);
-
- booleanFilter = new BooleanFilter();
- booleanFilter.add(getNullDISIFilter(), Occur.SHOULD);
- booleanFilter.add(getTermsFilter("accessRights", "admin"), Occur.MUST);
- tstFilterCard(">0 shoulds with no matches should return no docs", 0, booleanFilter);
- }
-
- public void testToStringOfBooleanFilterContainingTermsFilter() {
- BooleanFilter booleanFilter = new BooleanFilter();
- booleanFilter.add(getTermsFilter("inStock", "N"), Occur.MUST);
- booleanFilter.add(getTermsFilter("isFragile", "Y"), Occur.MUST);
-
- assertEquals("BooleanFilter(+inStock:N +isFragile:Y)", booleanFilter.toString());
- }
-
- public void testToStringOfWrappedBooleanFilters() {
- BooleanFilter orFilter = new BooleanFilter();
-
- BooleanFilter stockFilter = new BooleanFilter();
- stockFilter.add(new FilterClause(getTermsFilter("inStock", "Y"), Occur.MUST));
- stockFilter.add(new FilterClause(getTermsFilter("barCode", "12345678"), Occur.MUST));
-
- orFilter.add(new FilterClause(stockFilter,Occur.SHOULD));
-
- BooleanFilter productPropertyFilter = new BooleanFilter();
- productPropertyFilter.add(new FilterClause(getTermsFilter("isHeavy", "N"), Occur.MUST));
- productPropertyFilter.add(new FilterClause(getTermsFilter("isDamaged", "Y"), Occur.MUST));
-
- orFilter.add(new FilterClause(productPropertyFilter,Occur.SHOULD));
-
- BooleanFilter composedFilter = new BooleanFilter();
- composedFilter.add(new FilterClause(orFilter,Occur.MUST));
-
- assertEquals("BooleanFilter(+BooleanFilter(BooleanFilter(+inStock:Y +barCode:12345678) BooleanFilter(+isHeavy:N +isDamaged:Y)))",
- composedFilter.toString());
- }
-}
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/CorePlusExtensionsParser.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/CorePlusExtensionsParser.java
index 8d69d62a738..ec53e14d6b4 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/CorePlusExtensionsParser.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/CorePlusExtensionsParser.java
@@ -50,7 +50,6 @@ public class CorePlusExtensionsParser extends CoreParser {
private CorePlusExtensionsParser(String defaultField, Analyzer analyzer, QueryParser parser) {
super(defaultField, analyzer, parser);
filterFactory.addBuilder("TermsFilter", new TermsFilterBuilder(analyzer));
- filterFactory.addBuilder("BooleanFilter", new BooleanFilterBuilder(filterFactory));
filterFactory.addBuilder("DuplicateFilter", new DuplicateFilterBuilder());
String fields[] = {"contents"};
queryFactory.addBuilder("LikeThisQuery", new LikeThisQueryBuilder(analyzer, fields));
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/BooleanFilterBuilder.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/BooleanFilterBuilder.java
deleted file mode 100644
index 953a5847ab4..00000000000
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/BooleanFilterBuilder.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Created on 25-Jan-2006
- */
-package org.apache.lucene.queryparser.xml.builders;
-
-import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.queries.BooleanFilter;
-import org.apache.lucene.search.Filter;
-import org.apache.lucene.queries.FilterClause;
-import org.apache.lucene.queryparser.xml.DOMUtils;
-import org.apache.lucene.queryparser.xml.FilterBuilder;
-import org.apache.lucene.queryparser.xml.ParserException;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Builder for {@link BooleanFilter}
- */
-public class BooleanFilterBuilder implements FilterBuilder {
-
- private final FilterBuilder factory;
-
- public BooleanFilterBuilder(FilterBuilder factory) {
- this.factory = factory;
- }
-
- @Override
- public Filter getFilter(Element e) throws ParserException {
- BooleanFilter bf = new BooleanFilter();
- NodeList nl = e.getChildNodes();
-
- for (int i = 0; i < nl.getLength(); i++) {
- Node node = nl.item(i);
- if (node.getNodeName().equals("Clause")) {
- Element clauseElem = (Element) node;
- BooleanClause.Occur occurs = BooleanQueryBuilder.getOccursValue(clauseElem);
-
- Element clauseFilter = DOMUtils.getFirstChildOrFail(clauseElem);
- Filter f = factory.getFilter(clauseFilter);
- bf.add(new FilterClause(f, occurs));
- }
- }
-
- return bf;
- }
-
-}
diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/BooleanFilter.xml b/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/BooleanFilter.xml
deleted file mode 100644
index b601d791fd1..00000000000
--- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/BooleanFilter.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Emcore
-
-
-
-
-
-
-
diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java
index e5c61c2fe3f..bf1ad374de8 100644
--- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java
+++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java
@@ -181,11 +181,6 @@ public class TestParser extends LuceneTestCase {
dumpResults("MatchAllDocsQuery with range filter", q, 5);
}
- public void testBooleanFilterXML() throws ParserException, IOException {
- Query q = parse("BooleanFilter.xml");
- dumpResults("Boolean filter", q, 5);
- }
-
public void testNestedBooleanQuery() throws ParserException, IOException {
Query q = parse("NestedBooleanQuery.xml");
dumpResults("Nested Boolean query", q, 5);
diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/BaseBitSetTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/util/BaseBitSetTestCase.java
index b0abcfd1bb3..f59c63a0ac2 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/util/BaseBitSetTestCase.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/util/BaseBitSetTestCase.java
@@ -204,71 +204,6 @@ public abstract class BaseBitSetTestCase extends LuceneTestCas
testOr(random().nextFloat());
}
- private void testAnd(float load) throws IOException {
- final int numBits = 1 + random().nextInt(100000);
- BitSet set1 = new JavaUtilBitSet(randomSet(numBits, numBits), numBits); // full
- T set2 = copyOf(set1, numBits);
-
- final int iterations = atLeast(10);
- for (int iter = 0; iter < iterations; ++iter) {
- // BitSets have specializations to merge with certain impls, so we randomize the impl...
- DocIdSet otherSet = randomCopy(new JavaUtilBitSet(randomSet(numBits, load), numBits), numBits);
- DocIdSetIterator otherIterator = otherSet.iterator();
- if (otherIterator != null) {
- set1.and(otherIterator);
- set2.and(otherSet.iterator());
- assertEquals(set1, set2, numBits);
- }
- }
- }
-
- /** Test {@link BitSet#and(DocIdSetIterator)} on sparse sets. */
- public void testAndSparse() throws IOException {
- testAnd(0.1f);
- }
-
- /** Test {@link BitSet#and(DocIdSetIterator)} on dense sets. */
- public void testAndDense() throws IOException {
- testAnd(0.99f);
- }
-
- /** Test {@link BitSet#and(DocIdSetIterator)} on a random density. */
- public void testAndRandom() throws IOException {
- testAnd(random().nextFloat());
- }
-
- private void testAndNot(float load) throws IOException {
- final int numBits = 1 + random().nextInt(100000);
- BitSet set1 = new JavaUtilBitSet(randomSet(numBits, numBits), numBits); // full
- T set2 = copyOf(set1, numBits);
-
- final int iterations = atLeast(10);
- for (int iter = 0; iter < iterations; ++iter) {
- DocIdSet otherSet = randomCopy(new JavaUtilBitSet(randomSet(numBits, load), numBits), numBits);
- DocIdSetIterator otherIterator = otherSet.iterator();
- if (otherIterator != null) {
- set1.andNot(otherIterator);
- set2.andNot(otherSet.iterator());
- assertEquals(set1, set2, numBits);
- }
- }
- }
-
- /** Test {@link BitSet#andNot(DocIdSetIterator)} on sparse sets. */
- public void testAndNotSparse() throws IOException {
- testAndNot(0.01f);
- }
-
- /** Test {@link BitSet#andNot(DocIdSetIterator)} on dense sets. */
- public void testAndNotDense() throws IOException {
- testAndNot(0.9f);
- }
-
- /** Test {@link BitSet#andNot(DocIdSetIterator)} on a random density. */
- public void testAndNotRandom() throws IOException {
- testAndNot(random().nextFloat());
- }
-
private static class JavaUtilBitSet extends BitSet {
private final java.util.BitSet bitSet;
diff --git a/solr/core/src/java/org/apache/solr/schema/CurrencyField.java b/solr/core/src/java/org/apache/solr/schema/CurrencyField.java
index 3adf119e33b..74ae79ce59a 100644
--- a/solr/core/src/java/org/apache/solr/schema/CurrencyField.java
+++ b/solr/core/src/java/org/apache/solr/schema/CurrencyField.java
@@ -37,10 +37,10 @@ import org.apache.lucene.analysis.util.ResourceLoader;
import org.apache.lucene.analysis.util.ResourceLoaderAware;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.StorableField;
-import org.apache.lucene.queries.BooleanFilter;
import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.search.BooleanClause.Occur;
+import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.FieldValueQuery;
import org.apache.lucene.search.Filter;
import org.apache.lucene.search.Query;
@@ -335,12 +335,11 @@ public class CurrencyField extends FieldType implements SchemaAware, ResourceLoa
p1 == null ? null : p1.getAmount() + "",
p2 == null ? null : p2.getAmount() + "",
minInclusive, maxInclusive);
- final BooleanFilter docsInRange = new BooleanFilter();
- docsInRange.add(docsWithValues, Occur.MUST);
- docsInRange.add(vsRangeFilter, Occur.MUST);
+ final BooleanQuery docsInRange = new BooleanQuery();
+ docsInRange.add(docsWithValues, Occur.FILTER);
+ docsInRange.add(vsRangeFilter, Occur.FILTER);
- return new SolrConstantScoreQuery(docsInRange);
-
+ return new SolrConstantScoreQuery(new QueryWrapperFilter(docsInRange));
}
@Override