2003-07-21 12:27:44 +02:00
|
|
|
#ifndef __QUERY_H__
|
|
|
|
#define __QUERY_H__
|
|
|
|
/*
|
|
|
|
#define BS_DEBUG
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* item in polish notation with back link
|
|
|
|
* to left operand
|
|
|
|
*/
|
|
|
|
typedef struct ITEM
|
|
|
|
{
|
|
|
|
int8 type;
|
|
|
|
int8 weight;
|
|
|
|
int2 left;
|
|
|
|
int4 val;
|
|
|
|
/* user-friendly value, must correlate with WordEntry */
|
2003-08-04 02:43:34 +02:00
|
|
|
uint32
|
New features for tsearch2:
1 Comparison operation for tsquery
2 Btree index on tsquery
3 numnode(tsquery) - returns 'length' of tsquery
4 tsquery @ tsquery, tsquery ~ tsquery - contains, contained for tsquery.
Note: They don't gurantee exact result, only MAY BE, so it
useful only for speed up rewrite functions
5 GiST index support for @,~
6 rewrite():
select rewrite(orig, what, to);
select rewrite(ARRAY[orig, what, to]) from tsquery_table;
select rewrite(orig, 'select what, to from tsquery_table;');
7 significantly improve cover algorithm
2005-11-08 18:08:46 +01:00
|
|
|
istrue:1, /* use for ranking in Cover */
|
2003-08-04 02:43:34 +02:00
|
|
|
length:11,
|
|
|
|
distance:20;
|
2003-07-21 12:27:44 +02:00
|
|
|
} ITEM;
|
|
|
|
|
|
|
|
/*
|
|
|
|
*Storage:
|
|
|
|
* (len)(size)(array of ITEM)(array of operand in user-friendly form)
|
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int4 len;
|
|
|
|
int4 size;
|
|
|
|
char data[1];
|
|
|
|
} QUERYTYPE;
|
|
|
|
|
2005-05-25 23:40:43 +02:00
|
|
|
#define HDRSIZEQT ( 2 * sizeof(int4) )
|
|
|
|
#define COMPUTESIZE(size,lenofoperand) ( HDRSIZEQT + (size) * sizeof(ITEM) + (lenofoperand) )
|
2003-07-21 12:27:44 +02:00
|
|
|
#define GETQUERY(x) (ITEM*)( (char*)(x)+HDRSIZEQT )
|
2005-05-25 23:40:43 +02:00
|
|
|
#define GETOPERAND(x) ( (char*)GETQUERY(x) + ((QUERYTYPE*)(x))->size * sizeof(ITEM) )
|
2003-07-21 12:27:44 +02:00
|
|
|
|
|
|
|
#define ISOPERATOR(x) ( (x)=='!' || (x)=='&' || (x)=='|' || (x)=='(' || (x)==')' )
|
|
|
|
|
|
|
|
#define END 0
|
|
|
|
#define ERR 1
|
|
|
|
#define VAL 2
|
|
|
|
#define OPR 3
|
|
|
|
#define OPEN 4
|
|
|
|
#define CLOSE 5
|
2003-08-28 14:23:24 +02:00
|
|
|
#define VALSTOP 6 /* for stop words */
|
2003-07-21 12:27:44 +02:00
|
|
|
|
|
|
|
bool TS_execute(ITEM * curitem, void *checkval,
|
2003-08-04 02:43:34 +02:00
|
|
|
bool calcnot, bool (*chkcond) (void *checkval, ITEM * val));
|
2003-07-21 12:27:44 +02:00
|
|
|
|
|
|
|
#endif
|