Change the fts3 snippet function to return (hopefully) more relevant snippets in less time.
FossilOrigin-Name: 8a208223a74d451f60d9cd707d63fb7d157d1737
This commit is contained in:
+17
-29
@@ -1131,39 +1131,36 @@ do_test fts3ac-4.2 {
|
||||
SELECT snippet(email) FROM email
|
||||
WHERE email MATCH 'christmas candlelight'
|
||||
}
|
||||
} {{<b>...</b> place.? What do you think about going here <b>Christmas</b>
|
||||
eve?? They have an 11:00 a.m. service and a <b>candlelight</b> service at 5:00 p.m.,
|
||||
among others. <b>...</b>}}
|
||||
} {{<b>...</b>here <b>Christmas</b>
|
||||
eve?? They have an 11:00 a.m. service and a <b>candlelight</b> service<b>...</b>}}
|
||||
|
||||
do_test fts3ac-4.3 {
|
||||
execsql {
|
||||
SELECT snippet(email) FROM email
|
||||
WHERE email MATCH 'deal sheet potential reuse'
|
||||
}
|
||||
} {{EOL-Accenture <b>Deal</b> <b>Sheet</b> <b>...</b> intent
|
||||
Review Enron asset base for <b>potential</b> <b>reuse</b>/ licensing
|
||||
Contract negotiations <b>...</b>}}
|
||||
} {{EOL-Accenture <b>Deal</b> <b>Sheet</b><b>...</b>asset base for <b>potential</b> <b>reuse</b>/ licensing
|
||||
Contract negotiations<b>...</b>}}
|
||||
do_test fts3ac-4.4 {
|
||||
execsql {
|
||||
SELECT snippet(email,'<<<','>>>',' ') FROM email
|
||||
WHERE email MATCH 'deal sheet potential reuse'
|
||||
}
|
||||
} {{EOL-Accenture <<<Deal>>> <<<Sheet>>> intent
|
||||
Review Enron asset base for <<<potential>>> <<<reuse>>>/ licensing
|
||||
Contract negotiations }}
|
||||
} {{EOL-Accenture <<<Deal>>> <<<Sheet>>> asset base for <<<potential>>> <<<reuse>>>/ licensing
|
||||
Contract negotiations }}
|
||||
do_test fts3ac-4.5 {
|
||||
execsql {
|
||||
SELECT snippet(email,'<<<','>>>',' ') FROM email
|
||||
WHERE email MATCH 'first things'
|
||||
}
|
||||
} {{Re: <<<First>>> Polish Deal! Congrats! <<<Things>>> seem to be building rapidly now on the }}
|
||||
} {{Re: <<<First>>> Polish Deal! Congrats! <<<Things>>> seem to be building rapidly now }}
|
||||
do_test fts3ac-4.6 {
|
||||
execsql {
|
||||
SELECT snippet(email) FROM email
|
||||
WHERE email MATCH 'chris is here'
|
||||
}
|
||||
} {{<b>chris</b>.germany@enron.com <b>...</b> Sounds good to me. I bet this <b>is</b> next to the Warick?? Hotel. <b>...</b> place.? What do you think about going <b>here</b> Christmas
|
||||
eve?? They have an 11:00 a.m. <b>...</b>}}
|
||||
} {{<b>...</b><b>chris</b>.germany@enron.com'" <<b>chris</b><b>...</b>bet this <b>is</b> next to<b>...</b>about going <b>here</b> Christmas
|
||||
eve<b>...</b>}}
|
||||
do_test fts3ac-4.7 {
|
||||
execsql {
|
||||
SELECT snippet(email) FROM email
|
||||
@@ -1171,19 +1168,15 @@ do_test fts3ac-4.7 {
|
||||
}
|
||||
} {{Erin:
|
||||
|
||||
<b>Pursuant</b> <b>to</b> your request, attached are the Schedule to <b>...</b>}}
|
||||
<b>Pursuant</b> <b>to</b> your request, attached are the Schedule to the ISDA Master Agreement, together<b>...</b>}}
|
||||
do_test fts3ac-4.8 {
|
||||
execsql {
|
||||
SELECT snippet(email) FROM email
|
||||
WHERE email MATCH 'ancillary load davis'
|
||||
}
|
||||
} {{pete.<b>davis</b>@enron.com <b>...</b> Start Date: 4/22/01; HourAhead hour: 3; No <b>ancillary</b> schedules awarded.
|
||||
Variances detected.
|
||||
Variances detected in <b>Load</b> schedule.
|
||||
} {{pete.<b>davis</b>@enron.com<b>...</b>3; No <b>ancillary</b> schedules awarded<b>...</b>detected in <b>Load</b> schedule.
|
||||
|
||||
LOG MESSAGES:
|
||||
|
||||
PARSING <b>...</b>}}
|
||||
LOG<b>...</b>}}
|
||||
|
||||
# Combinations of AND and OR operators:
|
||||
#
|
||||
@@ -1192,22 +1185,17 @@ do_test fts3ac-5.1 {
|
||||
SELECT snippet(email) FROM email
|
||||
WHERE email MATCH 'questar enron OR com'
|
||||
}
|
||||
} {{matt.smith@<b>enron</b>.<b>com</b> <b>...</b> six reports:
|
||||
|
||||
31 Keystone Receipts
|
||||
} {{matt.smith@<b>enron</b>.<b>com</b><b>...</b>31 Keystone Receipts
|
||||
15 <b>Questar</b> Pipeline
|
||||
40 Rockies Production
|
||||
22 West_2 <b>...</b>}}
|
||||
40 Rockies<b>...</b>}}
|
||||
|
||||
do_test fts3ac-5.2 {
|
||||
execsql {
|
||||
SELECT snippet(email) FROM email
|
||||
WHERE email MATCH 'enron OR com questar'
|
||||
}
|
||||
} {{matt.smith@<b>enron</b>.<b>com</b> <b>...</b> six reports:
|
||||
|
||||
31 Keystone Receipts
|
||||
} {{matt.smith@<b>enron</b>.<b>com</b><b>...</b>31 Keystone Receipts
|
||||
15 <b>Questar</b> Pipeline
|
||||
40 Rockies Production
|
||||
22 West_2 <b>...</b>}}
|
||||
40 Rockies<b>...</b>}}
|
||||
|
||||
finish_test
|
||||
|
||||
+5
-1
@@ -53,6 +53,10 @@ do_test fts3al-1.3 {
|
||||
#
|
||||
# The trailing and leading hi-bit chars help with code which tests for
|
||||
# isspace() to coalesce multiple spaces.
|
||||
#
|
||||
# UPDATE: The above is no longer true; there is no such code in fts3.
|
||||
# But leave the test in just the same.
|
||||
#
|
||||
|
||||
set word "\x80xxxxx\x80xxxxx\x80xxxxx\x80xxxxx\x80xxxxx\x80xxxxx\x80"
|
||||
set phrase1 "$word $word $word target $word $word $word"
|
||||
@@ -64,6 +68,6 @@ db eval "INSERT INTO t4 (content) VALUES ('$phrase2')"
|
||||
|
||||
do_test fts3al-1.4 {
|
||||
execsql {SELECT rowid, length(snippet(t4)) FROM t4 WHERE t4 MATCH 'target'}
|
||||
} {1 111 2 117}
|
||||
} {1 241 2 247}
|
||||
|
||||
finish_test
|
||||
|
||||
+13
-1
@@ -76,6 +76,17 @@ do_test fts3near-1.15 {
|
||||
execsql {SELECT docid FROM t1 WHERE content MATCH 'one NEAR two NEAR one'}
|
||||
} {3}
|
||||
|
||||
do_test fts3near-1.16 {
|
||||
execsql {
|
||||
SELECT docid FROM t1 WHERE content MATCH '"one three" NEAR/0 "four five"'
|
||||
}
|
||||
} {1}
|
||||
do_test fts3near-1.17 {
|
||||
execsql {
|
||||
SELECT docid FROM t1 WHERE content MATCH '"four five" NEAR/0 "one three"'
|
||||
}
|
||||
} {1}
|
||||
|
||||
|
||||
# Output format of the offsets() function:
|
||||
#
|
||||
@@ -154,6 +165,7 @@ do_test fts3near-3.6 {
|
||||
SELECT offsets(t1) FROM t1 WHERE content MATCH 'three NEAR/0 "two four"'
|
||||
}
|
||||
} {{0 0 8 5 0 1 14 3 0 2 18 4}}
|
||||
breakpoint
|
||||
do_test fts3near-3.7 {
|
||||
execsql {
|
||||
SELECT offsets(t1) FROM t1 WHERE content MATCH '"two four" NEAR/0 three'}
|
||||
@@ -170,7 +182,7 @@ do_test fts3near-4.1 {
|
||||
execsql {
|
||||
SELECT snippet(t1) FROM t1 WHERE content MATCH 'specification NEAR supports'
|
||||
}
|
||||
} {{<b>...</b> devices, handheld devices, etc. This <b>specification</b> also <b>supports</b> content positioning, downloadable fonts, <b>...</b>}}
|
||||
} {{<b>...</b>braille devices, handheld devices, etc. This <b>specification</b> also <b>supports</b> content positioning, downloadable fonts, table layout<b>...</b>}}
|
||||
|
||||
do_test fts3near-5.1 {
|
||||
execsql {
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
|
||||
ifcapable !fts3 { finish_test ; return }
|
||||
|
||||
do_test fts3snippet-1.1 {
|
||||
execsql {
|
||||
CREATE VIRTUAL TABLE ft USING fts3;
|
||||
INSERT INTO ft VALUES('xxx xxx xxx xxx');
|
||||
}
|
||||
} {}
|
||||
|
||||
proc normalize {L} {
|
||||
set ret [list]
|
||||
foreach l $L {lappend ret $l}
|
||||
return $ret
|
||||
}
|
||||
|
||||
do_test fts3snippet-1.2 {
|
||||
execsql { SELECT offsets(ft) FROM ft WHERE ft MATCH 'xxx' }
|
||||
} {{0 0 0 3 0 0 4 3 0 0 8 3 0 0 12 3}}
|
||||
|
||||
do_test fts3snippet-1.3 {
|
||||
execsql { SELECT offsets(ft) FROM ft WHERE ft MATCH '"xxx xxx"' }
|
||||
} [list [normalize {
|
||||
0 0 0 3
|
||||
0 0 4 3
|
||||
0 1 4 3
|
||||
0 0 8 3
|
||||
0 1 8 3
|
||||
0 1 12 3
|
||||
}]]
|
||||
|
||||
|
||||
do_test fts3snippet-1.4 {
|
||||
execsql { SELECT offsets(ft) FROM ft WHERE ft MATCH '"xxx xxx" xxx' }
|
||||
} [list [normalize {
|
||||
0 0 0 3
|
||||
0 2 0 3
|
||||
0 0 4 3
|
||||
0 1 4 3
|
||||
0 2 4 3
|
||||
0 0 8 3
|
||||
0 1 8 3
|
||||
0 2 8 3
|
||||
0 1 12 3
|
||||
0 2 12 3
|
||||
}]]
|
||||
|
||||
do_test fts3snippet-1.5 {
|
||||
execsql { SELECT offsets(ft) FROM ft WHERE ft MATCH 'xxx "xxx xxx"' }
|
||||
} [list [normalize {
|
||||
0 0 0 3
|
||||
0 1 0 3
|
||||
0 0 4 3
|
||||
0 1 4 3
|
||||
0 2 4 3
|
||||
0 0 8 3
|
||||
0 1 8 3
|
||||
0 2 8 3
|
||||
0 0 12 3
|
||||
0 2 12 3
|
||||
}]]
|
||||
|
||||
finish_test
|
||||
|
||||
Reference in New Issue
Block a user