use of com.greplin.lucene.util.IntersectionProvider 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);
}
use of com.greplin.lucene.util.IntersectionProvider in project greplin-lucene-utils by Cue.
the class PhraseFilterTest method testIntersectionWithFilter.
@Test
public void testIntersectionWithFilter() throws Exception {
IndexReader reader = createReaderWithSampleDocuments();
IntersectionProvider filter = new FilterIntersectionProvider(TermsFilter.from(new Term("name", "one"), new Term("name", "two")));
assertFilterBitsEqual(reader, new PhraseFilter("f", "world"), true, true, true);
assertFilterBitsEqual(reader, new PhraseFilter(filter, "f", "world"), true, true, false);
assertFilterBitsEqual(reader, new PhraseFilter("f", "hello", "world"), true, false, true);
assertFilterBitsEqual(reader, new PhraseFilter(filter, "f", "hello", "world"), true, false, false);
}
Aggregations