Skip to content

Commit 2157286

Browse files
committed
Increase the document count.
1 parent 38c788a commit 2157286

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/query/boolean_query/mod.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,16 @@ mod proptest_boolean_query {
375375
}
376376
}
377377

378-
fn create_index_with_boolean_permutations(num_fields: usize) -> (Index, Vec<Field>) {
378+
fn doc_ids(num_docs: usize, num_fields: usize) -> impl Iterator<Item = DocId> {
379+
let permutations = 1 << num_fields;
380+
let copies = (num_docs as f32 / permutations as f32).ceil() as u32;
381+
(0..(permutations * copies)).into_iter()
382+
}
383+
384+
fn create_index_with_boolean_permutations(
385+
num_docs: usize,
386+
num_fields: usize,
387+
) -> (Index, Vec<Field>) {
379388
let mut schema_builder = Schema::builder();
380389
let fields: Vec<Field> = (0..num_fields)
381390
.map(|i| schema_builder.add_text_field(&format!("field_{}", i), TEXT))
@@ -384,10 +393,10 @@ mod proptest_boolean_query {
384393
let index = Index::create_in_ram(schema);
385394
let mut writer = index.writer_for_tests().unwrap();
386395

387-
for doc_id in 0..(1 << num_fields) {
396+
for doc_id in doc_ids(num_docs, num_fields) {
388397
let mut doc: BTreeMap<_, OwnedValue> = BTreeMap::default();
389398
for (field_idx, &field) in fields.iter().enumerate() {
390-
if (doc_id >> field_idx) & 1 == 1 {
399+
if BooleanQueryAST::matches_field(doc_id, field_idx) {
391400
doc.insert(field, "true".into());
392401
}
393402
}
@@ -414,14 +423,15 @@ mod proptest_boolean_query {
414423

415424
#[test]
416425
fn proptest_boolean_query() {
426+
let num_docs = 10000;
417427
let num_fields = 8;
418-
let (index, fields) = create_index_with_boolean_permutations(num_fields);
428+
let (index, fields) = create_index_with_boolean_permutations(num_docs, num_fields);
419429
let searcher = index.reader().unwrap().searcher();
420430
proptest!(|(ast in arb_boolean_query_ast(num_fields))| {
421431
let query = ast.to_query(&fields);
422432

423433
let mut matching_docs = HashSet::new();
424-
for doc_id in 0..(1 << num_fields) {
434+
for doc_id in doc_ids(num_docs, num_fields) {
425435
if ast.matches(doc_id as DocId) {
426436
matching_docs.insert(doc_id as DocId);
427437
}

0 commit comments

Comments
 (0)