Search in sources :

Example 1 with BitsProvider

use of com.greplin.lucene.predicate.BitsProvider in project greplin-lucene-utils by Cue.

the class PhraseFilterTest method testIntersectionWithPredicate.

@Test
public void testIntersectionWithPredicate() throws Exception {
    IndexReader reader = createReaderWithSampleDocuments();
    IntersectionProvider predicate = new BitsProviderIntersectionProvider(new BitsProvider() {

        @Override
        public Bits get(IndexReader reader) throws IOException {
            return new Bits() {

                @Override
                public boolean get(int index) {
                    return index != 0;
                }

                @Override
                public int length() {
                    return 3;
                }
            };
        }
    });
    assertFilterBitsEqual(reader, new PhraseFilter("f", "world"), true, true, true);
    assertFilterBitsEqual(reader, new PhraseFilter(predicate, "f", "world"), false, true, true);
    assertFilterBitsEqual(reader, new PhraseFilter("f", "hello", "world"), true, false, true);
    assertFilterBitsEqual(reader, new PhraseFilter(predicate, "f", "hello", "world"), false, false, true);
}
Also used : BitsProviderIntersectionProvider(com.greplin.lucene.util.BitsProviderIntersectionProvider) IndexReader(org.apache.lucene.index.IndexReader) Bits(org.apache.lucene.util.Bits) BitsProvider(com.greplin.lucene.predicate.BitsProvider) IOException(java.io.IOException) BitsProviderIntersectionProvider(com.greplin.lucene.util.BitsProviderIntersectionProvider) FilterIntersectionProvider(com.greplin.lucene.util.FilterIntersectionProvider) IntersectionProvider(com.greplin.lucene.util.IntersectionProvider) Test(org.junit.Test)

Aggregations

BitsProvider (com.greplin.lucene.predicate.BitsProvider)1 BitsProviderIntersectionProvider (com.greplin.lucene.util.BitsProviderIntersectionProvider)1 FilterIntersectionProvider (com.greplin.lucene.util.FilterIntersectionProvider)1 IntersectionProvider (com.greplin.lucene.util.IntersectionProvider)1 IOException (java.io.IOException)1 IndexReader (org.apache.lucene.index.IndexReader)1 Bits (org.apache.lucene.util.Bits)1 Test (org.junit.Test)1