{"action":"created","comment":{"url":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/comments/237406028","pull_request_review_id":179693549,"id":237406028,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNzQwNjAyOA==","diff_hunk":"@@ -10,6 +11,23 @@\n DOC_TYPE = 'company'\n \n \n+def get_suggestions(db_company):\n+    \"\"\"\n+    A list of fields used by the completion suggester to\n+    find a record when using quick search.\n+    \"\"\"\n+    if db_company.archived:\n+        return []\n+\n+    alias_names = db_company.alias.split(' ') if db_company.alias else []\n+\n+    data = itertools.chain(\n+        db_company.name.split(' '), alias_names,\n+        [db_company.name, db_company.alias],\n+    )","path":"datahub/search/company/models.py","position":26,"original_position":26,"commit_id":"d85ab96d4a0b636a7243ce0be7d12450f3a13893","original_commit_id":"d85ab96d4a0b636a7243ce0be7d12450f3a13893","user":{"login":"marcuspp","id":8222658,"node_id":"MDQ6VXNlcjgyMjI2NTg=","avatar_url":"https://avatars0.githubusercontent.com/u/8222658?v=4","gravatar_id":"","url":"https://api.github.com/users/marcuspp","html_url":"https://github.com/marcuspp","followers_url":"https://api.github.com/users/marcuspp/followers","following_url":"https://api.github.com/users/marcuspp/following{/other_user}","gists_url":"https://api.github.com/users/marcuspp/gists{/gist_id}","starred_url":"https://api.github.com/users/marcuspp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcuspp/subscriptions","organizations_url":"https://api.github.com/users/marcuspp/orgs","repos_url":"https://api.github.com/users/marcuspp/repos","events_url":"https://api.github.com/users/marcuspp/events{/privacy}","received_events_url":"https://api.github.com/users/marcuspp/received_events","type":"User","site_admin":false},"body":"Sure. Do you think anything else should go in here? I was toying with the idea of adding the company number so that if anyone knew it the company would show up.\r\n\r\nAnother thing I probably should of mentioned in the PR description is that each one of the suggestion could be weighted to boost them in the search. I have initially left that out as didn't want to complicate things to begin with but interested to hear everyone else's thoughts.","created_at":"2018-11-29T09:22:39Z","updated_at":"2018-11-29T09:22:39Z","html_url":"https://github.com/uktrade/data-hub-leeloo/pull/1258#discussion_r237406028","pull_request_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/1258","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/comments/237406028"},"html":{"href":"https://github.com/uktrade/data-hub-leeloo/pull/1258#discussion_r237406028"},"pull_request":{"href":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/1258"}},"in_reply_to_id":237161313},"pull_request":{"url":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/1258","id":234262481,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM0MjYyNDgx","html_url":"https://github.com/uktrade/data-hub-leeloo/pull/1258","diff_url":"https://github.com/uktrade/data-hub-leeloo/pull/1258.diff","patch_url":"https://github.com/uktrade/data-hub-leeloo/pull/1258.patch","issue_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues/1258","number":1258,"state":"open","locked":false,"title":"Company autocomplete search support","user":{"login":"marcuspp","id":8222658,"node_id":"MDQ6VXNlcjgyMjI2NTg=","avatar_url":"https://avatars0.githubusercontent.com/u/8222658?v=4","gravatar_id":"","url":"https://api.github.com/users/marcuspp","html_url":"https://github.com/marcuspp","followers_url":"https://api.github.com/users/marcuspp/followers","following_url":"https://api.github.com/users/marcuspp/following{/other_user}","gists_url":"https://api.github.com/users/marcuspp/gists{/gist_id}","starred_url":"https://api.github.com/users/marcuspp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcuspp/subscriptions","organizations_url":"https://api.github.com/users/marcuspp/orgs","repos_url":"https://api.github.com/users/marcuspp/repos","events_url":"https://api.github.com/users/marcuspp/events{/privacy}","received_events_url":"https://api.github.com/users/marcuspp/received_events","type":"User","site_admin":false},"body":"### Description of change\r\nTo support autocomplete or type-ahead for companies I've utilised the elasticsearch completion suggester and added it to the company elastic search model. It seems to work quite nicely (tested locally with 100K of companies) but am happy to rework any aspect of it as I am aware this sort of field uses more server memory etc. The completion suggestions are just what I think will work best am happy to add and remove values based on anyone else's recommendations. Completion suggestions also supports fuzzy matching which for the moment I have not used. I think the index will need to be rebuilt as the the mapping has changed.\r\n\r\n### How to test\r\n- Reindex some companies\r\n- Go to http://localhost:8000/v3/search/company/quick?q=mar\r\n\r\nI've found adding https://pypi.org/project/django-elasticsearch-debug-toolbar/ to the debug tool bar helped me work out what queries were being executed ie a double execution of the query. (For some reason when you click to view the json in chrome the link doesn't work so Ive had to inspect and remove the display class)\r\n\r\n\r\n### Checklist\r\n\r\n* [x] Has a new newsfragment been created? Check [changelog/README.rst](https://github.com/uktrade/data-hub-leeloo/blob/master/changelog/README.rst) for instructions\r\n* [ ] Have any relevant search models been updated?\r\n* [ ] Have any relevant fixtures (`fixtures/test_data.yaml`) been updated?\r\n* [ ] Have any relevant select-/prefetch-related field lists in the views and search apps been updated?\r\n* [ ] Has the admin site been updated (for new models, fields etc.)?\r\n* [ ] Has the README been updated (if needed)?\r\n","created_at":"2018-11-28T12:42:10Z","updated_at":"2018-11-29T09:22:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7f72c7913cdec76db82f831478dcdae37a3d9fac","assignee":null,"assignees":[],"requested_reviewers":[{"login":"reupen","id":12693549,"node_id":"MDQ6VXNlcjEyNjkzNTQ5","avatar_url":"https://avatars1.githubusercontent.com/u/12693549?v=4","gravatar_id":"","url":"https://api.github.com/users/reupen","html_url":"https://github.com/reupen","followers_url":"https://api.github.com/users/reupen/followers","following_url":"https://api.github.com/users/reupen/following{/other_user}","gists_url":"https://api.github.com/users/reupen/gists{/gist_id}","starred_url":"https://api.github.com/users/reupen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reupen/subscriptions","organizations_url":"https://api.github.com/users/reupen/orgs","repos_url":"https://api.github.com/users/reupen/repos","events_url":"https://api.github.com/users/reupen/events{/privacy}","received_events_url":"https://api.github.com/users/reupen/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/1258/commits","review_comments_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/1258/comments","review_comment_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues/1258/comments","statuses_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/statuses/d85ab96d4a0b636a7243ce0be7d12450f3a13893","head":{"label":"uktrade:feature/company_quick_search","ref":"feature/company_quick_search","sha":"d85ab96d4a0b636a7243ce0be7d12450f3a13893","user":{"login":"uktrade","id":15107524,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1MTA3NTI0","avatar_url":"https://avatars2.githubusercontent.com/u/15107524?v=4","gravatar_id":"","url":"https://api.github.com/users/uktrade","html_url":"https://github.com/uktrade","followers_url":"https://api.github.com/users/uktrade/followers","following_url":"https://api.github.com/users/uktrade/following{/other_user}","gists_url":"https://api.github.com/users/uktrade/gists{/gist_id}","starred_url":"https://api.github.com/users/uktrade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uktrade/subscriptions","organizations_url":"https://api.github.com/users/uktrade/orgs","repos_url":"https://api.github.com/users/uktrade/repos","events_url":"https://api.github.com/users/uktrade/events{/privacy}","received_events_url":"https://api.github.com/users/uktrade/received_events","type":"Organization","site_admin":false},"repo":{"id":73379434,"node_id":"MDEwOlJlcG9zaXRvcnk3MzM3OTQzNA==","name":"data-hub-leeloo","full_name":"uktrade/data-hub-leeloo","private":false,"owner":{"login":"uktrade","id":15107524,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1MTA3NTI0","avatar_url":"https://avatars2.githubusercontent.com/u/15107524?v=4","gravatar_id":"","url":"https://api.github.com/users/uktrade","html_url":"https://github.com/uktrade","followers_url":"https://api.github.com/users/uktrade/followers","following_url":"https://api.github.com/users/uktrade/following{/other_user}","gists_url":"https://api.github.com/users/uktrade/gists{/gist_id}","starred_url":"https://api.github.com/users/uktrade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uktrade/subscriptions","organizations_url":"https://api.github.com/users/uktrade/orgs","repos_url":"https://api.github.com/users/uktrade/repos","events_url":"https://api.github.com/users/uktrade/events{/privacy}","received_events_url":"https://api.github.com/users/uktrade/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/uktrade/data-hub-leeloo","description":"Django API for Data Hub frontend","fork":false,"url":"https://api.github.com/repos/uktrade/data-hub-leeloo","forks_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/forks","keys_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/teams","hooks_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/hooks","issue_events_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues/events{/number}","events_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/events","assignees_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/assignees{/user}","branches_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/branches{/branch}","tags_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/tags","blobs_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/git/refs{/sha}","trees_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/statuses/{sha}","languages_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/languages","stargazers_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/stargazers","contributors_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/contributors","subscribers_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/subscribers","subscription_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/subscription","commits_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/commits{/sha}","git_commits_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/git/commits{/sha}","comments_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/comments{/number}","issue_comment_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues/comments{/number}","contents_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/contents/{+path}","compare_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/merges","archive_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/downloads","issues_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues{/number}","pulls_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls{/number}","milestones_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/milestones{/number}","notifications_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/labels{/name}","releases_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/releases{/id}","deployments_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/deployments","created_at":"2016-11-10T12:21:01Z","updated_at":"2018-11-28T09:57:56Z","pushed_at":"2018-11-28T17:09:08Z","git_url":"git://github.com/uktrade/data-hub-leeloo.git","ssh_url":"git@github.com:uktrade/data-hub-leeloo.git","clone_url":"https://github.com/uktrade/data-hub-leeloo.git","svn_url":"https://github.com/uktrade/data-hub-leeloo","homepage":null,"size":6361,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":13,"license":null,"forks":2,"open_issues":13,"watchers":1,"default_branch":"develop"}},"base":{"label":"uktrade:develop","ref":"develop","sha":"8bf4fd747aa950af0d3e8b0af642993ea026833b","user":{"login":"uktrade","id":15107524,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1MTA3NTI0","avatar_url":"https://avatars2.githubusercontent.com/u/15107524?v=4","gravatar_id":"","url":"https://api.github.com/users/uktrade","html_url":"https://github.com/uktrade","followers_url":"https://api.github.com/users/uktrade/followers","following_url":"https://api.github.com/users/uktrade/following{/other_user}","gists_url":"https://api.github.com/users/uktrade/gists{/gist_id}","starred_url":"https://api.github.com/users/uktrade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uktrade/subscriptions","organizations_url":"https://api.github.com/users/uktrade/orgs","repos_url":"https://api.github.com/users/uktrade/repos","events_url":"https://api.github.com/users/uktrade/events{/privacy}","received_events_url":"https://api.github.com/users/uktrade/received_events","type":"Organization","site_admin":false},"repo":{"id":73379434,"node_id":"MDEwOlJlcG9zaXRvcnk3MzM3OTQzNA==","name":"data-hub-leeloo","full_name":"uktrade/data-hub-leeloo","private":false,"owner":{"login":"uktrade","id":15107524,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1MTA3NTI0","avatar_url":"https://avatars2.githubusercontent.com/u/15107524?v=4","gravatar_id":"","url":"https://api.github.com/users/uktrade","html_url":"https://github.com/uktrade","followers_url":"https://api.github.com/users/uktrade/followers","following_url":"https://api.github.com/users/uktrade/following{/other_user}","gists_url":"https://api.github.com/users/uktrade/gists{/gist_id}","starred_url":"https://api.github.com/users/uktrade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uktrade/subscriptions","organizations_url":"https://api.github.com/users/uktrade/orgs","repos_url":"https://api.github.com/users/uktrade/repos","events_url":"https://api.github.com/users/uktrade/events{/privacy}","received_events_url":"https://api.github.com/users/uktrade/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/uktrade/data-hub-leeloo","description":"Django API for Data Hub frontend","fork":false,"url":"https://api.github.com/repos/uktrade/data-hub-leeloo","forks_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/forks","keys_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/teams","hooks_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/hooks","issue_events_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues/events{/number}","events_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/events","assignees_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/assignees{/user}","branches_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/branches{/branch}","tags_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/tags","blobs_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/git/refs{/sha}","trees_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/statuses/{sha}","languages_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/languages","stargazers_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/stargazers","contributors_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/contributors","subscribers_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/subscribers","subscription_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/subscription","commits_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/commits{/sha}","git_commits_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/git/commits{/sha}","comments_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/comments{/number}","issue_comment_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues/comments{/number}","contents_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/contents/{+path}","compare_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/merges","archive_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/downloads","issues_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues{/number}","pulls_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls{/number}","milestones_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/milestones{/number}","notifications_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/labels{/name}","releases_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/releases{/id}","deployments_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/deployments","created_at":"2016-11-10T12:21:01Z","updated_at":"2018-11-28T09:57:56Z","pushed_at":"2018-11-28T17:09:08Z","git_url":"git://github.com/uktrade/data-hub-leeloo.git","ssh_url":"git@github.com:uktrade/data-hub-leeloo.git","clone_url":"https://github.com/uktrade/data-hub-leeloo.git","svn_url":"https://github.com/uktrade/data-hub-leeloo","homepage":null,"size":6361,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":13,"license":null,"forks":2,"open_issues":13,"watchers":1,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/1258"},"html":{"href":"https://github.com/uktrade/data-hub-leeloo/pull/1258"},"issue":{"href":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues/1258"},"comments":{"href":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues/1258/comments"},"review_comments":{"href":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/1258/comments"},"review_comment":{"href":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/1258/commits"},"statuses":{"href":"https://api.github.com/repos/uktrade/data-hub-leeloo/statuses/d85ab96d4a0b636a7243ce0be7d12450f3a13893"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"marcuspp"}}