PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
ts_public.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * ts_public.h
4  * Public interface to various tsearch modules, such as
5  * parsers and dictionaries.
6  *
7  * Copyright (c) 1998-2017, 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;
46  char *word;
49 
50 typedef struct
51 {
55  int32 vectorpos; /* positions a-la tsvector */
56  char *startsel;
57  char *stopsel;
58  char *fragdelim;
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  */
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_ */
uint16 WordEntryPos
Definition: ts_type.h:63
signed short int16
Definition: c.h:255
static void skip(struct vars *v)
Definition: regc_lex.c:1109
char * alias
Definition: ts_public.h:28
bool getnext
Definition: ts_public.h:127
char * get_tsearch_config_filename(const char *basename, const char *extension)
Definition: ts_utils.c:33
QueryOperand * item
Definition: ts_public.h:47
WordEntryPos pos
Definition: ts_public.h:45
signed int int32
Definition: c.h:256
unsigned short uint16
Definition: c.h:267
char ** stop
Definition: ts_public.h:76
char * lexeme
Definition: ts_public.h:111
HeadlineWordEntry * words
Definition: ts_public.h:52
unsigned int uint32
Definition: c.h:268
bool searchstoplist(StopList *s, char *key)
Definition: ts_utils.c:141
uint16 nvariant
Definition: ts_public.h:107
uint16 flags
Definition: ts_public.h:109
char * descr
Definition: ts_public.h:29
void readstoplist(const char *fname, StopList *s, char *(*wordop)(const char *))
Definition: ts_utils.c:68
int lexid
Definition: ts_public.h:27
int len
Definition: ts_public.h:75
void * private_state
Definition: ts_public.h:128