1 /*------------------------------------------------------------------------- 2 * 3 * ts_public.h 4 * Public interface to various tsearch modules, such as 5 * parsers and dictionaries. 6 * 7 * Copyright (c) 1998-2019, PostgreSQL Global Development Group 8 * 9 * src/include/tsearch/ts_public.h 10 * 11 *------------------------------------------------------------------------- 12 */ 13 #ifndef _PG_TS_PUBLIC_H_ 14 #define _PG_TS_PUBLIC_H_ 15 16 #include "tsearch/ts_type.h" 17 18 /* 19 * Parser's framework 20 */ 21 22 /* 23 * returning type for prslextype method of parser 24 */ 25 typedef struct 26 { 27 int lexid; 28 char *alias; 29 char *descr; 30 } LexDescr; 31 32 /* 33 * Interface to headline generator 34 */ 35 typedef struct 36 { 37 uint32 selected:1, 38 in:1, 39 replace:1, 40 repeated:1, 41 skip:1, 42 unused:3, 43 type:8, 44 len:16; 45 WordEntryPos pos; 46 char *word; 47 QueryOperand *item; 48 } HeadlineWordEntry; 49 50 typedef struct 51 { 52 HeadlineWordEntry *words; 53 int32 lenwords; 54 int32 curwords; 55 int32 vectorpos; /* positions a-la tsvector */ 56 char *startsel; 57 char *stopsel; 58 char *fragdelim; 59 int16 startsellen; 60 int16 stopsellen; 61 int16 fragdelimlen; 62 } HeadlineParsedText; 63 64 /* 65 * Common useful things for tsearch subsystem 66 */ 67 extern char *get_tsearch_config_filename(const char *basename, 68 const char *extension); 69 70 /* 71 * Often useful stopword list management 72 */ 73 typedef struct 74 { 75 int len; 76 char **stop; 77 } StopList; 78 79 extern void readstoplist(const char *fname, StopList *s, 80 char *(*wordop) (const char *)); 81 extern bool searchstoplist(StopList *s, char *key); 82 83 /* 84 * Interface with dictionaries 85 */ 86 87 /* return struct for any lexize function */ 88 typedef struct 89 { 90 /*---------- 91 * Number of current variant of split word. For example the Norwegian 92 * word 'fotballklubber' has two variants to split: ( fotball, klubb ) 93 * and ( fot, ball, klubb ). So, dictionary should return: 94 * 95 * nvariant lexeme 96 * 1 fotball 97 * 1 klubb 98 * 2 fot 99 * 2 ball 100 * 2 klubb 101 * 102 * In general, a TSLexeme will be considered to belong to the same split 103 * variant as the previous one if they have the same nvariant value. 104 * The exact values don't matter, only changes from one lexeme to next. 105 *---------- 106 */ 107 uint16 nvariant; 108 109 uint16 flags; /* See flag bits below */ 110 111 char *lexeme; /* C string */ 112 } TSLexeme; 113 114 /* Flag bits that can appear in TSLexeme.flags */ 115 #define TSL_ADDPOS 0x01 116 #define TSL_PREFIX 0x02 117 #define TSL_FILTER 0x04 118 119 /* 120 * Struct for supporting complex dictionaries like thesaurus. 121 * 4th argument for dictlexize method is a pointer to this 122 */ 123 typedef struct 124 { 125 bool isend; /* in: marks for lexize_info about text end is 126 * reached */ 127 bool getnext; /* out: dict wants next lexeme */ 128 void *private_state; /* internal dict state between calls with 129 * getnext == true */ 130 } DictSubState; 131 132 #endif /* _PG_TS_PUBLIC_H_ */ 133