Merge lp:~wallyworld/launchpad/remove-personpicker-fti-query into lp:launchpad

Proposed by Ian Booth
Status: Rejected
Rejected by: Ian Booth
Proposed branch: lp:~wallyworld/launchpad/remove-personpicker-fti-query
Merge into: lp:launchpad
Diff against target: 104 lines (+8/-22)
1 file modified
lib/lp/registry/vocabularies.py (+8/-22)
To merge this branch: bzr merge lp:~wallyworld/launchpad/remove-personpicker-fti-query
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+62120@code.launchpad.net

Commit message

[r=sinzui][bug=618356] Remove fti query from the person picker searches.

Description of the change

The person picker search can time out due to there being no ftq index.

== Implementation ==

As part of the disclosure work, the picker is being revamped. It was agreed that there is little benefit in doing a fti match and so it is reasonable to remove that for now.

== Tests ==

Run existing person picker tests, eg test_person_picker_widget

== Lint ==

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/registry/vocabularies.py

./lib/lp/registry/vocabularies.py
     584: E261 at least two spaces before inline comment

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you for making the search faster and more accurate.

review: Approve (code)
Revision history for this message
Ian Booth (wallyworld) wrote :

Rejected. Subsequent testing shows that matching on displayname requires fti. Adding fti index to prod instead.

Revision history for this message
Curtis Hovey (sinzui) wrote :

Why cannot we change the code to check displayname. I think the masses of bad matches in search is caused by words in the summary and description.

Revision history for this message
Curtis Hovey (sinzui) wrote :

person.fti contains name and displayname. The query singles out name (Launchpad Id) to give it the highest rank. Is faster and clearer to just check the displayname column? I think fti provides stem and case normalisation, which may make searching for teams easier.

Revision history for this message
Ian Booth (wallyworld) wrote :

I asked about doing this but was told that using fti is preferred since
a search for "Fred Bloggs" will still match "Fred J Bloggs" and hence a
simple displayname comparison is not sufficient. It was also mentioned
that since the fti only includes name and displayname, there should not
be crap results based on other "bad" matches.

On 25/05/11 23:57, Curtis Hovey wrote:
> Why cannot we change the code to check displayname. I think the masses of bad matches in search is caused by words in the summary and description.

Revision history for this message
Robert Collins (lifeless) wrote :

On Thu, May 26, 2011 at 10:37 AM, Ian Booth <email address hidden> wrote:
> I asked about doing this but was told that using fti is preferred since
> a search for "Fred Bloggs" will still match "Fred J Bloggs" and hence a
> simple displayname comparison is not sufficient. It was also mentioned
> that since the fti only includes name and displayname, there should not
> be crap results based on other "bad" matches.

And display name isn't indexed. So we would need to add an index on
that instead of the one we're meant to have on person_fti.

-Rob

Unmerged revisions

13109. By Ian Booth

Lint

13108. By Ian Booth

Remove fti matching for picker seaches

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/vocabularies.py'
2--- lib/lp/registry/vocabularies.py 2011-05-14 15:02:13 +0000
3+++ lib/lp/registry/vocabularies.py 2011-05-24 12:53:42 +0000
4@@ -50,7 +50,6 @@
5 'SourcePackageNameVocabulary',
6 'UserTeamsParticipationPlusSelfVocabulary',
7 'UserTeamsParticipationVocabulary',
8- 'ValidPersonOrClosedTeamVocabulary',
9 'ValidPersonOrTeamVocabulary',
10 'ValidPersonVocabulary',
11 'ValidTeamMemberVocabulary',
12@@ -543,11 +542,11 @@
13 ]
14
15 # Create an inner query that will match public persons and teams
16- # that have the search text in the fti, at the start of the email
17- # address, or as their full IRC nickname.
18+ # that have the search text at the start of the email address,
19+ # or as their full IRC nickname.
20 # Since we may be eliminating results with the limit to improve
21 # performance, we sort by the rank, so that we will always get
22- # the best results. The fti rank will be between 0 and 1.
23+ # the best results.
24 # Note we use lower() instead of the non-standard ILIKE because
25 # ILIKE doesn't hit the indexes.
26 # The '%%' is necessary because storm variable substitution
27@@ -558,10 +557,6 @@
28 FROM Person
29 WHERE name = ?
30 UNION ALL
31- SELECT Person.id, rank(fti, ftq(?))
32- FROM Person
33- WHERE Person.fti @@ ftq(?)
34- UNION ALL
35 SELECT Person.id, 10 AS rank
36 FROM Person, IrcId
37 WHERE IrcId.person = Person.id
38@@ -575,12 +570,11 @@
39 ) AS public_subquery
40 ORDER BY rank DESC
41 LIMIT ?
42- """, (text, text, text, text, text,
43+ """, (text, text, text,
44 EmailAddressStatus.VALIDATED.value,
45 EmailAddressStatus.PREFERRED.value,
46 self.LIMIT))
47
48-
49 public_result = self.store.using(*public_tables).find(
50 Person,
51 And(
52@@ -606,13 +600,9 @@
53 # but we're electing to ignore them here.
54 private_result = self.store.using(*private_tables).find(
55 Person,
56- And(
57- SQL('Person.fti @@ ftq(?)', [text]),
58- private_query,
59- )
60+ private_query,
61 )
62
63- private_result.order_by(SQL('rank(fti, ftq(?)) DESC', [text]))
64 private_result.config(limit=self.LIMIT)
65
66 combined_result = public_result.union(private_result)
67@@ -676,7 +666,7 @@
68 allow_null_search = True
69
70 def _doSearch(self, text=""):
71- """Return the teams whose fti, IRC, or email address match :text:"""
72+ """Return the teams whose IRC, or email address match :text:"""
73
74 private_query, private_tables = self._privateTeamQueryAndTables()
75 base_query = And(
76@@ -695,8 +685,6 @@
77 self.extra_clause)
78 result = self.store.using(*tables).find(Person, query)
79 else:
80- name_match_query = SQL("Person.fti @@ ftq(%s)" % quote(text))
81-
82 email_storm_query = self.store.find(
83 EmailAddress.personID,
84 EmailAddress.email.lower().startswith(text))
85@@ -709,9 +697,7 @@
86 result = self.store.using(*tables).find(
87 Person,
88 And(base_query,
89- self.extra_clause,
90- Or(name_match_query,
91- EmailAddress.person != None)))
92+ self.extra_clause))
93
94 # XXX: BradCrittenden 2009-05-07 bug=373228: A bug in Storm prevents
95 # setting the 'distinct' and 'limit' options in a single call to
96@@ -1433,7 +1419,7 @@
97
98 def __iter__(self):
99 series = self._table.select(
100- DistroSeries.q.distributionID==Distribution.q.id,
101+ DistroSeries.q.distributionID == Distribution.q.id,
102 orderBy=self._orderBy, clauseTables=self._clauseTables)
103 for series in sorted(series, key=attrgetter('sortkey')):
104 yield self.toTerm(series)