TestSuite *ts_1710(TestSuite *suite) { Store *store = open_ram_store(); suite = ADD_SUITE(suite); tst_run_test(suite, test_problem_text, store); store_deref(store); return suite; }
Index *index_new(Store *store, Analyzer *analyzer, HashSet *def_fields, bool create) { Index *self = ALLOC_AND_ZERO(Index); HashSetEntry *hse; /* FIXME: need to add these to the query parser */ self->config = default_config; mutex_init(&self->mutex, NULL); self->has_writes = false; if (store) { REF(store); self->store = store; } else { self->store = open_ram_store(); create = true; } if (analyzer) { self->analyzer = analyzer; REF(analyzer); } else { self->analyzer = mb_standard_analyzer_new(true); } if (create) { FieldInfos *fis = fis_new(STORE_YES, INDEX_YES, TERM_VECTOR_WITH_POSITIONS_OFFSETS); index_create(self->store, fis); fis_deref(fis); } /* options */ self->key = NULL; self->id_field = intern("id"); self->def_field = intern("id"); self->auto_flush = false; self->check_latest = true; REF(self->analyzer); self->qp = qp_new(self->analyzer); for (hse = def_fields->first; hse; hse = hse->next) { qp_add_field(self->qp, (Symbol)hse->elem, true, true); } /* Index is a convenience class so set qp convenience options */ self->qp->allow_any_fields = true; self->qp->clean_str = true; self->qp->handle_parse_errors = true; return self; }
Store *open_ram_store_and_copy(Store *from_store, bool close_dir) { Store *store = open_ram_store(); struct CopyFileArg cfa; cfa.to_store = store; cfa.from_store = from_store; from_store->each(from_store, ©_files, &cfa); if (close_dir) { store_deref(from_store); } return store; }
TestSuite *ts_sort(TestSuite *suite) { Searcher *sea, **searchers; Store *store = open_ram_store(), *fs_store; search = intern("search"); string = intern("string"); integer = intern("integer"); flt = intern("flt"); sort_test_setup(store); suite = ADD_SUITE(suite); tst_run_test(suite, test_sort_field_to_s, NULL); tst_run_test(suite, test_sort_to_s, NULL); sea = isea_new(ir_open(store)); tst_run_test(suite, test_sorts, (void *)sea); searcher_close(sea); do_byte_test = false; #ifdef POSH_OS_WIN32 fs_store = open_fs_store(".\\test\\testdir\\store"); #else fs_store = open_fs_store("./test/testdir/store"); #endif sort_multi_test_setup(store, fs_store); searchers = ALLOC_N(Searcher *, 2); searchers[0] = isea_new(ir_open(store)); searchers[1] = isea_new(ir_open(fs_store)); sea = msea_new(searchers, 2, true); tst_run_test(suite, test_sorts, (void *)sea); searcher_close(sea); store_deref(store); store_deref(fs_store); return suite; }
TestSuite *ts_filter(TestSuite *suite) { Store *store; IndexReader *ir; Searcher *searcher; suite = ADD_SUITE(suite); store = open_ram_store(); prepare_filter_index(store); ir = ir_open(store); searcher = isea_new(ir); tst_run_test(suite, test_range_filter, (void *)searcher); tst_run_test(suite, test_range_filter_hash, NULL); tst_run_test(suite, test_query_filter, (void *)searcher); tst_run_test(suite, test_query_filter_hash, NULL); tst_run_test(suite, test_filter_func, searcher); tst_run_test(suite, test_score_altering_filter_func, searcher); store_deref(store); searcher->close(searcher); return suite; }
IndexWriter * frjs_iw_init(bool create, bool create_if_missing, Store *store, Analyzer *analyzer, FieldInfos *fis) { IndexWriter *iw = NULL; Config config = default_config; // rb_scan_args(argc, argv, "01", &roptions); /*if (argc > 0) { Check_Type(roptions, T_HASH); if ((rval = rb_hash_aref(roptions, sym_dir)) != Qnil) { Check_Type(rval, T_DATA); store = DATA_PTR(rval); } else if ((rval = rb_hash_aref(roptions, sym_path)) != Qnil) { StringValue(rval); frb_create_dir(rval); store = open_fs_store(rs2s(rval)); DEREF(store); } // Let ruby's garbage collector handle the closing of the store // if (!close_dir) { // close_dir = RTEST(rb_hash_aref(roptions, sym_close_dir)); // } // use_compound_file defaults to true config.use_compound_file = (rb_hash_aref(roptions, sym_use_compound_file) == Qfalse) ? false : true; if ((rval = rb_hash_aref(roptions, sym_analyzer)) != Qnil) { analyzer = frb_get_cwrapped_analyzer(rval); } create = RTEST(rb_hash_aref(roptions, sym_create)); if ((rval = rb_hash_aref(roptions, sym_create_if_missing)) != Qnil) { create_if_missing = RTEST(rval); } SET_INT_ATTR(chunk_size); SET_INT_ATTR(max_buffer_memory); SET_INT_ATTR(index_interval); SET_INT_ATTR(skip_interval); SET_INT_ATTR(merge_factor); SET_INT_ATTR(max_buffered_docs); SET_INT_ATTR(max_merge_docs); SET_INT_ATTR(max_field_length); }*/ if (NULL == store) { store = open_ram_store(); DEREF(store); } if (!create && create_if_missing && !store->exists(store, "segments")) { create = true; } if (create) { if (fis != NULL) { index_create(store, fis); } else { fis = fis_new(STORE_YES, INDEX_YES, TERM_VECTOR_WITH_POSITIONS_OFFSETS); index_create(store, fis); fis_deref(fis); } } iw = iw_open(store, analyzer, &config); return iw; }