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,6 +5,7 @@
|
|
5
5
|
#include "frt_field_index.h"
|
6
6
|
#include "frt_bitvector.h"
|
7
7
|
#include "frt_similarity.h"
|
8
|
+
#include <ruby/encoding.h>
|
8
9
|
|
9
10
|
typedef struct FrtQuery FrtQuery;
|
10
11
|
typedef struct FrtWeight FrtWeight;
|
@@ -17,8 +18,7 @@ typedef struct FrtScorer FrtScorer;
|
|
17
18
|
***************************************************************************/
|
18
19
|
|
19
20
|
#define FRT_EXPLANATION_DETAILS_START_SIZE 4
|
20
|
-
typedef struct FrtExplanation
|
21
|
-
{
|
21
|
+
typedef struct FrtExplanation {
|
22
22
|
float value;
|
23
23
|
char *description;
|
24
24
|
struct FrtExplanation **details;
|
@@ -39,18 +39,16 @@ extern char *frt_expl_to_html(FrtExplanation *expl);
|
|
39
39
|
***************************************************************************/
|
40
40
|
typedef struct FrtSearcher FrtSearcher;
|
41
41
|
|
42
|
-
typedef struct FrtMatchRange
|
43
|
-
|
44
|
-
int
|
45
|
-
int
|
46
|
-
int
|
47
|
-
int end_offset;
|
42
|
+
typedef struct FrtMatchRange {
|
43
|
+
int start;
|
44
|
+
int end;
|
45
|
+
int start_offset;
|
46
|
+
int end_offset;
|
48
47
|
double score;
|
49
48
|
} FrtMatchRange;
|
50
49
|
|
51
50
|
#define FRT_MATCH_VECTOR_INIT_CAPA 8
|
52
|
-
typedef struct FrtMatchVector
|
53
|
-
{
|
51
|
+
typedef struct FrtMatchVector {
|
54
52
|
int size;
|
55
53
|
int capa;
|
56
54
|
FrtMatchRange *matches;
|
@@ -69,9 +67,8 @@ extern FrtMatchVector *frt_matchv_compact_with_breaks(FrtMatchVector *self);
|
|
69
67
|
*
|
70
68
|
***************************************************************************/
|
71
69
|
|
72
|
-
typedef struct FrtHit
|
73
|
-
|
74
|
-
int doc;
|
70
|
+
typedef struct FrtHit {
|
71
|
+
int doc;
|
75
72
|
float score;
|
76
73
|
} FrtHit;
|
77
74
|
|
@@ -81,16 +78,14 @@ typedef struct FrtHit
|
|
81
78
|
*
|
82
79
|
***************************************************************************/
|
83
80
|
|
84
|
-
typedef struct FrtTopDocs
|
85
|
-
|
86
|
-
int
|
87
|
-
int size;
|
81
|
+
typedef struct FrtTopDocs {
|
82
|
+
int total_hits;
|
83
|
+
int size;
|
88
84
|
FrtHit **hits;
|
89
|
-
float
|
85
|
+
float max_score;
|
90
86
|
} FrtTopDocs;
|
91
87
|
|
92
|
-
extern FrtTopDocs *frt_td_new(int total_hits, int size, FrtHit **hits,
|
93
|
-
float max_score);
|
88
|
+
extern FrtTopDocs *frt_td_new(int total_hits, int size, FrtHit **hits, float max_score);
|
94
89
|
extern void frt_td_destroy(FrtTopDocs *td);
|
95
90
|
extern char *frt_td_to_s(FrtTopDocs *td);
|
96
91
|
|
@@ -100,9 +95,8 @@ extern char *frt_td_to_s(FrtTopDocs *td);
|
|
100
95
|
*
|
101
96
|
***************************************************************************/
|
102
97
|
|
103
|
-
typedef struct FrtFilter
|
104
|
-
|
105
|
-
FrtSymbol name;
|
98
|
+
typedef struct FrtFilter {
|
99
|
+
ID name;
|
106
100
|
FrtHash *cache;
|
107
101
|
FrtBitVector *(*get_bv_i)(struct FrtFilter *self, FrtIndexReader *ir);
|
108
102
|
char *(*to_s)(struct FrtFilter *self);
|
@@ -110,10 +104,11 @@ typedef struct FrtFilter
|
|
110
104
|
int (*eq)(struct FrtFilter *self, struct FrtFilter *o);
|
111
105
|
void (*destroy_i)(struct FrtFilter *self);
|
112
106
|
int ref_cnt;
|
107
|
+
VALUE rfilter;
|
113
108
|
} FrtFilter;
|
114
109
|
|
115
110
|
#define filt_new(type) frt_filt_create(sizeof(type), rb_intern(#type))
|
116
|
-
extern FrtFilter *frt_filt_create(size_t size,
|
111
|
+
extern FrtFilter *frt_filt_create(size_t size, ID name);
|
117
112
|
extern FrtBitVector *frt_filt_get_bv(FrtFilter *filt, FrtIndexReader *ir);
|
118
113
|
extern void frt_filt_destroy_i(FrtFilter *filt);
|
119
114
|
extern void frt_filt_deref(FrtFilter *filt);
|
@@ -126,8 +121,23 @@ extern int frt_filt_eq(FrtFilter *filt, FrtFilter *o);
|
|
126
121
|
*
|
127
122
|
***************************************************************************/
|
128
123
|
|
129
|
-
|
130
|
-
|
124
|
+
typedef struct FrtRange {
|
125
|
+
ID field;
|
126
|
+
char *lower_term;
|
127
|
+
char *upper_term;
|
128
|
+
bool include_lower : 1;
|
129
|
+
bool include_upper : 1;
|
130
|
+
} FrtRange;
|
131
|
+
|
132
|
+
typedef struct FrtRangeFilter {
|
133
|
+
FrtFilter super;
|
134
|
+
FrtRange *range;
|
135
|
+
} FrtRangeFilter;
|
136
|
+
|
137
|
+
extern FrtFilter *frt_rfilt_alloc(void);
|
138
|
+
extern FrtFilter *frt_rfilt_init(FrtFilter *filt, ID field, const char *lower_term, const char *upper_term,
|
139
|
+
bool include_lower, bool include_upper);
|
140
|
+
extern FrtFilter *frt_rfilt_new(ID field, const char *lower_term, const char *upper_term,
|
131
141
|
bool include_lower, bool include_upper);
|
132
142
|
|
133
143
|
/***************************************************************************
|
@@ -136,8 +146,10 @@ extern FrtFilter *frt_rfilt_new(FrtSymbol field,
|
|
136
146
|
*
|
137
147
|
***************************************************************************/
|
138
148
|
|
139
|
-
extern FrtFilter *
|
140
|
-
|
149
|
+
extern FrtFilter *frt_trfilt_alloc(void);
|
150
|
+
extern FrtFilter *frt_trfilt_init(FrtFilter *filt, ID field, const char *lower_term, const char *upper_term,
|
151
|
+
bool include_lower, bool include_upper);
|
152
|
+
extern FrtFilter *frt_trfilt_new(ID field, const char *lower_term, const char *upper_term,
|
141
153
|
bool include_lower, bool include_upper);
|
142
154
|
|
143
155
|
/***************************************************************************
|
@@ -146,6 +158,13 @@ extern FrtFilter *frt_trfilt_new(FrtSymbol field,
|
|
146
158
|
*
|
147
159
|
***************************************************************************/
|
148
160
|
|
161
|
+
typedef struct FrtQueryFilter {
|
162
|
+
FrtFilter super;
|
163
|
+
FrtQuery *query;
|
164
|
+
} FrtQueryFilter;
|
165
|
+
|
166
|
+
extern FrtFilter *frt_qfilt_alloc(void);
|
167
|
+
extern FrtFilter *frt_qfilt_init(FrtFilter *filt, FrtQuery *query);
|
149
168
|
extern FrtFilter *frt_qfilt_new(FrtQuery *query);
|
150
169
|
extern FrtFilter *frt_qfilt_new_nr(FrtQuery *query);
|
151
170
|
|
@@ -155,22 +174,21 @@ extern FrtFilter *frt_qfilt_new_nr(FrtQuery *query);
|
|
155
174
|
*
|
156
175
|
***************************************************************************/
|
157
176
|
|
158
|
-
struct FrtWeight
|
159
|
-
|
160
|
-
float
|
161
|
-
float
|
162
|
-
float
|
163
|
-
float idf;
|
177
|
+
struct FrtWeight {
|
178
|
+
float value;
|
179
|
+
float qweight;
|
180
|
+
float qnorm;
|
181
|
+
float idf;
|
164
182
|
FrtQuery *query;
|
165
183
|
FrtSimilarity *similarity;
|
166
184
|
FrtQuery *(*get_query)(FrtWeight *self);
|
167
|
-
float
|
168
|
-
void
|
185
|
+
float (*get_value)(FrtWeight *self);
|
186
|
+
void (*normalize)(FrtWeight *self, float normalization_factor);
|
169
187
|
FrtScorer *(*scorer)(FrtWeight *self, FrtIndexReader *ir);
|
170
188
|
FrtExplanation *(*explain)(FrtWeight *self, FrtIndexReader *ir, int doc_num);
|
171
|
-
float
|
172
|
-
char
|
173
|
-
void
|
189
|
+
float (*sum_of_squared_weights)(FrtWeight *self);
|
190
|
+
char *(*to_s)(FrtWeight *self);
|
191
|
+
void (*destroy)(FrtWeight *self);
|
174
192
|
};
|
175
193
|
|
176
194
|
#define w_new(type, query) frt_w_create(sizeof(type), query)
|
@@ -187,8 +205,7 @@ extern void frt_w_normalize(FrtWeight *self, float normalization_factor);
|
|
187
205
|
*
|
188
206
|
***************************************************************************/
|
189
207
|
|
190
|
-
typedef enum
|
191
|
-
{
|
208
|
+
typedef enum {
|
192
209
|
TERM_QUERY,
|
193
210
|
MULTI_TERM_QUERY,
|
194
211
|
BOOLEAN_QUERY,
|
@@ -210,21 +227,21 @@ typedef enum
|
|
210
227
|
SPAN_NEAR_QUERY
|
211
228
|
} FrtQueryType;
|
212
229
|
|
213
|
-
struct FrtQuery
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
char *(*to_s)(FrtQuery *self, FrtSymbol field);
|
230
|
+
struct FrtQuery {
|
231
|
+
int ref_cnt;
|
232
|
+
float boost;
|
233
|
+
FrtWeight *weight;
|
234
|
+
FrtQuery *(*rewrite)(FrtQuery *self, FrtIndexReader *ir);
|
235
|
+
void (*extract_terms)(FrtQuery *self, FrtHashSet *terms);
|
236
|
+
FrtSimilarity *(*get_similarity)(FrtQuery *self, FrtSearcher *searcher);
|
237
|
+
char *(*to_s)(FrtQuery *self, ID field);
|
222
238
|
unsigned long long (*hash)(FrtQuery *self);
|
223
|
-
int
|
224
|
-
void
|
225
|
-
FrtWeight
|
226
|
-
FrtMatchVector
|
227
|
-
FrtQueryType
|
239
|
+
int (*eq)(FrtQuery *self, FrtQuery *o);
|
240
|
+
void (*destroy_i)(FrtQuery *self);
|
241
|
+
FrtWeight *(*create_weight_i)(FrtQuery *self, FrtSearcher *searcher);
|
242
|
+
FrtMatchVector *(*get_matchv_i)(FrtQuery *self, FrtMatchVector *mv, FrtTermVector *tv);
|
243
|
+
FrtQueryType type;
|
244
|
+
VALUE rquery;
|
228
245
|
};
|
229
246
|
|
230
247
|
/* Internal FrtQuery Functions */
|
@@ -245,37 +262,37 @@ extern FrtQuery *frt_q_create(size_t size);
|
|
245
262
|
* FrtTermQuery
|
246
263
|
***************************************************************************/
|
247
264
|
|
248
|
-
typedef struct FrtTermQuery
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
char *term;
|
265
|
+
typedef struct FrtTermQuery {
|
266
|
+
FrtQuery super;
|
267
|
+
ID field;
|
268
|
+
char *term;
|
253
269
|
} FrtTermQuery;
|
254
270
|
|
255
|
-
FrtQuery *
|
271
|
+
FrtQuery *frt_tq_alloc(void);
|
272
|
+
FrtQuery *frt_tq_init(FrtQuery *self, ID field, const char *term);
|
273
|
+
FrtQuery *frt_tq_new(ID field, const char *term);
|
256
274
|
|
257
275
|
/***************************************************************************
|
258
276
|
* FrtBooleanQuery
|
259
277
|
***************************************************************************/
|
260
278
|
|
261
|
-
|
262
|
-
|
263
|
-
typedef enum
|
264
|
-
{
|
279
|
+
typedef enum {
|
265
280
|
FRT_BC_SHOULD,
|
266
281
|
FRT_BC_MUST,
|
267
282
|
FRT_BC_MUST_NOT
|
268
283
|
} FrtBCType;
|
269
284
|
|
270
|
-
typedef struct FrtBooleanClause
|
271
|
-
|
272
|
-
|
273
|
-
FrtQuery *query;
|
285
|
+
typedef struct FrtBooleanClause {
|
286
|
+
int ref_cnt;
|
287
|
+
FrtQuery *query;
|
274
288
|
FrtBCType occur;
|
275
|
-
bool
|
276
|
-
bool
|
289
|
+
bool is_prohibited : 1;
|
290
|
+
bool is_required : 1;
|
291
|
+
VALUE rbc;
|
277
292
|
} FrtBooleanClause;
|
278
293
|
|
294
|
+
extern FrtBooleanClause *frt_bc_alloc(void);
|
295
|
+
extern FrtBooleanClause *frt_bc_init(FrtBooleanClause *self, FrtQuery *query, FrtBCType occur);
|
279
296
|
extern FrtBooleanClause *frt_bc_new(FrtQuery *query, FrtBCType occur);
|
280
297
|
extern void frt_bc_deref(FrtBooleanClause *self);
|
281
298
|
extern void frt_bc_set_occur(FrtBooleanClause *self, FrtBCType occur);
|
@@ -286,24 +303,23 @@ extern void frt_bc_set_occur(FrtBooleanClause *self, FrtBCType occur);
|
|
286
303
|
#define FRT_BOOLEAN_CLAUSES_START_CAPA 4
|
287
304
|
#define FRT_QUERY_STRING_START_SIZE 64
|
288
305
|
|
289
|
-
typedef struct FrtBooleanQuery
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
int
|
294
|
-
int
|
295
|
-
|
296
|
-
float original_boost;
|
306
|
+
typedef struct FrtBooleanQuery {
|
307
|
+
FrtQuery super;
|
308
|
+
bool coord_disabled;
|
309
|
+
int max_clause_cnt;
|
310
|
+
int clause_cnt;
|
311
|
+
int clause_capa;
|
312
|
+
float original_boost;
|
297
313
|
FrtBooleanClause **clauses;
|
298
|
-
FrtSimilarity
|
314
|
+
FrtSimilarity *similarity;
|
299
315
|
} FrtBooleanQuery;
|
300
316
|
|
317
|
+
extern FrtQuery *frt_bq_alloc(void);
|
318
|
+
extern FrtQuery *frt_bq_init(FrtQuery *self, bool coord_disabled);
|
301
319
|
extern FrtQuery *frt_bq_new(bool coord_disabled);
|
302
320
|
extern FrtQuery *frt_bq_new_max(bool coord_disabled, int max);
|
303
|
-
extern FrtBooleanClause *frt_bq_add_query(FrtQuery *self, FrtQuery *sub_query,
|
304
|
-
|
305
|
-
extern FrtBooleanClause *frt_bq_add_query_nr(FrtQuery *self, FrtQuery *sub_query,
|
306
|
-
FrtBCType occur);
|
321
|
+
extern FrtBooleanClause *frt_bq_add_query(FrtQuery *self, FrtQuery *sub_query, FrtBCType occur);
|
322
|
+
extern FrtBooleanClause *frt_bq_add_query_nr(FrtQuery *self, FrtQuery *sub_query, FrtBCType occur);
|
307
323
|
extern FrtBooleanClause *frt_bq_add_clause(FrtQuery *self, FrtBooleanClause *bc);
|
308
324
|
extern FrtBooleanClause *frt_bq_add_clause_nr(FrtQuery *self, FrtBooleanClause *bc);
|
309
325
|
|
@@ -311,17 +327,18 @@ extern FrtBooleanClause *frt_bq_add_clause_nr(FrtQuery *self, FrtBooleanClause *
|
|
311
327
|
* FrtPhraseQuery
|
312
328
|
***************************************************************************/
|
313
329
|
|
314
|
-
typedef struct FrtPhraseQuery
|
315
|
-
{
|
330
|
+
typedef struct FrtPhraseQuery {
|
316
331
|
FrtQuery super;
|
317
332
|
int slop;
|
318
|
-
|
333
|
+
ID field;
|
319
334
|
FrtPhrasePosition *positions;
|
320
335
|
int pos_cnt;
|
321
336
|
int pos_capa;
|
322
337
|
} FrtPhraseQuery;
|
323
338
|
|
324
|
-
extern FrtQuery *
|
339
|
+
extern FrtQuery *frt_phq_alloc(void);
|
340
|
+
extern FrtQuery *frt_phq_init(FrtQuery *self, ID field);
|
341
|
+
extern FrtQuery *frt_phq_new(ID field);
|
325
342
|
extern void frt_phq_add_term(FrtQuery *self, const char *term, int pos_inc);
|
326
343
|
extern void frt_phq_add_term_abs(FrtQuery *self, const char *term, int position);
|
327
344
|
extern void frt_phq_append_multi_term(FrtQuery *self, const char *term);
|
@@ -332,25 +349,24 @@ extern void frt_phq_set_slop(FrtQuery *self, int slop);
|
|
332
349
|
***************************************************************************/
|
333
350
|
|
334
351
|
#define MULTI_TERM_QUERY_MAX_TERMS 256
|
335
|
-
typedef struct FrtMultiTermQuery
|
336
|
-
{
|
352
|
+
typedef struct FrtMultiTermQuery {
|
337
353
|
FrtQuery super;
|
338
|
-
|
354
|
+
ID field;
|
339
355
|
FrtPriorityQueue *boosted_terms;
|
340
356
|
float min_boost;
|
341
357
|
} FrtMultiTermQuery;
|
342
358
|
|
343
359
|
extern void frt_multi_tq_add_term(FrtQuery *self, const char *term);
|
344
360
|
extern void frt_multi_tq_add_term_boost(FrtQuery *self, const char *term, float boost);
|
345
|
-
extern FrtQuery *
|
346
|
-
extern FrtQuery *
|
347
|
-
|
361
|
+
extern FrtQuery *frt_multi_tq_alloc(void);
|
362
|
+
extern FrtQuery *frt_multi_tq_new(ID field);
|
363
|
+
extern FrtQuery *frt_multi_tq_init_conf(FrtQuery *self, ID field, int max_terms, float min_boost);
|
364
|
+
extern FrtQuery *frt_multi_tq_new_conf(ID field, int max_terms, float min_boost);
|
348
365
|
|
349
366
|
#define FrtMTQMaxTerms(query) (((FrtMTQSubQuery *)(query))->max_terms)
|
350
|
-
typedef struct FrtMTQSubQuery
|
351
|
-
{
|
367
|
+
typedef struct FrtMTQSubQuery {
|
352
368
|
FrtQuery super;
|
353
|
-
int
|
369
|
+
int max_terms;
|
354
370
|
} FrtMTQSubQuery;
|
355
371
|
|
356
372
|
/***************************************************************************
|
@@ -359,14 +375,15 @@ typedef struct FrtMTQSubQuery
|
|
359
375
|
|
360
376
|
#define PREFIX_QUERY_MAX_TERMS 256
|
361
377
|
|
362
|
-
typedef struct FrtPrefixQuery
|
363
|
-
{
|
378
|
+
typedef struct FrtPrefixQuery {
|
364
379
|
FrtMTQSubQuery super;
|
365
|
-
|
380
|
+
ID field;
|
366
381
|
char *prefix;
|
367
382
|
} FrtPrefixQuery;
|
368
383
|
|
369
|
-
extern FrtQuery *
|
384
|
+
extern FrtQuery *frt_prefixq_alloc(void);
|
385
|
+
extern FrtQuery *frt_prefixq_init(FrtQuery *self, ID field, const char *prefix);
|
386
|
+
extern FrtQuery *frt_prefixq_new(ID field, const char *prefix);
|
370
387
|
|
371
388
|
/***************************************************************************
|
372
389
|
* FrtWildCardQuery
|
@@ -376,15 +393,15 @@ extern FrtQuery *frt_prefixq_new(FrtSymbol field, const char *prefix);
|
|
376
393
|
#define FRT_WILD_STRING '*'
|
377
394
|
#define FRT_WILD_CARD_QUERY_MAX_TERMS 256
|
378
395
|
|
379
|
-
typedef struct FrtWildCardQuery
|
380
|
-
{
|
396
|
+
typedef struct FrtWildCardQuery {
|
381
397
|
FrtMTQSubQuery super;
|
382
|
-
|
398
|
+
ID field;
|
383
399
|
char *pattern;
|
384
400
|
} FrtWildCardQuery;
|
385
401
|
|
386
|
-
|
387
|
-
extern FrtQuery *
|
402
|
+
extern FrtQuery *frt_wcq_alloc(void);
|
403
|
+
extern FrtQuery *frt_wcq_init(FrtQuery *self, ID field, const char *pattern);
|
404
|
+
extern FrtQuery *frt_wcq_new(ID field, const char *pattern);
|
388
405
|
extern bool frt_wc_match(const char *pattern, const char *text);
|
389
406
|
|
390
407
|
/***************************************************************************
|
@@ -396,36 +413,37 @@ extern bool frt_wc_match(const char *pattern, const char *text);
|
|
396
413
|
#define FRT_DEF_MAX_TERMS 256
|
397
414
|
#define FRT_TYPICAL_LONGEST_WORD 20
|
398
415
|
|
399
|
-
typedef struct FrtFuzzyQuery
|
400
|
-
{
|
416
|
+
typedef struct FrtFuzzyQuery {
|
401
417
|
FrtMTQSubQuery super;
|
402
|
-
|
403
|
-
char
|
404
|
-
const char
|
405
|
-
int
|
406
|
-
int
|
407
|
-
float
|
408
|
-
float
|
409
|
-
int
|
410
|
-
int
|
418
|
+
ID field;
|
419
|
+
char *term;
|
420
|
+
const char *text; /* term text after prefix */
|
421
|
+
int text_len;
|
422
|
+
int pre_len;
|
423
|
+
float min_sim;
|
424
|
+
float scale_factor;
|
425
|
+
int max_distances[FRT_TYPICAL_LONGEST_WORD];
|
426
|
+
int *da;
|
411
427
|
} FrtFuzzyQuery;
|
412
428
|
|
413
|
-
extern FrtQuery *
|
414
|
-
extern FrtQuery *
|
415
|
-
|
429
|
+
extern FrtQuery *frt_fuzq_alloc(void);
|
430
|
+
extern FrtQuery *frt_fuzq_new(ID field, const char *term);
|
431
|
+
extern FrtQuery *frt_fuzq_init_conf(FrtQuery *self, ID field, const char *term, float min_sim, int pre_len, int max_terms);
|
432
|
+
extern FrtQuery *frt_fuzq_new_conf(ID field, const char *term, float min_sim, int pre_len, int max_terms);
|
416
433
|
extern float frt_fuzq_score(FrtFuzzyQuery *fuzq, const char *target);
|
417
434
|
|
418
435
|
/***************************************************************************
|
419
436
|
* FrtConstantScoreQuery
|
420
437
|
***************************************************************************/
|
421
438
|
|
422
|
-
typedef struct FrtConstantScoreQuery
|
423
|
-
|
424
|
-
FrtQuery super;
|
439
|
+
typedef struct FrtConstantScoreQuery {
|
440
|
+
FrtQuery super;
|
425
441
|
FrtFilter *filter;
|
426
442
|
FrtQuery *original;
|
427
443
|
} FrtConstantScoreQuery;
|
428
444
|
|
445
|
+
extern FrtQuery *frt_csq_alloc(void);
|
446
|
+
extern FrtQuery *frt_csq_init(FrtQuery *self, FrtFilter *filter);
|
429
447
|
extern FrtQuery *frt_csq_new(FrtFilter *filter);
|
430
448
|
extern FrtQuery *frt_csq_new_nr(FrtFilter *filter);
|
431
449
|
|
@@ -434,38 +452,47 @@ extern FrtQuery *frt_csq_new_nr(FrtFilter *filter);
|
|
434
452
|
***************************************************************************/
|
435
453
|
|
436
454
|
typedef struct FrtFilteredQuery {
|
437
|
-
FrtQuery
|
455
|
+
FrtQuery super;
|
438
456
|
FrtQuery *query;
|
439
457
|
FrtFilter *filter;
|
440
458
|
} FrtFilteredQuery;
|
441
459
|
|
460
|
+
extern FrtQuery *frt_fq_alloc(void);
|
461
|
+
extern FrtQuery *frt_fq_init(FrtQuery *self, FrtQuery *query, FrtFilter *filter);
|
442
462
|
extern FrtQuery *frt_fq_new(FrtQuery *query, FrtFilter *filter);
|
443
463
|
|
444
464
|
/***************************************************************************
|
445
465
|
* FrtMatchAllQuery
|
446
466
|
***************************************************************************/
|
447
467
|
|
468
|
+
extern FrtQuery *frt_maq_alloc(void);
|
469
|
+
extern FrtQuery *frt_maq_init(FrtQuery *self);
|
448
470
|
extern FrtQuery *frt_maq_new();
|
449
471
|
|
450
472
|
/***************************************************************************
|
451
473
|
* FrtRangeQuery
|
452
474
|
***************************************************************************/
|
453
475
|
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
476
|
+
typedef struct FrtRangeQuery {
|
477
|
+
FrtQuery f;
|
478
|
+
FrtRange *range;
|
479
|
+
} FrtRangeQuery;
|
480
|
+
|
481
|
+
extern FrtQuery *frt_rq_alloc(void);
|
482
|
+
extern FrtQuery *frt_rq_init(FrtQuery *self, ID field, const char *lower_term, const char *upper_term, bool include_lower, bool include_upper);
|
483
|
+
extern FrtQuery *frt_rq_new(ID field, const char *lower_term, const char *upper_term, bool include_lower, bool include_upper);
|
484
|
+
extern FrtQuery *frt_rq_new_less(ID field, const char *upper_term, bool include_upper);
|
485
|
+
extern FrtQuery *frt_rq_new_more(ID field, const char *lower_term, bool include_lower);
|
459
486
|
|
460
487
|
/***************************************************************************
|
461
488
|
* FrtTypedRangeQuery
|
462
489
|
***************************************************************************/
|
463
490
|
|
464
|
-
extern FrtQuery *
|
465
|
-
|
466
|
-
|
467
|
-
extern FrtQuery *frt_trq_new_less(
|
468
|
-
extern FrtQuery *frt_trq_new_more(
|
491
|
+
extern FrtQuery *frt_trq_alloc(void);
|
492
|
+
extern FrtQuery *frt_trq_init(FrtQuery *self, ID field, const char *lower_term, const char *upper_term, bool include_lower, bool include_upper);
|
493
|
+
extern FrtQuery *frt_trq_new(ID field, const char *lower_term, const char *upper_term, bool include_lower, bool include_upper);
|
494
|
+
extern FrtQuery *frt_trq_new_less(ID field, const char *upper_term, bool include_upper);
|
495
|
+
extern FrtQuery *frt_trq_new_more(ID field, const char *lower_term, bool include_lower);
|
469
496
|
|
470
497
|
/***************************************************************************
|
471
498
|
* FrtSpanQuery
|
@@ -473,66 +500,68 @@ extern FrtQuery *frt_trq_new_more(FrtSymbol field, const char *lower_term, bool
|
|
473
500
|
|
474
501
|
/* ** FrtSpanEnum ** */
|
475
502
|
typedef struct FrtSpanEnum FrtSpanEnum;
|
476
|
-
struct FrtSpanEnum
|
477
|
-
{
|
503
|
+
struct FrtSpanEnum {
|
478
504
|
FrtQuery *query;
|
479
|
-
bool
|
480
|
-
bool
|
481
|
-
int
|
482
|
-
int
|
483
|
-
int
|
484
|
-
char
|
485
|
-
void
|
505
|
+
bool (*next)(FrtSpanEnum *self);
|
506
|
+
bool (*skip_to)(FrtSpanEnum *self, int target_doc);
|
507
|
+
int (*doc)(FrtSpanEnum *self);
|
508
|
+
int (*start)(FrtSpanEnum *self);
|
509
|
+
int (*end)(FrtSpanEnum *self);
|
510
|
+
char *(*to_s)(FrtSpanEnum *self);
|
511
|
+
void (*destroy)(FrtSpanEnum *self);
|
486
512
|
};
|
487
513
|
|
488
514
|
/* ** FrtSpanQuery ** */
|
489
|
-
typedef struct FrtSpanQuery
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
FrtHashSet *(*get_terms)(FrtQuery *self);
|
515
|
+
typedef struct FrtSpanQuery {
|
516
|
+
FrtQuery super;
|
517
|
+
ID field;
|
518
|
+
FrtSpanEnum *(*get_spans)(FrtQuery *self, FrtIndexReader *ir);
|
519
|
+
FrtHashSet *(*get_terms)(FrtQuery *self);
|
495
520
|
} FrtSpanQuery;
|
496
521
|
|
497
522
|
/***************************************************************************
|
498
523
|
* FrtSpanTermQuery
|
499
524
|
***************************************************************************/
|
500
525
|
|
501
|
-
typedef struct FrtSpanTermQuery
|
502
|
-
{
|
526
|
+
typedef struct FrtSpanTermQuery {
|
503
527
|
FrtSpanQuery super;
|
504
|
-
char
|
528
|
+
char *term;
|
505
529
|
} FrtSpanTermQuery;
|
506
|
-
|
530
|
+
|
531
|
+
extern FrtQuery *frt_spantq_alloc(void);
|
532
|
+
extern FrtQuery *frt_spantq_init(FrtQuery *self, ID field, const char *term);
|
533
|
+
extern FrtQuery *frt_spantq_new(ID field, const char *term);
|
507
534
|
|
508
535
|
/***************************************************************************
|
509
536
|
* FrtSpanMultiTermQuery
|
510
537
|
***************************************************************************/
|
511
538
|
|
512
539
|
#define SPAN_MULTI_TERM_QUERY_CAPA 1024
|
513
|
-
typedef struct FrtSpanMultiTermQuery
|
514
|
-
{
|
540
|
+
typedef struct FrtSpanMultiTermQuery {
|
515
541
|
FrtSpanQuery super;
|
516
|
-
char
|
517
|
-
int
|
518
|
-
int
|
542
|
+
char **terms;
|
543
|
+
int term_cnt;
|
544
|
+
int term_capa;
|
519
545
|
} FrtSpanMultiTermQuery;
|
520
546
|
|
521
|
-
extern FrtQuery *
|
522
|
-
extern FrtQuery *
|
547
|
+
extern FrtQuery *frt_spanmtq_alloc(void);
|
548
|
+
extern FrtQuery *frt_spanmtq_init(FrtQuery *self, ID field);
|
549
|
+
extern FrtQuery *frt_spanmtq_new(ID field);
|
550
|
+
extern FrtQuery *frt_spanmtq_new_conf(ID field, int max_size);
|
523
551
|
extern void frt_spanmtq_add_term(FrtQuery *self, const char *term);
|
524
552
|
|
525
553
|
/***************************************************************************
|
526
554
|
* FrtSpanFirstQuery
|
527
555
|
***************************************************************************/
|
528
556
|
|
529
|
-
typedef struct FrtSpanFirstQuery
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
FrtQuery *match;
|
557
|
+
typedef struct FrtSpanFirstQuery {
|
558
|
+
FrtSpanQuery super;
|
559
|
+
int end;
|
560
|
+
FrtQuery *match;
|
534
561
|
} FrtSpanFirstQuery;
|
535
562
|
|
563
|
+
extern FrtQuery *frt_spanfq_alloc(void);
|
564
|
+
extern FrtQuery *frt_spanfq_init(FrtQuery *self, FrtQuery *match, int end);
|
536
565
|
extern FrtQuery *frt_spanfq_new(FrtQuery *match, int end);
|
537
566
|
extern FrtQuery *frt_spanfq_new_nr(FrtQuery *match, int end);
|
538
567
|
|
@@ -540,14 +569,15 @@ extern FrtQuery *frt_spanfq_new_nr(FrtQuery *match, int end);
|
|
540
569
|
* FrtSpanOrQuery
|
541
570
|
***************************************************************************/
|
542
571
|
|
543
|
-
typedef struct FrtSpanOrQuery
|
544
|
-
|
545
|
-
FrtSpanQuery super;
|
572
|
+
typedef struct FrtSpanOrQuery {
|
573
|
+
FrtSpanQuery super;
|
546
574
|
FrtQuery **clauses;
|
547
|
-
int
|
548
|
-
int
|
575
|
+
int c_cnt;
|
576
|
+
int c_capa;
|
549
577
|
} FrtSpanOrQuery;
|
550
578
|
|
579
|
+
extern FrtQuery *frt_spanoq_alloc(void);
|
580
|
+
extern FrtQuery *frt_spanoq_init(FrtQuery *self);
|
551
581
|
extern FrtQuery *frt_spanoq_new();
|
552
582
|
extern FrtQuery *frt_spanoq_add_clause(FrtQuery *self, FrtQuery *clause);
|
553
583
|
extern FrtQuery *frt_spanoq_add_clause_nr(FrtQuery *self, FrtQuery *clause);
|
@@ -556,16 +586,17 @@ extern FrtQuery *frt_spanoq_add_clause_nr(FrtQuery *self, FrtQuery *clause);
|
|
556
586
|
* FrtSpanNearQuery
|
557
587
|
***************************************************************************/
|
558
588
|
|
559
|
-
typedef struct FrtSpanNearQuery
|
560
|
-
|
561
|
-
FrtSpanQuery super;
|
589
|
+
typedef struct FrtSpanNearQuery {
|
590
|
+
FrtSpanQuery super;
|
562
591
|
FrtQuery **clauses;
|
563
|
-
int
|
564
|
-
int
|
565
|
-
int
|
566
|
-
bool
|
592
|
+
int c_cnt;
|
593
|
+
int c_capa;
|
594
|
+
int slop;
|
595
|
+
bool in_order : 1;
|
567
596
|
} FrtSpanNearQuery;
|
568
597
|
|
598
|
+
extern FrtQuery *frt_spannq_alloc(void);
|
599
|
+
extern FrtQuery *frt_spannq_init(FrtQuery *self, int slop, bool in_order);
|
569
600
|
extern FrtQuery *frt_spannq_new(int slop, bool in_order);
|
570
601
|
extern FrtQuery *frt_spannq_add_clause(FrtQuery *self, FrtQuery *clause);
|
571
602
|
extern FrtQuery *frt_spannq_add_clause_nr(FrtQuery *self, FrtQuery *clause);
|
@@ -574,32 +605,32 @@ extern FrtQuery *frt_spannq_add_clause_nr(FrtQuery *self, FrtQuery *clause);
|
|
574
605
|
* FrtSpanNotQuery
|
575
606
|
***************************************************************************/
|
576
607
|
|
577
|
-
typedef struct FrtSpanNotQuery
|
578
|
-
|
579
|
-
|
580
|
-
FrtQuery
|
581
|
-
FrtQuery *exc;
|
608
|
+
typedef struct FrtSpanNotQuery {
|
609
|
+
FrtSpanQuery super;
|
610
|
+
FrtQuery *inc;
|
611
|
+
FrtQuery *exc;
|
582
612
|
} FrtSpanNotQuery;
|
583
613
|
|
614
|
+
extern FrtQuery *frt_spanxq_alloc(void);
|
615
|
+
extern FrtQuery *frt_spanxq_init(FrtQuery *self, FrtQuery *inc, FrtQuery *exc);
|
584
616
|
extern FrtQuery *frt_spanxq_new(FrtQuery *inc, FrtQuery *exc);
|
585
617
|
extern FrtQuery *frt_spanxq_new_nr(FrtQuery *inc, FrtQuery *exc);
|
586
618
|
|
587
|
-
|
588
619
|
/***************************************************************************
|
589
620
|
* FrtSpanPrefixQuery
|
590
621
|
***************************************************************************/
|
591
622
|
|
592
623
|
#define FRT_SPAN_PREFIX_QUERY_MAX_TERMS 256
|
593
624
|
|
594
|
-
typedef struct FrtSpanPrefixQuery
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
int max_terms;
|
625
|
+
typedef struct FrtSpanPrefixQuery {
|
626
|
+
FrtSpanQuery super;
|
627
|
+
char *prefix;
|
628
|
+
int max_terms;
|
599
629
|
} FrtSpanPrefixQuery;
|
600
630
|
|
601
|
-
extern FrtQuery *
|
602
|
-
|
631
|
+
extern FrtQuery *frt_spanprq_alloc(void);
|
632
|
+
extern FrtQuery *frt_spanprq_init(FrtQuery *self, ID field, const char *prefix);
|
633
|
+
extern FrtQuery *frt_spanprq_new(ID field, const char *prefix);
|
603
634
|
|
604
635
|
/***************************************************************************
|
605
636
|
*
|
@@ -612,15 +643,14 @@ extern FrtQuery *frt_spanprq_new(FrtSymbol field, const char *prefix);
|
|
612
643
|
(mscorer) = NULL;\
|
613
644
|
} while (0)
|
614
645
|
|
615
|
-
struct FrtScorer
|
616
|
-
{
|
646
|
+
struct FrtScorer {
|
617
647
|
FrtSimilarity *similarity;
|
618
|
-
int
|
619
|
-
float
|
620
|
-
bool
|
621
|
-
bool
|
648
|
+
int doc;
|
649
|
+
float (*score)(FrtScorer *self);
|
650
|
+
bool (*next)(FrtScorer *self);
|
651
|
+
bool (*skip_to)(FrtScorer *self, int doc_num);
|
622
652
|
FrtExplanation *(*explain)(FrtScorer *self, int doc_num);
|
623
|
-
void
|
653
|
+
void (*destroy)(FrtScorer *self);
|
624
654
|
};
|
625
655
|
|
626
656
|
#define frt_scorer_new(type, similarity) frt_scorer_create(sizeof(type), similarity)
|
@@ -634,16 +664,15 @@ extern int frt_scorer_doc_cmp(const void *p1, const void *p2);
|
|
634
664
|
* FrtComparable
|
635
665
|
***************************************************************************/
|
636
666
|
|
637
|
-
typedef struct FrtComparable
|
638
|
-
|
639
|
-
int type;
|
667
|
+
typedef struct FrtComparable {
|
668
|
+
int type;
|
640
669
|
union {
|
641
670
|
long l;
|
642
671
|
float f;
|
643
|
-
char
|
644
|
-
void
|
672
|
+
char *s;
|
673
|
+
void *p;
|
645
674
|
} val;
|
646
|
-
bool
|
675
|
+
bool reverse : 1;
|
647
676
|
} FrtComparable;
|
648
677
|
|
649
678
|
/***************************************************************************
|
@@ -652,8 +681,7 @@ typedef struct FrtComparable
|
|
652
681
|
*
|
653
682
|
***************************************************************************/
|
654
683
|
|
655
|
-
typedef enum
|
656
|
-
{
|
684
|
+
typedef enum {
|
657
685
|
FRT_SORT_TYPE_SCORE,
|
658
686
|
FRT_SORT_TYPE_DOC,
|
659
687
|
FRT_SORT_TYPE_BYTE,
|
@@ -667,44 +695,54 @@ typedef enum
|
|
667
695
|
* FrtSortField
|
668
696
|
***************************************************************************/
|
669
697
|
|
670
|
-
typedef struct FrtSortField
|
671
|
-
{
|
698
|
+
typedef struct FrtSortField {
|
672
699
|
const FrtFieldIndexClass *field_index_class;
|
673
|
-
|
674
|
-
SortType
|
675
|
-
bool
|
676
|
-
int
|
677
|
-
void
|
700
|
+
ID field;
|
701
|
+
SortType type;
|
702
|
+
bool reverse : 1;
|
703
|
+
int (*compare)(void *index_ptr, FrtHit *hit1, FrtHit *hit2);
|
704
|
+
void (*get_val)(void *index_ptr, FrtHit *hit1, FrtComparable *comparable);
|
705
|
+
VALUE rfield;
|
678
706
|
} FrtSortField;
|
679
707
|
|
680
|
-
extern FrtSortField *
|
681
|
-
|
682
|
-
|
708
|
+
extern FrtSortField *frt_sort_field_alloc(void);
|
709
|
+
extern FrtSortField *frt_sort_field_init(FrtSortField *self, ID field, SortType type, bool reverse);
|
710
|
+
extern FrtSortField *frt_sort_field_new(ID field, SortType type, bool reverse);
|
711
|
+
extern FrtSortField *frt_sort_field_score_init(FrtSortField *self, bool reverse);
|
683
712
|
extern FrtSortField *frt_sort_field_score_new(bool reverse);
|
713
|
+
extern void frt_sort_field_score_get_val(void *index, FrtHit *hit, FrtComparable *comparable);
|
714
|
+
extern int frt_sort_field_score_compare(void *index_ptr, FrtHit *hit2, FrtHit *hit1);
|
715
|
+
extern FrtSortField *frt_sort_field_doc_init(FrtSortField *self, bool reverse);
|
684
716
|
extern FrtSortField *frt_sort_field_doc_new(bool reverse);
|
685
|
-
extern
|
686
|
-
extern
|
687
|
-
extern FrtSortField *
|
688
|
-
extern FrtSortField *
|
689
|
-
extern FrtSortField *
|
717
|
+
extern void frt_sort_field_doc_get_val(void *index, FrtHit *hit, FrtComparable *comparable);
|
718
|
+
extern int frt_sort_field_doc_compare(void *index_ptr, FrtHit *hit1, FrtHit *hit2);
|
719
|
+
extern FrtSortField *frt_sort_field_int_init(FrtSortField *self, ID field, bool reverse);
|
720
|
+
extern FrtSortField *frt_sort_field_int_new(ID field, bool reverse);
|
721
|
+
extern FrtSortField *frt_sort_field_byte_init(FrtSortField *self, ID field, bool reverse);
|
722
|
+
extern FrtSortField *frt_sort_field_byte_new(ID field, bool reverse);
|
723
|
+
extern FrtSortField *frt_sort_field_float_init(FrtSortField *self, ID field, bool reverse);
|
724
|
+
extern FrtSortField *frt_sort_field_float_new(ID field, bool reverse);
|
725
|
+
extern FrtSortField *frt_sort_field_string_init(FrtSortField *self, ID field, bool reverse);
|
726
|
+
extern FrtSortField *frt_sort_field_string_new(ID field, bool reverse);
|
727
|
+
extern FrtSortField *frt_sort_field_auto_init(FrtSortField *self, ID field, bool reverse);
|
728
|
+
extern FrtSortField *frt_sort_field_auto_new(ID field, bool reverse);
|
690
729
|
extern void frt_sort_field_destroy(void *p);
|
691
730
|
extern char *frt_sort_field_to_s(FrtSortField *self);
|
692
731
|
|
693
|
-
extern
|
694
|
-
extern
|
695
|
-
extern
|
696
|
-
extern
|
732
|
+
extern FrtSortField *FRT_SORT_FIELD_SCORE;
|
733
|
+
extern FrtSortField *FRT_SORT_FIELD_SCORE_REV;
|
734
|
+
extern FrtSortField *FRT_SORT_FIELD_DOC;
|
735
|
+
extern FrtSortField *FRT_SORT_FIELD_DOC_REV;
|
697
736
|
|
698
737
|
/***************************************************************************
|
699
738
|
* FrtSort
|
700
739
|
***************************************************************************/
|
701
740
|
|
702
|
-
typedef struct FrtSort
|
703
|
-
{
|
741
|
+
typedef struct FrtSort {
|
704
742
|
FrtSortField **sort_fields;
|
705
|
-
int
|
706
|
-
int
|
707
|
-
int
|
743
|
+
int size;
|
744
|
+
int capa;
|
745
|
+
int start;
|
708
746
|
bool destroy_all : 1;
|
709
747
|
} FrtSort;
|
710
748
|
|
@@ -728,10 +766,9 @@ extern FrtHit *frt_fshq_pq_pop_fd(FrtPriorityQueue *pq);
|
|
728
766
|
* FrtFieldDoc
|
729
767
|
***************************************************************************/
|
730
768
|
|
731
|
-
typedef struct FrtFieldDoc
|
732
|
-
|
733
|
-
|
734
|
-
int size;
|
769
|
+
typedef struct FrtFieldDoc {
|
770
|
+
FrtHit hit;
|
771
|
+
int size;
|
735
772
|
FrtComparable comparables[1];
|
736
773
|
} FrtFieldDoc;
|
737
774
|
|
@@ -747,38 +784,22 @@ extern bool frt_fdshq_lt(FrtFieldDoc *fd1, FrtFieldDoc *fd2);
|
|
747
784
|
*
|
748
785
|
***************************************************************************/
|
749
786
|
|
750
|
-
typedef struct FrtPostFilter
|
751
|
-
{
|
787
|
+
typedef struct FrtPostFilter {
|
752
788
|
float (*filter_func)(int doc_num, float score, FrtSearcher *self, void *arg);
|
753
|
-
void
|
789
|
+
void *arg;
|
754
790
|
} FrtPostFilter;
|
755
791
|
|
756
|
-
struct FrtSearcher
|
757
|
-
{
|
792
|
+
struct FrtSearcher {
|
758
793
|
FrtSimilarity *similarity;
|
759
|
-
int
|
760
|
-
const char *term);
|
794
|
+
int (*doc_freq)(FrtSearcher *self, ID field, const char *term);
|
761
795
|
FrtDocument *(*get_doc)(FrtSearcher *self, int doc_num);
|
762
796
|
FrtLazyDoc *(*get_lazy_doc)(FrtSearcher *self, int doc_num);
|
763
|
-
int
|
797
|
+
int (*max_doc)(FrtSearcher *self);
|
764
798
|
FrtWeight *(*create_weight)(FrtSearcher *self, FrtQuery *query);
|
765
|
-
FrtTopDocs *(*search)(FrtSearcher *self, FrtQuery *query, int first_doc,
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
FrtTopDocs *(*search_w)(FrtSearcher *self, FrtWeight *weight, int first_doc,
|
770
|
-
int num_docs, FrtFilter *filter, FrtSort *sort,
|
771
|
-
FrtPostFilter *post_filter,
|
772
|
-
bool load_fields);
|
773
|
-
void (*search_each)(FrtSearcher *self, FrtQuery *query, FrtFilter *filter,
|
774
|
-
FrtPostFilter *post_filter,
|
775
|
-
void (*fn)(FrtSearcher *, int, float, void *),
|
776
|
-
void *arg);
|
777
|
-
void (*search_each_w)(FrtSearcher *self, FrtWeight *weight,
|
778
|
-
FrtFilter *filter,
|
779
|
-
FrtPostFilter *post_filter,
|
780
|
-
void (*fn)(FrtSearcher *, int, float, void *),
|
781
|
-
void *arg);
|
799
|
+
FrtTopDocs *(*search)(FrtSearcher *self, FrtQuery *query, int first_doc, int num_docs, FrtFilter *filter, FrtSort *sort, FrtPostFilter *post_filter, bool load_fields);
|
800
|
+
FrtTopDocs *(*search_w)(FrtSearcher *self, FrtWeight *weight, int first_doc, int num_docs, FrtFilter *filter, FrtSort *sort, FrtPostFilter *post_filter, bool load_fields);
|
801
|
+
void (*search_each)(FrtSearcher *self, FrtQuery *query, FrtFilter *filter, FrtPostFilter *post_filter, void (*fn)(FrtSearcher *, int, float, void *), void *arg);
|
802
|
+
void (*search_each_w)(FrtSearcher *self, FrtWeight *weight, FrtFilter *filter, FrtPostFilter *post_filter, void (*fn)(FrtSearcher *, int, float, void *), void *arg);
|
782
803
|
/*
|
783
804
|
* Scan the index for all documents that match a query and write the
|
784
805
|
* results to a buffer. It will stop scanning once the limit is reached
|
@@ -787,23 +808,15 @@ struct FrtSearcher
|
|
787
808
|
* Note: Unlike the offset_docnum in other search methods, this
|
788
809
|
* offset_docnum refers to document number and not hit.
|
789
810
|
*/
|
790
|
-
int
|
791
|
-
|
792
|
-
int *buf,
|
793
|
-
int limit,
|
794
|
-
int offset_docnum);
|
795
|
-
int (*search_unscored_w)(FrtSearcher *searcher,
|
796
|
-
FrtWeight *weight,
|
797
|
-
int *buf,
|
798
|
-
int limit,
|
799
|
-
int offset_docnum);
|
811
|
+
int (*search_unscored)(FrtSearcher *searcher, FrtQuery *query, int *buf, int limit, int offset_docnum);
|
812
|
+
int (*search_unscored_w)(FrtSearcher *searcher, FrtWeight *weight, int *buf, int limit, int offset_docnum);
|
800
813
|
FrtQuery *(*rewrite)(FrtSearcher *self, FrtQuery *original);
|
801
814
|
FrtExplanation *(*explain)(FrtSearcher *self, FrtQuery *query, int doc_num);
|
802
815
|
FrtExplanation *(*explain_w)(FrtSearcher *self, FrtWeight *weight, int doc_num);
|
803
|
-
FrtTermVector *(*get_term_vector)(FrtSearcher *self, const int doc_num,
|
804
|
-
FrtSymbol field);
|
816
|
+
FrtTermVector *(*get_term_vector)(FrtSearcher *self, const int doc_num, ID field);
|
805
817
|
FrtSimilarity *(*get_similarity)(FrtSearcher *self);
|
806
|
-
void
|
818
|
+
void (*close)(FrtSearcher *self);
|
819
|
+
VALUE rsea;
|
807
820
|
};
|
808
821
|
|
809
822
|
#define frt_searcher_get_doc(s, dn) s->get_doc(s, dn)
|
@@ -816,14 +829,11 @@ struct FrtSearcher
|
|
816
829
|
#define frt_searcher_search_each(s, q, filt, ff, fn, arg) s->search_each(s, q, filt, ff, fn, arg)
|
817
830
|
#define frt_searcher_search_unscored(s, q, buf, limit, offset_docnum) s->search_unscored(s, q, buf, limit, offset_docnum)
|
818
831
|
|
819
|
-
extern FrtMatchVector *frt_searcher_get_match_vector(FrtSearcher *self,
|
820
|
-
FrtQuery *query,
|
821
|
-
const int doc_num,
|
822
|
-
FrtSymbol field);
|
832
|
+
extern FrtMatchVector *frt_searcher_get_match_vector(FrtSearcher *self, FrtQuery *query, const int doc_num, ID field);
|
823
833
|
extern char **frt_searcher_highlight(FrtSearcher *self,
|
824
834
|
FrtQuery *query,
|
825
835
|
const int doc_num,
|
826
|
-
|
836
|
+
ID field,
|
827
837
|
const int excerpt_len,
|
828
838
|
const int num_excerpts,
|
829
839
|
const char *pre_tag,
|
@@ -837,15 +847,15 @@ extern char **frt_searcher_highlight(FrtSearcher *self,
|
|
837
847
|
***************************************************************************/
|
838
848
|
|
839
849
|
typedef struct FrtIndexSearcher {
|
840
|
-
FrtSearcher
|
841
|
-
FrtIndexReader
|
842
|
-
bool
|
850
|
+
FrtSearcher super;
|
851
|
+
FrtIndexReader *ir;
|
852
|
+
bool close_ir : 1;
|
843
853
|
} FrtIndexSearcher;
|
844
854
|
|
855
|
+
extern FrtSearcher *frt_isea_alloc(void);
|
856
|
+
extern FrtSearcher *frt_isea_init(FrtSearcher *self, FrtIndexReader *ir);
|
845
857
|
extern FrtSearcher *frt_isea_new(FrtIndexReader *ir);
|
846
|
-
extern int frt_isea_doc_freq(FrtSearcher *self,
|
847
|
-
|
848
|
-
|
858
|
+
extern int frt_isea_doc_freq(FrtSearcher *self, ID field, const char *term);
|
849
859
|
|
850
860
|
/***************************************************************************
|
851
861
|
*
|
@@ -853,16 +863,17 @@ extern int frt_isea_doc_freq(FrtSearcher *self, FrtSymbol field, const char *ter
|
|
853
863
|
*
|
854
864
|
***************************************************************************/
|
855
865
|
|
856
|
-
typedef struct FrtMultiSearcher
|
857
|
-
|
858
|
-
FrtSearcher super;
|
866
|
+
typedef struct FrtMultiSearcher {
|
867
|
+
FrtSearcher super;
|
859
868
|
int s_cnt;
|
860
|
-
FrtSearcher
|
861
|
-
int
|
869
|
+
FrtSearcher **searchers;
|
870
|
+
int *starts;
|
862
871
|
int max_doc;
|
863
872
|
bool close_subs : 1;
|
864
873
|
} FrtMultiSearcher;
|
865
874
|
|
875
|
+
extern FrtSearcher *frt_msea_alloc(void);
|
876
|
+
extern FrtSearcher *frt_msea_init(FrtSearcher *self, FrtSearcher **searchers, int s_cnt, bool close_subs);
|
866
877
|
extern FrtSearcher *frt_msea_new(FrtSearcher **searchers, int s_cnt, bool close_subs);
|
867
878
|
|
868
879
|
/***************************************************************************
|
@@ -874,48 +885,48 @@ extern FrtSearcher *frt_msea_new(FrtSearcher **searchers, int s_cnt, bool close_
|
|
874
885
|
#define FRT_QP_CONC_WORDS 2
|
875
886
|
#define FRT_QP_MAX_CLAUSES 512
|
876
887
|
typedef struct FrtFieldStack {
|
877
|
-
FrtHashSet
|
888
|
+
FrtHashSet *fields;
|
878
889
|
struct FrtFieldStack *next;
|
879
|
-
bool
|
890
|
+
bool destroy : 1;
|
880
891
|
} FrtFieldStack;
|
881
892
|
|
882
|
-
typedef struct FrtQueryParser
|
883
|
-
|
884
|
-
|
885
|
-
int
|
886
|
-
int
|
887
|
-
|
888
|
-
char
|
889
|
-
char
|
890
|
-
char
|
891
|
-
|
892
|
-
|
893
|
-
FrtHashSet
|
894
|
-
FrtHashSet
|
895
|
-
FrtHashSet
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
FrtQuery *result;
|
893
|
+
typedef struct FrtQueryParser {
|
894
|
+
frt_mutex_t mutex;
|
895
|
+
int def_slop;
|
896
|
+
int max_clauses;
|
897
|
+
int phq_pos_inc;
|
898
|
+
char *qstr;
|
899
|
+
char *qstrp;
|
900
|
+
char buf[FRT_QP_CONC_WORDS][FRT_MAX_WORD_SIZE];
|
901
|
+
char *dynbuf;
|
902
|
+
int buf_index;
|
903
|
+
FrtHashSet *def_fields;
|
904
|
+
FrtHashSet *all_fields;
|
905
|
+
FrtHashSet *tokenized_fields;
|
906
|
+
FrtHashSet *fields;
|
907
|
+
FrtFieldStack *fields_top;
|
908
|
+
FrtAnalyzer *analyzer;
|
909
|
+
FrtHash *ts_cache;
|
910
|
+
FrtQuery *result;
|
901
911
|
FrtTokenStream *non_tokenizer;
|
902
|
-
bool
|
903
|
-
bool
|
904
|
-
bool
|
905
|
-
bool
|
906
|
-
bool
|
907
|
-
bool
|
908
|
-
bool
|
909
|
-
bool
|
910
|
-
bool
|
912
|
+
bool or_default : 1;
|
913
|
+
bool wild_lower : 1;
|
914
|
+
bool clean_str : 1;
|
915
|
+
bool handle_parse_errors : 1;
|
916
|
+
bool allow_any_fields : 1;
|
917
|
+
bool destruct : 1;
|
918
|
+
bool recovering : 1;
|
919
|
+
bool use_keywords : 1;
|
920
|
+
bool use_typed_range_query : 1;
|
911
921
|
} FrtQueryParser;
|
912
922
|
typedef FrtQueryParser FrtQParser; /* FrtQParser is an alias for FrtQueryParser */
|
913
923
|
|
924
|
+
extern FrtQParser *frt_qp_alloc(void);
|
925
|
+
extern FrtQParser *frt_qp_init(FrtQParser *, FrtAnalyzer *analyzer);
|
914
926
|
extern FrtQParser *frt_qp_new(FrtAnalyzer *analyzer);
|
915
|
-
extern void frt_qp_add_field(FrtQParser *self,
|
916
|
-
bool is_default, bool is_tokenized);
|
927
|
+
extern void frt_qp_add_field(FrtQParser *self, ID field, bool is_default, bool is_tokenized);
|
917
928
|
extern void frt_qp_destroy(FrtQParser *self);
|
918
|
-
extern FrtQuery *qp_parse(FrtQParser *self, char *qstr);
|
929
|
+
extern FrtQuery *qp_parse(FrtQParser *self, char *qstr, rb_encoding *encoding);
|
919
930
|
extern char *frt_qp_clean_str(char *str);
|
920
931
|
|
921
932
|
extern float frt_qp_default_fuzzy_min_sim;
|