Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
61366a95
Commit
61366a95
authored
Aug 28, 2003
by
Teodor Sigaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More accuracy works with stopwords in queries
parent
d1031cde
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
56 deletions
+39
-56
contrib/tsearch2/expected/tsearch2.out
contrib/tsearch2/expected/tsearch2.out
+24
-0
contrib/tsearch2/query.c
contrib/tsearch2/query.c
+2
-11
contrib/tsearch2/query.h
contrib/tsearch2/query.h
+1
-2
contrib/tsearch2/rewrite.c
contrib/tsearch2/rewrite.c
+8
-43
contrib/tsearch2/sql/tsearch2.sql
contrib/tsearch2/sql/tsearch2.sql
+4
-0
No files found.
contrib/tsearch2/expected/tsearch2.out
View file @
61366a95
...
...
@@ -569,6 +569,30 @@ select to_tsquery('default', '\'the wether\':dc & \' sKies \':BC ');
'wether':CD & 'sky':BC
(1 row)
select to_tsquery('asd&(and|fghj)');
to_tsquery
----------------
'asd' & 'fghj'
(1 row)
select to_tsquery('(asd&and)|fghj');
to_tsquery
----------------
'asd' | 'fghj'
(1 row)
select to_tsquery('(asd&!and)|fghj');
to_tsquery
----------------
'asd' | 'fghj'
(1 row)
select to_tsquery('(the|and&(i&1))&fghj');
to_tsquery
--------------
'1' & 'fghj'
(1 row)
select 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca';
?column?
----------
...
...
contrib/tsearch2/query.c
View file @
61366a95
...
...
@@ -52,15 +52,6 @@ Datum to_tsquery_name(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1
(
to_tsquery_current
);
Datum
to_tsquery_current
(
PG_FUNCTION_ARGS
);
#define END 0
#define ERR 1
#define VAL 2
#define OPR 3
#define OPEN 4
#define CLOSE 5
#define VALTRUE 6
/* for stop words */
#define VALFALSE 7
/* parser's states */
#define WAITOPERAND 1
#define WAITOPERATOR 2
...
...
@@ -293,7 +284,7 @@ pushval_morph(QPRS_STATE * state, int typeval, char *strval, int lenval, int2 we
/* XXX */
if
(
prs
.
curwords
==
0
)
pushval_asis
(
state
,
VAL
TRUE
,
0
,
0
,
0
);
pushval_asis
(
state
,
VAL
STOP
,
0
,
0
,
0
);
}
#define STACKDEPTH 32
...
...
@@ -526,7 +517,7 @@ findoprnd(ITEM * ptr, int4 *pos)
elog
(
DEBUG3
,
(
ptr
[
*
pos
].
type
==
OPR
)
?
"%d %c"
:
"%d %d"
,
*
pos
,
ptr
[
*
pos
].
val
);
#endif
if
(
ptr
[
*
pos
].
type
==
VAL
||
ptr
[
*
pos
].
type
==
VAL
TRUE
)
if
(
ptr
[
*
pos
].
type
==
VAL
||
ptr
[
*
pos
].
type
==
VAL
STOP
)
{
ptr
[
*
pos
].
left
=
0
;
(
*
pos
)
++
;
...
...
contrib/tsearch2/query.h
View file @
61366a95
...
...
@@ -46,8 +46,7 @@ typedef struct
#define OPR 3
#define OPEN 4
#define CLOSE 5
#define VALTRUE 6
/* for stop words */
#define VALFALSE 7
#define VALSTOP 6
/* for stop words */
bool
TS_execute
(
ITEM
*
curitem
,
void
*
checkval
,
bool
calcnot
,
bool
(
*
chkcond
)
(
void
*
checkval
,
ITEM
*
val
));
...
...
contrib/tsearch2/rewrite.c
View file @
61366a95
...
...
@@ -177,6 +177,7 @@ clean_NOT_v2(ITEM * ptr, int4 *len)
#define V_UNKNOWN 0
#define V_TRUE 1
#define V_FALSE 2
#define V_STOP 3
/*
* Clean query tree from values which is always in
...
...
@@ -190,10 +191,10 @@ clean_fakeval_intree(NODE * node, char *result)
if
(
node
->
valnode
->
type
==
VAL
)
return
node
;
else
if
(
node
->
valnode
->
type
==
VAL
TRUE
)
else
if
(
node
->
valnode
->
type
==
VAL
STOP
)
{
pfree
(
node
);
*
result
=
V_
TRUE
;
*
result
=
V_
STOP
;
return
NULL
;
}
...
...
@@ -203,65 +204,29 @@ clean_fakeval_intree(NODE * node, char *result)
node
->
right
=
clean_fakeval_intree
(
node
->
right
,
&
rresult
);
if
(
!
node
->
right
)
{
*
result
=
(
rresult
==
V_TRUE
)
?
V_FALSE
:
V_TRUE
;
*
result
=
V_STOP
;
freetree
(
node
);
return
NULL
;
}
}
else
if
(
node
->
valnode
->
val
==
(
int4
)
'|'
)
{
NODE
*
res
=
node
;
node
->
left
=
clean_fakeval_intree
(
node
->
left
,
&
lresult
);
node
->
right
=
clean_fakeval_intree
(
node
->
right
,
&
rresult
);
if
(
lresult
==
V_TRUE
||
rresult
==
V_TRUE
)
{
freetree
(
node
);
*
result
=
V_TRUE
;
return
NULL
;
}
else
if
(
lresult
==
V_FALSE
&&
rresult
==
V_FALSE
)
{
freetree
(
node
);
*
result
=
V_FALSE
;
return
NULL
;
}
else
if
(
lresult
==
V_FALSE
)
{
res
=
node
->
right
;
pfree
(
node
);
}
else
if
(
rresult
==
V_FALSE
)
{
res
=
node
->
left
;
pfree
(
node
);
}
return
res
;
}
else
{
NODE
*
res
=
node
;
node
->
left
=
clean_fakeval_intree
(
node
->
left
,
&
lresult
);
node
->
right
=
clean_fakeval_intree
(
node
->
right
,
&
rresult
);
if
(
lresult
==
V_FALSE
||
rresult
==
V_FALSE
)
{
freetree
(
node
);
*
result
=
V_FALSE
;
return
NULL
;
}
else
if
(
lresult
==
V_TRUE
&&
rresult
==
V_TRUE
)
if
(
lresult
==
V_STOP
&&
rresult
==
V_STOP
)
{
freetree
(
node
);
*
result
=
V_
TRUE
;
*
result
=
V_
STOP
;
return
NULL
;
}
else
if
(
lresult
==
V_
TRUE
)
else
if
(
lresult
==
V_
STOP
)
{
res
=
node
->
right
;
pfree
(
node
);
}
else
if
(
rresult
==
V_
TRUE
)
else
if
(
rresult
==
V_
STOP
)
{
res
=
node
->
left
;
pfree
(
node
);
...
...
contrib/tsearch2/sql/tsearch2.sql
View file @
61366a95
...
...
@@ -87,6 +87,10 @@ SELECT length(to_tsvector('default', '345 qwe@efd.r \' http://www.com/ http://ae
select
to_tsquery
(
'default'
,
'qwe & sKies '
);
select
to_tsquery
(
'simple'
,
'qwe & sKies '
);
select
to_tsquery
(
'default'
,
'
\'
the wether
\'
:dc &
\'
sKies
\'
:BC '
);
select
to_tsquery
(
'asd&(and|fghj)'
);
select
to_tsquery
(
'(asd&and)|fghj'
);
select
to_tsquery
(
'(asd&!and)|fghj'
);
select
to_tsquery
(
'(the|and&(i&1))&fghj'
);
select
'a b:89 ca:23A,64b d:34c'
::
tsvector
@@
'd:AC & ca'
;
select
'a b:89 ca:23A,64b d:34c'
::
tsvector
@@
'd:AC & ca:B'
;
select
'a b:89 ca:23A,64b d:34c'
::
tsvector
@@
'd:AC & ca:A'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment