isomorfeus-ferret 0.12.6 → 0.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +101 -19
- data/README.md +85 -16
- data/ext/isomorfeus_ferret_ext/bm_bitvector.c +22 -30
- data/ext/isomorfeus_ferret_ext/bm_hash.c +6 -12
- data/ext/isomorfeus_ferret_ext/bm_micro_string.c +3 -6
- data/ext/isomorfeus_ferret_ext/bm_store.c +11 -22
- data/ext/isomorfeus_ferret_ext/brotli_common_constants.c +15 -0
- data/ext/isomorfeus_ferret_ext/brotli_common_constants.h +200 -0
- data/ext/isomorfeus_ferret_ext/brotli_common_context.c +156 -0
- data/ext/isomorfeus_ferret_ext/brotli_common_context.h +113 -0
- data/ext/isomorfeus_ferret_ext/brotli_common_dictionary.c +5914 -0
- data/ext/isomorfeus_ferret_ext/brotli_common_dictionary.h +64 -0
- data/ext/isomorfeus_ferret_ext/brotli_common_platform.c +22 -0
- data/ext/isomorfeus_ferret_ext/brotli_common_platform.h +594 -0
- data/ext/isomorfeus_ferret_ext/brotli_common_transform.c +291 -0
- data/ext/isomorfeus_ferret_ext/brotli_common_transform.h +85 -0
- data/ext/isomorfeus_ferret_ext/brotli_common_version.h +26 -0
- data/ext/isomorfeus_ferret_ext/brotli_dec_bit_reader.c +76 -0
- data/ext/isomorfeus_ferret_ext/brotli_dec_bit_reader.h +351 -0
- data/ext/isomorfeus_ferret_ext/brotli_dec_decode.c +2608 -0
- data/ext/isomorfeus_ferret_ext/brotli_dec_huffman.c +339 -0
- data/ext/isomorfeus_ferret_ext/brotli_dec_huffman.h +121 -0
- data/ext/isomorfeus_ferret_ext/brotli_dec_prefix.h +732 -0
- data/ext/isomorfeus_ferret_ext/brotli_dec_state.c +159 -0
- data/ext/isomorfeus_ferret_ext/brotli_dec_state.h +365 -0
- data/ext/isomorfeus_ferret_ext/brotli_decode.h +344 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_backward_references.c +145 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_backward_references.h +39 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_backward_references_hq.c +843 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_backward_references_hq.h +95 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_backward_references_inc.h +163 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_bit_cost.c +35 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_bit_cost.h +63 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_bit_cost_inc.h +127 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_block_encoder_inc.h +34 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_block_splitter.c +194 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_block_splitter.h +51 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_block_splitter_inc.h +440 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_brotli_bit_stream.c +1314 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_brotli_bit_stream.h +84 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_cluster.c +56 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_cluster.h +48 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_cluster_inc.h +320 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_command.c +28 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_command.h +190 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_compress_fragment.c +790 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_compress_fragment.h +61 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_compress_fragment_two_pass.c +645 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_compress_fragment_two_pass.h +54 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_dictionary_hash.c +1846 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_dictionary_hash.h +25 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_encode.c +1927 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_encoder_dict.c +33 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_encoder_dict.h +43 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_entropy_encode.c +503 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_entropy_encode.h +122 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_entropy_encode_static.h +539 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_fast_log.c +105 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_fast_log.h +66 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_find_match_length.h +79 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_hash.h +488 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_hash_composite_inc.h +125 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_hash_forgetful_chain_inc.h +293 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_hash_longest_match64_inc.h +267 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_hash_longest_match_inc.h +262 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_hash_longest_match_quickly_inc.h +266 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_hash_rolling_inc.h +212 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_hash_to_binary_tree_inc.h +329 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_histogram.c +100 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_histogram.h +63 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_histogram_inc.h +51 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_literal_cost.c +175 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_literal_cost.h +30 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_memory.c +170 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_memory.h +114 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_metablock.c +663 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_metablock.h +105 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_metablock_inc.h +183 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_params.h +46 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_prefix.h +53 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_quality.h +165 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_ringbuffer.h +167 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_static_dict.c +486 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_static_dict.h +40 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_static_dict_lut.h +5864 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_utf8_util.c +85 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_utf8_util.h +32 -0
- data/ext/isomorfeus_ferret_ext/brotli_enc_write_bits.h +87 -0
- data/ext/isomorfeus_ferret_ext/brotli_encode.h +448 -0
- data/ext/isomorfeus_ferret_ext/brotli_port.h +288 -0
- data/ext/isomorfeus_ferret_ext/brotli_types.h +83 -0
- data/ext/isomorfeus_ferret_ext/bzlib.c +1572 -0
- data/ext/isomorfeus_ferret_ext/bzlib.h +282 -0
- data/ext/isomorfeus_ferret_ext/bzlib_blocksort.c +1094 -0
- data/ext/isomorfeus_ferret_ext/bzlib_compress.c +672 -0
- data/ext/isomorfeus_ferret_ext/bzlib_crctable.c +104 -0
- data/ext/isomorfeus_ferret_ext/bzlib_decompress.c +652 -0
- data/ext/isomorfeus_ferret_ext/bzlib_huffman.c +205 -0
- data/ext/isomorfeus_ferret_ext/bzlib_private.h +509 -0
- data/ext/isomorfeus_ferret_ext/bzlib_randtable.c +84 -0
- data/ext/isomorfeus_ferret_ext/fio_tmpfile.h +53 -53
- data/ext/isomorfeus_ferret_ext/frb_analysis.c +785 -1192
- data/ext/isomorfeus_ferret_ext/frb_index.c +513 -464
- data/ext/isomorfeus_ferret_ext/frb_qparser.c +48 -60
- data/ext/isomorfeus_ferret_ext/frb_search.c +1520 -1002
- data/ext/isomorfeus_ferret_ext/frb_store.c +96 -96
- data/ext/isomorfeus_ferret_ext/frb_threading.h +0 -1
- data/ext/isomorfeus_ferret_ext/frb_utils.c +147 -196
- data/ext/isomorfeus_ferret_ext/frt_analysis.c +695 -1090
- data/ext/isomorfeus_ferret_ext/frt_analysis.h +174 -170
- data/ext/isomorfeus_ferret_ext/frt_array.c +2 -4
- data/ext/isomorfeus_ferret_ext/frt_bitvector.c +9 -16
- data/ext/isomorfeus_ferret_ext/frt_bitvector.h +32 -81
- data/ext/isomorfeus_ferret_ext/frt_document.c +15 -20
- data/ext/isomorfeus_ferret_ext/frt_document.h +10 -9
- data/ext/isomorfeus_ferret_ext/frt_except.c +5 -12
- data/ext/isomorfeus_ferret_ext/frt_field_index.c +3 -3
- data/ext/isomorfeus_ferret_ext/frt_field_index.h +6 -7
- data/ext/isomorfeus_ferret_ext/frt_filter.c +35 -46
- data/ext/isomorfeus_ferret_ext/frt_fs_store.c +2 -0
- data/ext/isomorfeus_ferret_ext/frt_global.c +91 -200
- data/ext/isomorfeus_ferret_ext/frt_global.h +7 -18
- data/ext/isomorfeus_ferret_ext/frt_hash.c +1 -2
- data/ext/isomorfeus_ferret_ext/frt_ind.c +32 -35
- data/ext/isomorfeus_ferret_ext/frt_ind.h +9 -9
- data/ext/isomorfeus_ferret_ext/frt_index.c +714 -384
- data/ext/isomorfeus_ferret_ext/frt_index.h +274 -290
- data/ext/isomorfeus_ferret_ext/frt_lang.c +0 -2
- data/ext/isomorfeus_ferret_ext/frt_mempool.c +1 -2
- data/ext/isomorfeus_ferret_ext/frt_multimapper.c +4 -7
- data/ext/isomorfeus_ferret_ext/frt_q_boolean.c +68 -91
- data/ext/isomorfeus_ferret_ext/frt_q_const_score.c +35 -38
- data/ext/isomorfeus_ferret_ext/frt_q_filtered_query.c +53 -72
- data/ext/isomorfeus_ferret_ext/frt_q_fuzzy.c +25 -32
- data/ext/isomorfeus_ferret_ext/frt_q_match_all.c +21 -23
- data/ext/isomorfeus_ferret_ext/frt_q_multi_term.c +66 -103
- data/ext/isomorfeus_ferret_ext/frt_q_parser.c +207 -195
- data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +20 -16
- data/ext/isomorfeus_ferret_ext/frt_q_prefix.c +17 -14
- data/ext/isomorfeus_ferret_ext/frt_q_range.c +102 -131
- data/ext/isomorfeus_ferret_ext/frt_q_span.c +179 -178
- data/ext/isomorfeus_ferret_ext/frt_q_term.c +47 -60
- data/ext/isomorfeus_ferret_ext/frt_q_wildcard.c +18 -16
- data/ext/isomorfeus_ferret_ext/frt_ram_store.c +46 -84
- data/ext/isomorfeus_ferret_ext/frt_search.c +105 -146
- data/ext/isomorfeus_ferret_ext/frt_search.h +331 -320
- data/ext/isomorfeus_ferret_ext/frt_similarity.c +5 -13
- data/ext/isomorfeus_ferret_ext/frt_similarity.h +7 -12
- data/ext/isomorfeus_ferret_ext/frt_sort.c +105 -149
- data/ext/isomorfeus_ferret_ext/frt_store.c +13 -7
- data/ext/isomorfeus_ferret_ext/frt_store.h +10 -2
- data/ext/isomorfeus_ferret_ext/frt_threading.h +0 -1
- data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +22 -112
- data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.h +2 -32
- data/ext/isomorfeus_ferret_ext/lz4.c +2495 -0
- data/ext/isomorfeus_ferret_ext/lz4.h +774 -0
- data/ext/isomorfeus_ferret_ext/lz4frame.c +1899 -0
- data/ext/isomorfeus_ferret_ext/lz4frame.h +623 -0
- data/ext/isomorfeus_ferret_ext/lz4hc.c +1615 -0
- data/ext/isomorfeus_ferret_ext/lz4hc.h +413 -0
- data/ext/isomorfeus_ferret_ext/lz4xxhash.c +1030 -0
- data/ext/isomorfeus_ferret_ext/lz4xxhash.h +328 -0
- data/ext/isomorfeus_ferret_ext/stem_modules.h +0 -86
- data/ext/isomorfeus_ferret_ext/test.c +0 -17
- data/ext/isomorfeus_ferret_ext/test_1710.c +11 -12
- data/ext/isomorfeus_ferret_ext/test_analysis.c +590 -583
- data/ext/isomorfeus_ferret_ext/test_compound_io.c +1 -1
- data/ext/isomorfeus_ferret_ext/test_document.c +19 -15
- data/ext/isomorfeus_ferret_ext/test_except.c +1 -2
- data/ext/isomorfeus_ferret_ext/test_fields.c +111 -100
- data/ext/isomorfeus_ferret_ext/test_file_deleter.c +10 -27
- data/ext/isomorfeus_ferret_ext/test_filter.c +11 -8
- data/ext/isomorfeus_ferret_ext/test_global.c +0 -46
- data/ext/isomorfeus_ferret_ext/test_hash.c +2 -2
- data/ext/isomorfeus_ferret_ext/test_hashset.c +1 -1
- data/ext/isomorfeus_ferret_ext/test_highlighter.c +15 -11
- data/ext/isomorfeus_ferret_ext/test_index.c +373 -363
- data/ext/isomorfeus_ferret_ext/test_q_const_score.c +5 -3
- data/ext/isomorfeus_ferret_ext/test_q_filtered.c +5 -3
- data/ext/isomorfeus_ferret_ext/test_q_fuzzy.c +13 -10
- data/ext/isomorfeus_ferret_ext/test_q_parser.c +45 -7
- data/ext/isomorfeus_ferret_ext/test_q_span.c +15 -12
- data/ext/isomorfeus_ferret_ext/test_ram_store.c +3 -3
- data/ext/isomorfeus_ferret_ext/test_search.c +60 -64
- data/ext/isomorfeus_ferret_ext/test_segments.c +5 -4
- data/ext/isomorfeus_ferret_ext/test_sort.c +17 -14
- data/ext/isomorfeus_ferret_ext/test_store.c +2 -0
- data/ext/isomorfeus_ferret_ext/test_term.c +3 -1
- data/ext/isomorfeus_ferret_ext/test_term_vectors.c +9 -10
- data/ext/isomorfeus_ferret_ext/test_test.c +1 -2
- data/ext/isomorfeus_ferret_ext/test_threading.c +9 -10
- data/ext/isomorfeus_ferret_ext/testhelper.c +1 -2
- data/lib/isomorfeus/ferret/version.rb +1 -1
- metadata +113 -58
- data/ext/isomorfeus_ferret_ext/email.rl +0 -21
- data/ext/isomorfeus_ferret_ext/frt_scanner.c +0 -900
- data/ext/isomorfeus_ferret_ext/frt_scanner.h +0 -28
- data/ext/isomorfeus_ferret_ext/frt_scanner_mb.c +0 -6706
- data/ext/isomorfeus_ferret_ext/frt_scanner_utf8.c +0 -4420
- data/ext/isomorfeus_ferret_ext/scanner.h +0 -28
- data/ext/isomorfeus_ferret_ext/scanner.in +0 -43
- data/ext/isomorfeus_ferret_ext/scanner.rl +0 -84
- data/ext/isomorfeus_ferret_ext/scanner_mb.rl +0 -200
- data/ext/isomorfeus_ferret_ext/scanner_utf8.rl +0 -85
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_basque.c +0 -1167
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_basque.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_catalan.c +0 -1433
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_catalan.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_danish.c +0 -301
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_danish.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_dutch.c +0 -590
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_dutch.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_english.c +0 -1049
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_english.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_finnish.c +0 -705
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_finnish.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_french.c +0 -1239
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_french.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_german.c +0 -477
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_german.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_hungarian.c +0 -1217
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_hungarian.h +0 -7
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_indonesian.c +0 -394
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_indonesian.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_irish.c +0 -457
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_irish.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_italian.c +0 -1009
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_italian.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_norwegian.c +0 -259
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_norwegian.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_porter.c +0 -704
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_porter.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_portuguese.c +0 -948
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_portuguese.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_spanish.c +0 -1028
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_spanish.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_swedish.c +0 -275
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_swedish.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_hungarian.c +0 -849
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_hungarian.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_romanian.c +0 -952
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_romanian.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_KOI8_R_russian.c +0 -669
- data/ext/isomorfeus_ferret_ext/stem_KOI8_R_russian.h +0 -6
- data/ext/isomorfeus_ferret_ext/stem_modules.txt +0 -63
- data/ext/isomorfeus_ferret_ext/uchar-ucs4.rl +0 -1854
- data/ext/isomorfeus_ferret_ext/uchar-utf8.rl +0 -1999
- data/ext/isomorfeus_ferret_ext/url.rl +0 -27
@@ -5,9 +5,11 @@
|
|
5
5
|
#include "testhelper.h"
|
6
6
|
#include "test.h"
|
7
7
|
|
8
|
+
#undef close
|
9
|
+
|
8
10
|
#define ARRAY_SIZE 40
|
9
11
|
|
10
|
-
static
|
12
|
+
static ID date, field, cat, number;
|
11
13
|
|
12
14
|
static void test_byte_float_conversion(TestCase *tc, void *data)
|
13
15
|
{
|
@@ -19,9 +21,7 @@ static void test_byte_float_conversion(TestCase *tc, void *data)
|
|
19
21
|
}
|
20
22
|
}
|
21
23
|
|
22
|
-
static int my_doc_freq(FrtSearcher *searcher,
|
23
|
-
const char *term)
|
24
|
-
{
|
24
|
+
static int my_doc_freq(FrtSearcher *searcher, ID field, const char *term) {
|
25
25
|
(void)searcher; (void)field; (void)term;
|
26
26
|
return 9;
|
27
27
|
}
|
@@ -137,14 +137,13 @@ static FrtTokenStream *dbl_tf_clone_i(FrtTokenStream *ts)
|
|
137
137
|
|
138
138
|
static FrtTokenStream *dbl_tf_new(FrtTokenStream *sub_ts)
|
139
139
|
{
|
140
|
-
FrtTokenStream *ts =
|
141
|
-
ts->next
|
142
|
-
ts->clone_i
|
140
|
+
FrtTokenStream *ts = frt_tf_new_i(sizeof(DoubleFilter), sub_ts);
|
141
|
+
ts->next = &dbl_tf_next;
|
142
|
+
ts->clone_i = &dbl_tf_clone_i;
|
143
143
|
return ts;
|
144
144
|
}
|
145
145
|
|
146
|
-
FrtAnalyzer *dbl_analyzer_new()
|
147
|
-
{
|
146
|
+
FrtAnalyzer *dbl_analyzer_new(void) {
|
148
147
|
FrtTokenStream *ts;
|
149
148
|
ts = dbl_tf_new(frt_whitespace_tokenizer_new());
|
150
149
|
return frt_analyzer_new(ts, NULL, NULL);
|
@@ -206,20 +205,21 @@ static void prepare_search_index(FrtStore *store)
|
|
206
205
|
int i;
|
207
206
|
FrtIndexWriter *iw;
|
208
207
|
|
209
|
-
FrtFieldInfos *fis = frt_fis_new(FRT_STORE_YES, FRT_INDEX_YES, FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS);
|
210
|
-
FrtFieldInfo *fi = frt_fi_new(rb_intern("empty-field"), FRT_STORE_NO, FRT_INDEX_NO, FRT_TERM_VECTOR_NO);
|
208
|
+
FrtFieldInfos *fis = frt_fis_new(FRT_STORE_YES, FRT_COMPRESSION_NONE, FRT_INDEX_YES, FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS);
|
209
|
+
FrtFieldInfo *fi = frt_fi_new(rb_intern("empty-field"), FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_NO, FRT_TERM_VECTOR_NO);
|
211
210
|
frt_fis_add_field(fis, fi);
|
212
211
|
frt_index_create(store, fis);
|
213
212
|
frt_fis_deref(fis);
|
213
|
+
rb_encoding *enc = rb_enc_find("ASCII-8BIT");
|
214
214
|
|
215
|
-
iw = frt_iw_open(store, dbl_analyzer_new(), NULL);
|
215
|
+
iw = frt_iw_open(NULL, store, dbl_analyzer_new(), NULL);
|
216
216
|
for (i = 0; i < SEARCH_DOCS_SIZE; i++) {
|
217
217
|
FrtDocument *doc = frt_doc_new();
|
218
218
|
doc->boost = (float)(i+1);
|
219
|
-
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(date), (char *)test_data[i].date));
|
220
|
-
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(field), (char *)test_data[i].field));
|
221
|
-
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(cat), (char *)test_data[i].cat));
|
222
|
-
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(number), (char *)test_data[i].number));
|
219
|
+
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(date), (char *)test_data[i].date, enc));
|
220
|
+
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(field), (char *)test_data[i].field, enc));
|
221
|
+
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(cat), (char *)test_data[i].cat, enc));
|
222
|
+
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(number), (char *)test_data[i].number, enc));
|
223
223
|
frt_iw_add_doc(iw, doc);
|
224
224
|
frt_doc_destroy(doc);
|
225
225
|
}
|
@@ -252,7 +252,7 @@ static void test_get_doc(TestCase *tc, void *data)
|
|
252
252
|
frt_doc_destroy(doc);
|
253
253
|
}
|
254
254
|
|
255
|
-
void check_to_s(TestCase *tc, FrtQuery *query,
|
255
|
+
void check_to_s(TestCase *tc, FrtQuery *query, ID field, const char *q_str)
|
256
256
|
{
|
257
257
|
char *q_res = query->to_s(query, field);
|
258
258
|
Asequal(q_str, q_res);
|
@@ -266,7 +266,6 @@ void tst_check_hits(TestCase *tc, FrtSearcher *searcher, FrtQuery *query, const
|
|
266
266
|
int i, count;
|
267
267
|
int total_hits = s2l(expected_hits, num_array);
|
268
268
|
FrtTopDocs *top_docs = frt_searcher_search(searcher, query, 0, total_hits + 1, NULL, NULL, NULL);
|
269
|
-
frt_p_pause();
|
270
269
|
if (!tc->failed && !Aiequal(total_hits, top_docs->total_hits)) {
|
271
270
|
int i;
|
272
271
|
Tmsg_nf("\texpected docs:\n\t ");
|
@@ -314,11 +313,10 @@ void tst_check_hits(TestCase *tc, FrtSearcher *searcher, FrtQuery *query, const
|
|
314
313
|
count = frt_searcher_search_unscored(searcher, query, num_array2, ARRAY_SIZE, num_array2[3]);
|
315
314
|
Aaiequal(num_array + 3, num_array2, count);
|
316
315
|
}
|
317
|
-
frt_p_resume();
|
318
316
|
}
|
319
317
|
|
320
318
|
void check_match_vector(TestCase *tc, FrtSearcher *searcher, FrtQuery *query,
|
321
|
-
int doc,
|
319
|
+
int doc, ID field, const char *ranges)
|
322
320
|
{
|
323
321
|
static int range_array[ARRAY_SIZE];
|
324
322
|
FrtMatchVector *mv = frt_searcher_get_match_vector(searcher, query, doc, field);
|
@@ -342,11 +340,11 @@ static void test_term_query(TestCase *tc, void *data)
|
|
342
340
|
char *t, e[100];
|
343
341
|
FrtQuery *tq = frt_tq_new(field, "word2");
|
344
342
|
check_to_s(tc, tq, field, "word2");
|
345
|
-
check_to_s(tc, tq, (
|
343
|
+
check_to_s(tc, tq, (ID)NULL, "field:word2");
|
346
344
|
tq->boost = 100;
|
347
345
|
tst_check_hits(tc, searcher, tq, "4, 8, 1", -1);
|
348
346
|
check_to_s(tc, tq, field, "word2^100.0");
|
349
|
-
check_to_s(tc, tq, (
|
347
|
+
check_to_s(tc, tq, (ID)NULL, "field:word2^100.0");
|
350
348
|
|
351
349
|
/* test TermWeight.to_s */
|
352
350
|
w = searcher->create_weight(searcher, tq);
|
@@ -554,13 +552,13 @@ static void test_phrase_query(TestCase *tc, void *data)
|
|
554
552
|
FrtWeight *w;
|
555
553
|
char *t, e[100];
|
556
554
|
check_to_s(tc, phq, field, "\"\"");
|
557
|
-
check_to_s(tc, phq, (
|
555
|
+
check_to_s(tc, phq, (ID)NULL, "field:\"\"");
|
558
556
|
|
559
557
|
frt_phq_add_term(phq, "quick", 1);
|
560
558
|
frt_phq_add_term(phq, "brown", 1);
|
561
559
|
frt_phq_add_term(phq, "fox", 1);
|
562
560
|
check_to_s(tc, phq, field, "\"quick brown fox\"");
|
563
|
-
check_to_s(tc, phq, (
|
561
|
+
check_to_s(tc, phq, (ID)NULL, "field:\"quick brown fox\"");
|
564
562
|
tst_check_hits(tc, searcher, phq, "1", 1);
|
565
563
|
|
566
564
|
frt_phq_set_slop(phq, 4);
|
@@ -581,7 +579,7 @@ static void test_phrase_query(TestCase *tc, void *data)
|
|
581
579
|
frt_phq_add_term(phq, "quick", 1);
|
582
580
|
frt_phq_add_term(phq, "fox", 2);
|
583
581
|
check_to_s(tc, phq, field, "\"quick <> fox\"");
|
584
|
-
check_to_s(tc, phq, (
|
582
|
+
check_to_s(tc, phq, (ID)NULL, "field:\"quick <> fox\"");
|
585
583
|
tst_check_hits(tc, searcher, phq, "1, 11, 14", 14);
|
586
584
|
|
587
585
|
frt_phq_set_slop(phq, 1);
|
@@ -590,19 +588,19 @@ static void test_phrase_query(TestCase *tc, void *data)
|
|
590
588
|
frt_phq_set_slop(phq, 4);
|
591
589
|
tst_check_hits(tc, searcher, phq, "1, 11, 14, 16, 17", 14);
|
592
590
|
frt_phq_add_term(phq, "red", -1);
|
593
|
-
check_to_s(tc, phq, (
|
591
|
+
check_to_s(tc, phq, (ID)NULL, "field:\"quick red fox\"~4");
|
594
592
|
tst_check_hits(tc, searcher, phq, "11", 11);
|
595
593
|
frt_phq_add_term(phq, "RED", 0);
|
596
|
-
check_to_s(tc, phq, (
|
594
|
+
check_to_s(tc, phq, (ID)NULL, "field:\"quick red RED&fox\"~4");
|
597
595
|
tst_check_hits(tc, searcher, phq, "11", 11);
|
598
596
|
frt_phq_add_term(phq, "QUICK", -1);
|
599
597
|
frt_phq_add_term(phq, "red", 0);
|
600
|
-
check_to_s(tc, phq, (
|
598
|
+
check_to_s(tc, phq, (ID)NULL, "field:\"quick QUICK&red&red RED&fox\"~4");
|
601
599
|
tst_check_hits(tc, searcher, phq, "11", 11);
|
602
600
|
frt_phq_add_term(phq, "green", 0);
|
603
601
|
frt_phq_add_term(phq, "yellow", 0);
|
604
602
|
frt_phq_add_term(phq, "sentinel", 1);
|
605
|
-
check_to_s(tc, phq, (
|
603
|
+
check_to_s(tc, phq, (ID)NULL,
|
606
604
|
"field:\"quick QUICK&red&red RED&fox&green&yellow sentinel\"~4");
|
607
605
|
tst_check_hits(tc, searcher, phq, "", -1);
|
608
606
|
frt_q_deref(phq);
|
@@ -615,7 +613,7 @@ static void test_phrase_query(TestCase *tc, void *data)
|
|
615
613
|
frt_phq_add_term(phq, "quick", 0);
|
616
614
|
frt_phq_add_term(phq, "QUICK", 1);
|
617
615
|
tst_check_hits(tc, searcher, phq, "11, 14", 14);
|
618
|
-
check_to_s(tc, phq, (
|
616
|
+
check_to_s(tc, phq, (ID)NULL, "field:\"WORD3&the THE&quick QUICK\"");
|
619
617
|
frt_q_deref(phq);
|
620
618
|
|
621
619
|
/* test repeating terms check */
|
@@ -740,30 +738,30 @@ static void test_multi_phrase_query(TestCase *tc, void *data)
|
|
740
738
|
frt_phq_append_multi_term(phq, "fast");
|
741
739
|
tst_check_hits(tc, searcher, phq, "1, 8, 11, 14, 16, 17", -1);
|
742
740
|
check_to_s(tc, phq, field, "\"quick|fast\"");
|
743
|
-
check_to_s(tc, phq, (
|
741
|
+
check_to_s(tc, phq, (ID)NULL, "field:\"quick|fast\"");
|
744
742
|
|
745
743
|
frt_phq_add_term(phq, "brown", 1);
|
746
744
|
frt_phq_append_multi_term(phq, "red");
|
747
745
|
frt_phq_append_multi_term(phq, "hairy");
|
748
746
|
frt_phq_add_term(phq, "fox", 1);
|
749
747
|
check_to_s(tc, phq, field, "\"quick|fast brown|red|hairy fox\"");
|
750
|
-
check_to_s(tc, phq, (
|
748
|
+
check_to_s(tc, phq, (ID)NULL, "field:\"quick|fast brown|red|hairy fox\"");
|
751
749
|
tst_check_hits(tc, searcher, phq, "1, 8, 11, 14", -1);
|
752
750
|
|
753
751
|
frt_phq_set_slop(phq, 4);
|
754
752
|
tst_check_hits(tc, searcher, phq, "1, 8, 11, 14, 16, 17", -1);
|
755
|
-
check_to_s(tc, phq, (
|
753
|
+
check_to_s(tc, phq, (ID)NULL, "field:\"quick|fast brown|red|hairy fox\"~4");
|
756
754
|
|
757
755
|
frt_phq_add_term(phq, "QUICK", -1);
|
758
756
|
frt_phq_append_multi_term(phq, "FAST");
|
759
757
|
tst_check_hits(tc, searcher, phq, "1, 8, 11, 14, 16, 17", -1);
|
760
|
-
check_to_s(tc, phq, (
|
758
|
+
check_to_s(tc, phq, (ID)NULL,
|
761
759
|
"field:\"quick|fast QUICK|FAST&brown|red|hairy fox\"~4");
|
762
760
|
|
763
761
|
frt_phq_add_term(phq, "WORD3", -3);
|
764
762
|
frt_phq_append_multi_term(phq, "WORD2");
|
765
763
|
tst_check_hits(tc, searcher, phq, "1, 8, 11, 14", -1);
|
766
|
-
check_to_s(tc, phq, (
|
764
|
+
check_to_s(tc, phq, (ID)NULL, "field:\"WORD3|WORD2 quick|fast "
|
767
765
|
"QUICK|FAST&brown|red|hairy fox\"~4");
|
768
766
|
|
769
767
|
frt_q_deref(phq);
|
@@ -776,11 +774,11 @@ static void test_multi_phrase_query(TestCase *tc, void *data)
|
|
776
774
|
frt_phq_add_term(phq, "two", 1);
|
777
775
|
frt_phq_add_term(phq, "one", 1);
|
778
776
|
tst_check_hits(tc, searcher, phq, "2", -1);
|
779
|
-
check_to_s(tc, phq, (
|
777
|
+
check_to_s(tc, phq, (ID)NULL, "field:\"WORD3|x&one two one\"");
|
780
778
|
|
781
779
|
frt_phq_set_slop(phq, 4);
|
782
780
|
tst_check_hits(tc, searcher, phq, "2", -1);
|
783
|
-
check_to_s(tc, phq, (
|
781
|
+
check_to_s(tc, phq, (ID)NULL, "field:\"WORD3|x&one two one\"~4");
|
784
782
|
frt_q_deref(phq);
|
785
783
|
|
786
784
|
/* test phrase query on non-existing field doesn't break anything */
|
@@ -900,40 +898,40 @@ static void test_multi_term_query(TestCase *tc, void *data)
|
|
900
898
|
mtq = frt_multi_tq_new_conf(field, 4, 0.5);
|
901
899
|
tst_check_hits(tc, searcher, mtq, "", -1);
|
902
900
|
check_to_s(tc, mtq, field, "\"\"");
|
903
|
-
check_to_s(tc, mtq, (
|
901
|
+
check_to_s(tc, mtq, (ID)NULL, "field:\"\"");
|
904
902
|
|
905
903
|
frt_multi_tq_add_term(mtq, "brown");
|
906
904
|
tst_check_hits(tc, searcher, mtq, "1, 8, 16, 17", -1);
|
907
905
|
check_to_s(tc, mtq, field, "\"brown\"");
|
908
|
-
check_to_s(tc, mtq, (
|
906
|
+
check_to_s(tc, mtq, (ID)NULL, "field:\"brown\"");
|
909
907
|
|
910
908
|
|
911
909
|
/* 0.4f boost is below the 0.5 threshold so term is ignored */
|
912
910
|
frt_multi_tq_add_term_boost(mtq, "fox", 0.4f);
|
913
911
|
tst_check_hits(tc, searcher, mtq, "1, 8, 16, 17", -1);
|
914
912
|
check_to_s(tc, mtq, field, "\"brown\"");
|
915
|
-
check_to_s(tc, mtq, (
|
913
|
+
check_to_s(tc, mtq, (ID)NULL, "field:\"brown\"");
|
916
914
|
|
917
915
|
/* 0.6f boost is above the 0.5 threshold so term is included */
|
918
916
|
frt_multi_tq_add_term_boost(mtq, "fox", 0.6f);
|
919
917
|
tst_check_hits(tc, searcher, mtq, "1, 8, 11, 14, 16, 17", -1);
|
920
918
|
check_to_s(tc, mtq, field, "\"fox^0.6|brown\"");
|
921
|
-
check_to_s(tc, mtq, (
|
919
|
+
check_to_s(tc, mtq, (ID)NULL, "field:\"fox^0.6|brown\"");
|
922
920
|
|
923
921
|
frt_multi_tq_add_term_boost(mtq, "fast", 50.0f);
|
924
922
|
tst_check_hits(tc, searcher, mtq, "1, 8, 11, 14, 16, 17", 8);
|
925
923
|
check_to_s(tc, mtq, field, "\"fox^0.6|brown|fast^50.0\"");
|
926
|
-
check_to_s(tc, mtq, (
|
924
|
+
check_to_s(tc, mtq, (ID)NULL, "field:\"fox^0.6|brown|fast^50.0\"");
|
927
925
|
|
928
926
|
|
929
927
|
mtq->boost = 80.1f;
|
930
|
-
check_to_s(tc, mtq, (
|
928
|
+
check_to_s(tc, mtq, (ID)NULL, "field:\"fox^0.6|brown|fast^50.0\"^80.1");
|
931
929
|
frt_multi_tq_add_term(mtq, "word1");
|
932
|
-
check_to_s(tc, mtq, (
|
930
|
+
check_to_s(tc, mtq, (ID)NULL, "field:\"fox^0.6|brown|word1|fast^50.0\"^80.1");
|
933
931
|
frt_multi_tq_add_term(mtq, "word2");
|
934
|
-
check_to_s(tc, mtq, (
|
932
|
+
check_to_s(tc, mtq, (ID)NULL, "field:\"brown|word1|word2|fast^50.0\"^80.1");
|
935
933
|
frt_multi_tq_add_term(mtq, "word3");
|
936
|
-
check_to_s(tc, mtq, (
|
934
|
+
check_to_s(tc, mtq, (ID)NULL, "field:\"brown|word1|word2|fast^50.0\"^80.1");
|
937
935
|
|
938
936
|
/* test MultiTermWeight.to_s */
|
939
937
|
w = searcher->create_weight(searcher, mtq);
|
@@ -956,7 +954,7 @@ static void test_multi_term_query(TestCase *tc, void *data)
|
|
956
954
|
frt_bq_add_query(bq, mtq, FRT_BC_MUST);
|
957
955
|
tst_check_hits(tc, searcher, bq, "1, 11, 14, 16, 17", -1);
|
958
956
|
check_to_s(tc, bq, field, "+quick +\"fox^0.6|brown|word1\"");
|
959
|
-
check_to_s(tc, bq, (
|
957
|
+
check_to_s(tc, bq, (ID)NULL, "+field:quick +field:\"fox^0.6|brown|word1\"");
|
960
958
|
frt_q_deref(bq);
|
961
959
|
frt_q_deref(mtq);
|
962
960
|
|
@@ -978,7 +976,7 @@ static void test_multi_term_query_hash(TestCase *tc, void *data)
|
|
978
976
|
(void)data;
|
979
977
|
|
980
978
|
|
981
|
-
check_to_s(tc, q1, (
|
979
|
+
check_to_s(tc, q1, (ID)NULL, "field:\"\"");
|
982
980
|
Assert(frt_q_hash(q1) == frt_q_hash(q2), "Queries should be equal");
|
983
981
|
Assert(frt_q_eq(q1, q1), "Same queries should be equal");
|
984
982
|
Assert(frt_q_eq(q1, q2), "Queries should be equal");
|
@@ -1637,7 +1635,7 @@ static void test_search_unscored(TestCase *tc, void *data)
|
|
1637
1635
|
|
1638
1636
|
TestSuite *ts_search(TestSuite *suite)
|
1639
1637
|
{
|
1640
|
-
FrtStore *store = frt_open_ram_store();
|
1638
|
+
FrtStore *store = frt_open_ram_store(NULL);
|
1641
1639
|
FrtIndexReader *ir;
|
1642
1640
|
FrtSearcher *searcher;
|
1643
1641
|
|
@@ -1653,7 +1651,7 @@ TestSuite *ts_search(TestSuite *suite)
|
|
1653
1651
|
tst_run_test(suite, test_default_similarity, NULL);
|
1654
1652
|
|
1655
1653
|
prepare_search_index(store);
|
1656
|
-
ir = frt_ir_open(store);
|
1654
|
+
ir = frt_ir_open(NULL, store);
|
1657
1655
|
searcher = frt_isea_new(ir);
|
1658
1656
|
|
1659
1657
|
tst_run_test(suite, test_get_doc, (void *)searcher);
|
@@ -1702,22 +1700,21 @@ static void prepare_multi_search_index(FrtStore *store, struct Data data[],
|
|
1702
1700
|
{
|
1703
1701
|
int i;
|
1704
1702
|
FrtIndexWriter *iw;
|
1705
|
-
FrtFieldInfos *fis = frt_fis_new(FRT_STORE_YES,
|
1706
|
-
|
1707
|
-
FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS);
|
1708
|
-
FrtFieldInfo *fi = frt_fi_new(rb_intern("empty-field"), FRT_STORE_NO, FRT_INDEX_NO, FRT_TERM_VECTOR_NO);
|
1703
|
+
FrtFieldInfos *fis = frt_fis_new(FRT_STORE_YES, FRT_COMPRESSION_NONE, FRT_INDEX_YES, FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS);
|
1704
|
+
FrtFieldInfo *fi = frt_fi_new(rb_intern("empty-field"), FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_NO, FRT_TERM_VECTOR_NO);
|
1709
1705
|
frt_fis_add_field(fis, fi);
|
1710
1706
|
frt_index_create(store, fis);
|
1711
1707
|
frt_fis_deref(fis);
|
1708
|
+
rb_encoding *enc = rb_enc_find("ASCII-8BIT");
|
1712
1709
|
|
1713
|
-
iw = frt_iw_open(store, dbl_analyzer_new(), NULL);
|
1710
|
+
iw = frt_iw_open(NULL, store, dbl_analyzer_new(), NULL);
|
1714
1711
|
for (i = 0; i < d_cnt; i++) {
|
1715
1712
|
FrtDocument *doc = frt_doc_new();
|
1716
1713
|
doc->boost = (float)(i+w);
|
1717
|
-
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(date), (char *)data[i].date));
|
1718
|
-
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(field), (char *)data[i].field));
|
1719
|
-
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(cat), (char *)data[i].cat));
|
1720
|
-
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(number), (char *)data[i].number));
|
1714
|
+
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(date), (char *)data[i].date, enc));
|
1715
|
+
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(field), (char *)data[i].field, enc));
|
1716
|
+
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(cat), (char *)data[i].cat, enc));
|
1717
|
+
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(number), (char *)data[i].number, enc));
|
1721
1718
|
frt_iw_add_doc(iw, doc);
|
1722
1719
|
frt_doc_destroy(doc);
|
1723
1720
|
}
|
@@ -1826,8 +1823,8 @@ static void test_query_combine(TestCase *tc, void *data)
|
|
1826
1823
|
|
1827
1824
|
TestSuite *ts_multi_search(TestSuite *suite)
|
1828
1825
|
{
|
1829
|
-
FrtStore *store0 = frt_open_ram_store();
|
1830
|
-
FrtStore *store1 = frt_open_ram_store();
|
1826
|
+
FrtStore *store0 = frt_open_ram_store(NULL);
|
1827
|
+
FrtStore *store1 = frt_open_ram_store(NULL);
|
1831
1828
|
|
1832
1829
|
FrtIndexReader *ir0, *ir1;
|
1833
1830
|
FrtSearcher **searchers;
|
@@ -1843,8 +1840,8 @@ TestSuite *ts_multi_search(TestSuite *suite)
|
|
1843
1840
|
prepare_multi_search_index(store0, test_data, 9, 1);
|
1844
1841
|
prepare_multi_search_index(store1, test_data + 9, FRT_NELEMS(test_data) - 9, 10);
|
1845
1842
|
|
1846
|
-
ir0 = frt_ir_open(store0);
|
1847
|
-
ir1 = frt_ir_open(store1);
|
1843
|
+
ir0 = frt_ir_open(NULL, store0);
|
1844
|
+
ir1 = frt_ir_open(NULL, store1);
|
1848
1845
|
searchers = FRT_ALLOC_N(FrtSearcher *, 2);
|
1849
1846
|
searchers[0] = frt_isea_new(ir0);
|
1850
1847
|
searchers[1] = frt_isea_new(ir1);
|
@@ -1870,4 +1867,3 @@ TestSuite *ts_multi_search(TestSuite *suite)
|
|
1870
1867
|
frt_searcher_close(searcher);
|
1871
1868
|
return suite;
|
1872
1869
|
}
|
1873
|
-
|
@@ -16,9 +16,10 @@
|
|
16
16
|
#define Asi_has_vals(si, name, doc_cnt, store)\
|
17
17
|
tst_si_eql(__LINE__, tc, si, name, doc_cnt, store)
|
18
18
|
static FrtFieldInfos dummy_fis = {
|
19
|
-
FRT_STORE_NO,
|
20
|
-
|
21
|
-
|
19
|
+
FRT_STORE_NO, /* store */
|
20
|
+
FRT_COMPRESSION_NONE, /* compression */
|
21
|
+
FRT_INDEX_NO, /* index */
|
22
|
+
FRT_TERM_VECTOR_NO, /* term_vector */
|
22
23
|
0, /* size */
|
23
24
|
0, /* capa */
|
24
25
|
NULL, /* fields */
|
@@ -154,7 +155,7 @@ void test_sis_rw(TestCase *tc, void *data)
|
|
154
155
|
|
155
156
|
TestSuite *ts_segments(TestSuite *suite)
|
156
157
|
{
|
157
|
-
FrtStore *store = frt_open_ram_store();
|
158
|
+
FrtStore *store = frt_open_ram_store(NULL);
|
158
159
|
|
159
160
|
suite = ADD_SUITE(suite);
|
160
161
|
|
@@ -3,9 +3,11 @@
|
|
3
3
|
#include "frt_search.h"
|
4
4
|
#include "test.h"
|
5
5
|
|
6
|
+
#undef close
|
7
|
+
|
6
8
|
#define ARRAY_SIZE 20
|
7
9
|
|
8
|
-
static
|
10
|
+
static ID search, string, integer, flt;
|
9
11
|
|
10
12
|
typedef struct SortTestData {
|
11
13
|
const char *search;
|
@@ -17,10 +19,11 @@ typedef struct SortTestData {
|
|
17
19
|
static void add_sort_test_data(SortTestData *std, FrtIndexWriter *iw)
|
18
20
|
{
|
19
21
|
FrtDocument *doc = frt_doc_new();
|
20
|
-
|
21
|
-
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(
|
22
|
-
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(
|
23
|
-
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(
|
22
|
+
rb_encoding *enc = rb_enc_find("ASCII-8BIT");
|
23
|
+
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(search), (char *)std->search, enc));
|
24
|
+
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(string), (char *)std->string, enc));
|
25
|
+
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(integer), (char *)std->integer, enc));
|
26
|
+
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(flt), (char *)std->flt, enc));
|
24
27
|
|
25
28
|
sscanf(std->flt, "%f", &doc->boost);
|
26
29
|
|
@@ -45,11 +48,11 @@ static void sort_test_setup(FrtStore *store)
|
|
45
48
|
{
|
46
49
|
int i;
|
47
50
|
FrtIndexWriter *iw;
|
48
|
-
FrtFieldInfos *fis = frt_fis_new(FRT_STORE_YES, FRT_INDEX_YES, FRT_TERM_VECTOR_YES);
|
51
|
+
FrtFieldInfos *fis = frt_fis_new(FRT_STORE_YES, FRT_COMPRESSION_NONE, FRT_INDEX_YES, FRT_TERM_VECTOR_YES);
|
49
52
|
frt_index_create(store, fis);
|
50
53
|
frt_fis_deref(fis);
|
51
54
|
|
52
|
-
iw = frt_iw_open(store, frt_whitespace_analyzer_new(false), NULL);
|
55
|
+
iw = frt_iw_open(NULL, store, frt_whitespace_analyzer_new(false), NULL);
|
53
56
|
|
54
57
|
for (i = 0; i < FRT_NELEMS(data); i++) {
|
55
58
|
add_sort_test_data(&data[i], iw);
|
@@ -60,21 +63,21 @@ static void sort_test_setup(FrtStore *store)
|
|
60
63
|
static void sort_multi_test_setup(FrtStore *store1, FrtStore *store2)
|
61
64
|
{
|
62
65
|
int i;
|
63
|
-
FrtFieldInfos *fis = frt_fis_new(FRT_STORE_YES, FRT_INDEX_YES, FRT_TERM_VECTOR_YES);
|
66
|
+
FrtFieldInfos *fis = frt_fis_new(FRT_STORE_YES, FRT_COMPRESSION_NONE, FRT_INDEX_YES, FRT_TERM_VECTOR_YES);
|
64
67
|
FrtIndexWriter *iw;
|
65
68
|
|
66
69
|
frt_index_create(store1, fis);
|
67
70
|
frt_index_create(store2, fis);
|
68
71
|
frt_fis_deref(fis);
|
69
72
|
|
70
|
-
iw = frt_iw_open(store1, frt_whitespace_analyzer_new(false), NULL);
|
73
|
+
iw = frt_iw_open(NULL, store1, frt_whitespace_analyzer_new(false), NULL);
|
71
74
|
|
72
75
|
for (i = 0; i < FRT_NELEMS(data)/2; i++) {
|
73
76
|
add_sort_test_data(&data[i], iw);
|
74
77
|
}
|
75
78
|
frt_iw_close(iw);
|
76
79
|
|
77
|
-
iw = frt_iw_open(store2, frt_whitespace_analyzer_new(false), NULL);
|
80
|
+
iw = frt_iw_open(NULL, store2, frt_whitespace_analyzer_new(false), NULL);
|
78
81
|
|
79
82
|
for (i = FRT_NELEMS(data)/2; i < FRT_NELEMS(data); i++) {
|
80
83
|
add_sort_test_data(&data[i], iw);
|
@@ -288,7 +291,7 @@ static void test_sorts(TestCase *tc, void *data)
|
|
288
291
|
TestSuite *ts_sort(TestSuite *suite)
|
289
292
|
{
|
290
293
|
FrtSearcher *sea, **searchers;
|
291
|
-
FrtStore *store = frt_open_ram_store(), *fs_store;
|
294
|
+
FrtStore *store = frt_open_ram_store(NULL), *fs_store;
|
292
295
|
|
293
296
|
search = rb_intern("search");
|
294
297
|
string = rb_intern("string");
|
@@ -302,7 +305,7 @@ TestSuite *ts_sort(TestSuite *suite)
|
|
302
305
|
tst_run_test(suite, test_sort_field_to_s, NULL);
|
303
306
|
tst_run_test(suite, test_sort_to_s, NULL);
|
304
307
|
|
305
|
-
sea = frt_isea_new(frt_ir_open(store));
|
308
|
+
sea = frt_isea_new(frt_ir_open(NULL, store));
|
306
309
|
|
307
310
|
tst_run_test(suite, test_sorts, (void *)sea);
|
308
311
|
|
@@ -319,8 +322,8 @@ TestSuite *ts_sort(TestSuite *suite)
|
|
319
322
|
|
320
323
|
searchers = FRT_ALLOC_N(FrtSearcher *, 2);
|
321
324
|
|
322
|
-
searchers[0] = frt_isea_new(frt_ir_open(store));
|
323
|
-
searchers[1] = frt_isea_new(frt_ir_open(fs_store));
|
325
|
+
searchers[0] = frt_isea_new(frt_ir_open(NULL, store));
|
326
|
+
searchers[1] = frt_isea_new(frt_ir_open(NULL, fs_store));
|
324
327
|
|
325
328
|
sea = frt_msea_new(searchers, 2, true);
|
326
329
|
tst_run_test(suite, test_sorts, (void *)sea);
|
@@ -1,6 +1,8 @@
|
|
1
1
|
#include "frt_index.h"
|
2
2
|
#include "test.h"
|
3
3
|
|
4
|
+
#undef close
|
5
|
+
|
4
6
|
/***************************************************************************
|
5
7
|
*
|
6
8
|
* FrtTermInfosWriter
|
@@ -336,7 +338,7 @@ static void test_term_infos_reader(TestCase *tc, void *data)
|
|
336
338
|
|
337
339
|
TestSuite *ts_term(TestSuite *suite)
|
338
340
|
{
|
339
|
-
FrtStore *store = frt_open_ram_store();
|
341
|
+
FrtStore *store = frt_open_ram_store(NULL);
|
340
342
|
|
341
343
|
suite = ADD_SUITE(suite);
|
342
344
|
|
@@ -33,14 +33,13 @@ static void test_posting(TestCase *tc, void *data)
|
|
33
33
|
Apnull(pl->last_occ->next);
|
34
34
|
}
|
35
35
|
|
36
|
-
static FrtFieldInfos *create_tv_fis()
|
37
|
-
|
38
|
-
|
39
|
-
frt_fis_add_field(fis, frt_fi_new(rb_intern("
|
40
|
-
frt_fis_add_field(fis, frt_fi_new(rb_intern("
|
41
|
-
frt_fis_add_field(fis, frt_fi_new(rb_intern("
|
42
|
-
frt_fis_add_field(fis, frt_fi_new(rb_intern("
|
43
|
-
frt_fis_add_field(fis, frt_fi_new(rb_intern("tv_with_positions_offsets"), FRT_STORE_NO, FRT_INDEX_UNTOKENIZED, FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS));
|
36
|
+
static FrtFieldInfos *create_tv_fis(void) {
|
37
|
+
FrtFieldInfos *fis = frt_fis_new(FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_UNTOKENIZED, FRT_TERM_VECTOR_NO);
|
38
|
+
frt_fis_add_field(fis, frt_fi_new(rb_intern("tv"), FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_UNTOKENIZED, FRT_TERM_VECTOR_YES));
|
39
|
+
frt_fis_add_field(fis, frt_fi_new(rb_intern("tv2"), FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_UNTOKENIZED, FRT_TERM_VECTOR_YES));
|
40
|
+
frt_fis_add_field(fis, frt_fi_new(rb_intern("tv_with_positions"), FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_UNTOKENIZED, FRT_TERM_VECTOR_WITH_POSITIONS));
|
41
|
+
frt_fis_add_field(fis, frt_fi_new(rb_intern("tv_with_offsets"), FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_UNTOKENIZED, FRT_TERM_VECTOR_WITH_OFFSETS));
|
42
|
+
frt_fis_add_field(fis, frt_fi_new(rb_intern("tv_with_positions_offsets"), FRT_STORE_NO, FRT_COMPRESSION_NONE, FRT_INDEX_UNTOKENIZED, FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS));
|
44
43
|
return fis;
|
45
44
|
}
|
46
45
|
|
@@ -85,7 +84,7 @@ static FrtOffset *create_tv_offsets(FrtMemoryPool *mp)
|
|
85
84
|
static void test_tv_single_doc(TestCase *tc, void *data)
|
86
85
|
{
|
87
86
|
int i, j;
|
88
|
-
FrtStore *store = frt_open_ram_store();
|
87
|
+
FrtStore *store = frt_open_ram_store(NULL);
|
89
88
|
FrtMemoryPool *mp = (FrtMemoryPool *)data;
|
90
89
|
FrtFieldsReader *fr;
|
91
90
|
FrtFieldsWriter *fw;
|
@@ -227,7 +226,7 @@ static void test_tv_single_doc(TestCase *tc, void *data)
|
|
227
226
|
static void test_tv_multi_doc(TestCase *tc, void *data)
|
228
227
|
{
|
229
228
|
int i, j;
|
230
|
-
FrtStore *store = frt_open_ram_store();
|
229
|
+
FrtStore *store = frt_open_ram_store(NULL);
|
231
230
|
FrtMemoryPool *mp = (FrtMemoryPool *)data;
|
232
231
|
FrtFieldsReader *fr;
|
233
232
|
FrtFieldsWriter *fw;
|
@@ -71,12 +71,12 @@ static void do_add_doc(FrtIndex *index)
|
|
71
71
|
{
|
72
72
|
FrtDocument *doc = frt_doc_new();
|
73
73
|
int n = rand();
|
74
|
-
|
75
|
-
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(id), frt_strfmt("%d", n)))->destroy_data = true;
|
76
|
-
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(contents), num_to_str(n)))->destroy_data = true;
|
74
|
+
rb_encoding *enc = rb_enc_find("ASCII-8BIT");
|
75
|
+
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(id), frt_strfmt("%d", n), enc))->destroy_data = true;
|
76
|
+
frt_doc_add_field(doc, frt_df_add_data(frt_df_new(contents), num_to_str(n), enc))->destroy_data = true;
|
77
77
|
tlog("Adding %d\n", n);
|
78
78
|
frt_index_add_doc(index, doc);
|
79
|
-
|
79
|
+
frt_doc_destroy(doc);
|
80
80
|
}
|
81
81
|
|
82
82
|
static void do_search(FrtIndex *index)
|
@@ -84,17 +84,18 @@ static void do_search(FrtIndex *index)
|
|
84
84
|
int n = rand(), i;
|
85
85
|
char *query = num_to_str(n);
|
86
86
|
FrtTopDocs *td;
|
87
|
+
rb_encoding *enc = rb_enc_find("ASCII-8BIT");
|
87
88
|
|
88
89
|
tlog("Searching for %d\n", n);
|
89
90
|
|
90
91
|
frt_mutex_lock(&index->mutex);
|
91
|
-
td = frt_index_search_str(index, query, 0, 3, NULL, NULL, NULL);
|
92
|
+
td = frt_index_search_str(index, query, 0, 3, NULL, NULL, NULL, enc);
|
92
93
|
free(query);
|
93
94
|
for (i = 0; i < td->size; i++) {
|
94
95
|
FrtHit *hit = td->hits[i];
|
95
96
|
FrtDocument *doc = frt_index_get_doc(index, hit->doc);
|
96
97
|
tlog("Hit for %d: %s - %f\n", hit->doc, frt_doc_get_field(doc, id)->data[0], hit->score);
|
97
|
-
|
98
|
+
frt_doc_destroy(doc);
|
98
99
|
}
|
99
100
|
tlog("Searched for %d: total = %d\n", n, td->total_hits);
|
100
101
|
frt_mutex_unlock(&index->mutex);
|
@@ -157,10 +158,8 @@ TestSuite *ts_threading(TestSuite *suite)
|
|
157
158
|
FrtStore *store = frt_open_fs_store("./test/testdir/store");
|
158
159
|
FrtIndex *index;
|
159
160
|
FrtHashSet *def_fields = frt_hs_new_ptr(NULL);
|
160
|
-
FrtFieldInfos *fis = frt_fis_new(FRT_STORE_YES, FRT_INDEX_YES,
|
161
|
-
|
162
|
-
frt_fis_add_field(fis, frt_fi_new(id, FRT_STORE_YES, FRT_INDEX_UNTOKENIZED,
|
163
|
-
FRT_TERM_VECTOR_YES));
|
161
|
+
FrtFieldInfos *fis = frt_fis_new(FRT_STORE_YES, FRT_COMPRESSION_NONE, FRT_INDEX_YES, FRT_TERM_VECTOR_WITH_POSITIONS_OFFSETS);
|
162
|
+
frt_fis_add_field(fis, frt_fi_new(id, FRT_STORE_YES, FRT_COMPRESSION_NONE, FRT_INDEX_UNTOKENIZED, FRT_TERM_VECTOR_YES));
|
164
163
|
frt_index_create(store, fis);
|
165
164
|
frt_fis_deref(fis);
|
166
165
|
|