#29084: tests.postgres_tests.test_search.SimpleSearchTest:
to_tsvector/plainto_tsquery need 'english' as first parameter
-------------------------------------+-------------------------------------
Reporter: Дилян | Owner: (none)
Палаузов |
Type: | Status: new
Uncategorized |
Component: | Version: 1.11
contrib.postgres | Keywords: tests postgresql
Severity: Normal | search
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
tests/postgres_tests/test_search.py:class SimpleSearchTest contains:
{{{
def test_non_exact_match(self):
searched = Line.objects.filter(dialogue__search='hearts')
self.assertSequenceEqual(searched, [self.verse2])
def test_search_two_terms(self):
searched = Line.objects.filter(dialogue__search='heart bowel')
self.assertSequenceEqual(searched, [self.verse2])
}}}
The first test calls:
> SELECT to_tsvector('His head smashed in and his heart cut out, ') @@
plainto_tsquery('hearts')
which is false. In particular:
{{{SELECT to_tsvector('His head smashed in and his heart cut out, ');}}}
returns {{{'and':5 'cut':8 'head':2 'heart':7 'his':1,6 'in':4 'out':9
'smashed':3}}} and {{{SELECT plainto_tsquery('hearts');}}} returns
{{{'hearts'}}}.
However this works:
> SELECT to_tsvector('english', 'His head smashed in and his heart cut
out, ') @@ plainto_tsquery('english', 'hearts');
as {{{SELECT to_tsvector('english', 'His head smashed in and his heart cut
out, ')}}} returns {{{'cut':8 'head':2 'heart':7 'smash':3}}} and
{{{SELECT plainto_tsquery('english', 'hearts');}}} returns {{{heart}}}.
The second test calls:
> SELECT to_tsvector(COALESCE('His head smashed in and his heart cut out,
And his liver removed and his bowels unplugged, And his nostrils ripped
and his bottom burned off, And his--')) @@ plainto_tsquery('heart bowel');
which is again false. In particular {{{SELECT COALESCE('His head smashed
in and his heart cut out, And his liver removed and his bowels unplugged,
And his nostrils ripped and his bottom burned off, And his--');}}} returns
{{{His head smashed in and his heart cut out, And his liver removed and
his bowels unplugged, And his nostrils ripped and his bottom burned off,
And his--}}}, {{{SELECT to_tsvector(COALESCE('His head smashed in and his
heart cut out, And his liver removed and his bowels unplugged, And his
nostrils ripped and his bottom burned off, And his--'));}}} returns
{{{and':5,10,14,18,22,27 'bottom':24 'bowels':16 'burned':25 'cut':8
'head':2 'heart':7 'his':1,6,11,15,19,23,28 'in':4 'liver':12
'nostrils':20 'off':26 'out':9 'removed':13 'ripped':21 'smashed':3
'unplugged':17}}} and {{{SELECT plainto_tsquery('heart bowel');}}} returns
{{{'heart' & 'bowel'}}}.
Here again 'english' helps:
{{{SELECT to_tsvector('english', COALESCE('His head smashed in and his
heart cut out, And his liver removed and his bowels unplugged, And his
nostrils ripped and his bottom burned off, And his--'));}}} returns
{{{'bottom':24 'bowel':16 'burn':25 'cut':8 'head':2 'heart':7 'liver':12
'nostril':20 'remov':13 'rip':21 'smash':3 'unplug':17}}} and
> SELECT to_tsvector('english', COALESCE('His head smashed in and his
heart cut out, And his liver removed and his bowels unplugged, And his
nostrils ripped and his bottom burned off, And his--')) @@
(plainto_tsquery('heart bowel'));
is true.
--
Ticket URL: <https://code.djangoproject.com/ticket/29084>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/057.608b8c6104e406a308ed51a5fd460e74%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.