{"action":"created","comment":{"url":"https://api.github.com/repos/LandRegistry/digital-register-api/pulls/comments/29436159","id":29436159,"diff_hunk":"@@ -55,26 +56,49 @@ def healthcheck():\n \n \n def get_property_address(postcode):\n-    client = Elasticsearch([ELASTIC_SEARCH_ENDPOINT])\n-    search = Search(\n-        using=client, index='landregistry', doc_type='property_by_postcode_2')\n+    search = create_search('property_by_postcode_2')\n     query = search.filter('term', postcode=postcode)\n     return query.execute().hits\n \n \n+def get_properties_for_address(address):\n+    search = create_search('property_by_address')\n+    address_parts = address.split()\n+    # In the future we might start weighting some words higher than others\n+    # eg \"Street\" be low, if it is a structured address the house number should be high etc\n+    word_queries = [~Q('match', address_string=address_part) for address_part in address_parts]\n+    bool_address_query = Q('bool', should=word_queries)\n+    query = search.query(bool_address_query)\n+    return query.execute().hits","path":"service/server.py","position":32,"original_position":32,"commit_id":"a66d5e8834091dc883f69283575a085e95a9067c","original_commit_id":"d289b42665f20ee04edadb256791aa0ee4cc2813","user":{"login":"camilleldn","id":5455804,"avatar_url":"https://avatars.githubusercontent.com/u/5455804?v=3","gravatar_id":"","url":"https://api.github.com/users/camilleldn","html_url":"https://github.com/camilleldn","followers_url":"https://api.github.com/users/camilleldn/followers","following_url":"https://api.github.com/users/camilleldn/following{/other_user}","gists_url":"https://api.github.com/users/camilleldn/gists{/gist_id}","starred_url":"https://api.github.com/users/camilleldn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/camilleldn/subscriptions","organizations_url":"https://api.github.com/users/camilleldn/orgs","repos_url":"https://api.github.com/users/camilleldn/repos","events_url":"https://api.github.com/users/camilleldn/events{/privacy}","received_events_url":"https://api.github.com/users/camilleldn/received_events","type":"User","site_admin":false},"body":"according to the elasticsearch_dsl documentation, it needs to be done on the search object -> http://elasticsearch-dsl.readthedocs.org/en/latest/search_dsl.html","created_at":"2015-04-30T14:53:25Z","updated_at":"2015-04-30T14:53:25Z","html_url":"https://github.com/LandRegistry/digital-register-api/pull/36#discussion_r29436159","pull_request_url":"https://api.github.com/repos/LandRegistry/digital-register-api/pulls/36","_links":{"self":{"href":"https://api.github.com/repos/LandRegistry/digital-register-api/pulls/comments/29436159"},"html":{"href":"https://github.com/LandRegistry/digital-register-api/pull/36#discussion_r29436159"},"pull_request":{"href":"https://api.github.com/repos/LandRegistry/digital-register-api/pulls/36"}}},"pull_request":{"url":"https://api.github.com/repos/LandRegistry/digital-register-api/pulls/36","id":34256548,"html_url":"https://github.com/LandRegistry/digital-register-api/pull/36","diff_url":"https://github.com/LandRegistry/digital-register-api/pull/36.diff","patch_url":"https://github.com/LandRegistry/digital-register-api/pull/36.patch","issue_url":"https://api.github.com/repos/LandRegistry/digital-register-api/issues/36","number":36,"state":"open","locked":false,"title":"[to be merged with 2 other address-search PRs] Search by address","user":{"login":"camilleldn","id":5455804,"avatar_url":"https://avatars.githubusercontent.com/u/5455804?v=3","gravatar_id":"","url":"https://api.github.com/users/camilleldn","html_url":"https://github.com/camilleldn","followers_url":"https://api.github.com/users/camilleldn/followers","following_url":"https://api.github.com/users/camilleldn/following{/other_user}","gists_url":"https://api.github.com/users/camilleldn/gists{/gist_id}","starred_url":"https://api.github.com/users/camilleldn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/camilleldn/subscriptions","organizations_url":"https://api.github.com/users/camilleldn/orgs","repos_url":"https://api.github.com/users/camilleldn/repos","events_url":"https://api.github.com/users/camilleldn/events{/privacy}","received_events_url":"https://api.github.com/users/camilleldn/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-04-28T11:22:09Z","updated_at":"2015-04-30T14:53:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b6af4431cf988d7ee2768ea42969775947051f20","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/LandRegistry/digital-register-api/pulls/36/commits","review_comments_url":"https://api.github.com/repos/LandRegistry/digital-register-api/pulls/36/comments","review_comment_url":"https://api.github.com/repos/LandRegistry/digital-register-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/LandRegistry/digital-register-api/issues/36/comments","statuses_url":"https://api.github.com/repos/LandRegistry/digital-register-api/statuses/a66d5e8834091dc883f69283575a085e95a9067c","head":{"label":"LandRegistry:search_by_address","ref":"search_by_address","sha":"a66d5e8834091dc883f69283575a085e95a9067c","user":{"login":"LandRegistry","id":6876797,"avatar_url":"https://avatars.githubusercontent.com/u/6876797?v=3","gravatar_id":"","url":"https://api.github.com/users/LandRegistry","html_url":"https://github.com/LandRegistry","followers_url":"https://api.github.com/users/LandRegistry/followers","following_url":"https://api.github.com/users/LandRegistry/following{/other_user}","gists_url":"https://api.github.com/users/LandRegistry/gists{/gist_id}","starred_url":"https://api.github.com/users/LandRegistry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LandRegistry/subscriptions","organizations_url":"https://api.github.com/users/LandRegistry/orgs","repos_url":"https://api.github.com/users/LandRegistry/repos","events_url":"https://api.github.com/users/LandRegistry/events{/privacy}","received_events_url":"https://api.github.com/users/LandRegistry/received_events","type":"Organization","site_admin":false},"repo":{"id":30356567,"name":"digital-register-api","full_name":"LandRegistry/digital-register-api","owner":{"login":"LandRegistry","id":6876797,"avatar_url":"https://avatars.githubusercontent.com/u/6876797?v=3","gravatar_id":"","url":"https://api.github.com/users/LandRegistry","html_url":"https://github.com/LandRegistry","followers_url":"https://api.github.com/users/LandRegistry/followers","following_url":"https://api.github.com/users/LandRegistry/following{/other_user}","gists_url":"https://api.github.com/users/LandRegistry/gists{/gist_id}","starred_url":"https://api.github.com/users/LandRegistry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LandRegistry/subscriptions","organizations_url":"https://api.github.com/users/LandRegistry/orgs","repos_url":"https://api.github.com/users/LandRegistry/repos","events_url":"https://api.github.com/users/LandRegistry/events{/privacy}","received_events_url":"https://api.github.com/users/LandRegistry/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/LandRegistry/digital-register-api","description":"This is repo for the backend API for the digital register page","fork":false,"url":"https://api.github.com/repos/LandRegistry/digital-register-api","forks_url":"https://api.github.com/repos/LandRegistry/digital-register-api/forks","keys_url":"https://api.github.com/repos/LandRegistry/digital-register-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LandRegistry/digital-register-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LandRegistry/digital-register-api/teams","hooks_url":"https://api.github.com/repos/LandRegistry/digital-register-api/hooks","issue_events_url":"https://api.github.com/repos/LandRegistry/digital-register-api/issues/events{/number}","events_url":"https://api.github.com/repos/LandRegistry/digital-register-api/events","assignees_url":"https://api.github.com/repos/LandRegistry/digital-register-api/assignees{/user}","branches_url":"https://api.github.com/repos/LandRegistry/digital-register-api/branches{/branch}","tags_url":"https://api.github.com/repos/LandRegistry/digital-register-api/tags","blobs_url":"https://api.github.com/repos/LandRegistry/digital-register-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LandRegistry/digital-register-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LandRegistry/digital-register-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/LandRegistry/digital-register-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LandRegistry/digital-register-api/statuses/{sha}","languages_url":"https://api.github.com/repos/LandRegistry/digital-register-api/languages","stargazers_url":"https://api.github.com/repos/LandRegistry/digital-register-api/stargazers","contributors_url":"https://api.github.com/repos/LandRegistry/digital-register-api/contributors","subscribers_url":"https://api.github.com/repos/LandRegistry/digital-register-api/subscribers","subscription_url":"https://api.github.com/repos/LandRegistry/digital-register-api/subscription","commits_url":"https://api.github.com/repos/LandRegistry/digital-register-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/LandRegistry/digital-register-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/LandRegistry/digital-register-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/LandRegistry/digital-register-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/LandRegistry/digital-register-api/contents/{+path}","compare_url":"https://api.github.com/repos/LandRegistry/digital-register-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LandRegistry/digital-register-api/merges","archive_url":"https://api.github.com/repos/LandRegistry/digital-register-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LandRegistry/digital-register-api/downloads","issues_url":"https://api.github.com/repos/LandRegistry/digital-register-api/issues{/number}","pulls_url":"https://api.github.com/repos/LandRegistry/digital-register-api/pulls{/number}","milestones_url":"https://api.github.com/repos/LandRegistry/digital-register-api/milestones{/number}","notifications_url":"https://api.github.com/repos/LandRegistry/digital-register-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LandRegistry/digital-register-api/labels{/name}","releases_url":"https://api.github.com/repos/LandRegistry/digital-register-api/releases{/id}","created_at":"2015-02-05T13:24:31Z","updated_at":"2015-04-30T14:00:02Z","pushed_at":"2015-04-30T14:52:16Z","git_url":"git://github.com/LandRegistry/digital-register-api.git","ssh_url":"git@github.com:LandRegistry/digital-register-api.git","clone_url":"https://github.com/LandRegistry/digital-register-api.git","svn_url":"https://github.com/LandRegistry/digital-register-api","homepage":null,"size":1192,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"LandRegistry:master","ref":"master","sha":"67b4909e553340464c70db5301eb529344b4e027","user":{"login":"LandRegistry","id":6876797,"avatar_url":"https://avatars.githubusercontent.com/u/6876797?v=3","gravatar_id":"","url":"https://api.github.com/users/LandRegistry","html_url":"https://github.com/LandRegistry","followers_url":"https://api.github.com/users/LandRegistry/followers","following_url":"https://api.github.com/users/LandRegistry/following{/other_user}","gists_url":"https://api.github.com/users/LandRegistry/gists{/gist_id}","starred_url":"https://api.github.com/users/LandRegistry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LandRegistry/subscriptions","organizations_url":"https://api.github.com/users/LandRegistry/orgs","repos_url":"https://api.github.com/users/LandRegistry/repos","events_url":"https://api.github.com/users/LandRegistry/events{/privacy}","received_events_url":"https://api.github.com/users/LandRegistry/received_events","type":"Organization","site_admin":false},"repo":{"id":30356567,"name":"digital-register-api","full_name":"LandRegistry/digital-register-api","owner":{"login":"LandRegistry","id":6876797,"avatar_url":"https://avatars.githubusercontent.com/u/6876797?v=3","gravatar_id":"","url":"https://api.github.com/users/LandRegistry","html_url":"https://github.com/LandRegistry","followers_url":"https://api.github.com/users/LandRegistry/followers","following_url":"https://api.github.com/users/LandRegistry/following{/other_user}","gists_url":"https://api.github.com/users/LandRegistry/gists{/gist_id}","starred_url":"https://api.github.com/users/LandRegistry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LandRegistry/subscriptions","organizations_url":"https://api.github.com/users/LandRegistry/orgs","repos_url":"https://api.github.com/users/LandRegistry/repos","events_url":"https://api.github.com/users/LandRegistry/events{/privacy}","received_events_url":"https://api.github.com/users/LandRegistry/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/LandRegistry/digital-register-api","description":"This is repo for the backend API for the digital register page","fork":false,"url":"https://api.github.com/repos/LandRegistry/digital-register-api","forks_url":"https://api.github.com/repos/LandRegistry/digital-register-api/forks","keys_url":"https://api.github.com/repos/LandRegistry/digital-register-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LandRegistry/digital-register-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LandRegistry/digital-register-api/teams","hooks_url":"https://api.github.com/repos/LandRegistry/digital-register-api/hooks","issue_events_url":"https://api.github.com/repos/LandRegistry/digital-register-api/issues/events{/number}","events_url":"https://api.github.com/repos/LandRegistry/digital-register-api/events","assignees_url":"https://api.github.com/repos/LandRegistry/digital-register-api/assignees{/user}","branches_url":"https://api.github.com/repos/LandRegistry/digital-register-api/branches{/branch}","tags_url":"https://api.github.com/repos/LandRegistry/digital-register-api/tags","blobs_url":"https://api.github.com/repos/LandRegistry/digital-register-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LandRegistry/digital-register-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LandRegistry/digital-register-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/LandRegistry/digital-register-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LandRegistry/digital-register-api/statuses/{sha}","languages_url":"https://api.github.com/repos/LandRegistry/digital-register-api/languages","stargazers_url":"https://api.github.com/repos/LandRegistry/digital-register-api/stargazers","contributors_url":"https://api.github.com/repos/LandRegistry/digital-register-api/contributors","subscribers_url":"https://api.github.com/repos/LandRegistry/digital-register-api/subscribers","subscription_url":"https://api.github.com/repos/LandRegistry/digital-register-api/subscription","commits_url":"https://api.github.com/repos/LandRegistry/digital-register-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/LandRegistry/digital-register-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/LandRegistry/digital-register-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/LandRegistry/digital-register-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/LandRegistry/digital-register-api/contents/{+path}","compare_url":"https://api.github.com/repos/LandRegistry/digital-register-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LandRegistry/digital-register-api/merges","archive_url":"https://api.github.com/repos/LandRegistry/digital-register-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LandRegistry/digital-register-api/downloads","issues_url":"https://api.github.com/repos/LandRegistry/digital-register-api/issues{/number}","pulls_url":"https://api.github.com/repos/LandRegistry/digital-register-api/pulls{/number}","milestones_url":"https://api.github.com/repos/LandRegistry/digital-register-api/milestones{/number}","notifications_url":"https://api.github.com/repos/LandRegistry/digital-register-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LandRegistry/digital-register-api/labels{/name}","releases_url":"https://api.github.com/repos/LandRegistry/digital-register-api/releases{/id}","created_at":"2015-02-05T13:24:31Z","updated_at":"2015-04-30T14:00:02Z","pushed_at":"2015-04-30T14:52:16Z","git_url":"git://github.com/LandRegistry/digital-register-api.git","ssh_url":"git@github.com:LandRegistry/digital-register-api.git","clone_url":"https://github.com/LandRegistry/digital-register-api.git","svn_url":"https://github.com/LandRegistry/digital-register-api","homepage":null,"size":1192,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/LandRegistry/digital-register-api/pulls/36"},"html":{"href":"https://github.com/LandRegistry/digital-register-api/pull/36"},"issue":{"href":"https://api.github.com/repos/LandRegistry/digital-register-api/issues/36"},"comments":{"href":"https://api.github.com/repos/LandRegistry/digital-register-api/issues/36/comments"},"review_comments":{"href":"https://api.github.com/repos/LandRegistry/digital-register-api/pulls/36/comments"},"review_comment":{"href":"https://api.github.com/repos/LandRegistry/digital-register-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/LandRegistry/digital-register-api/pulls/36/commits"},"statuses":{"href":"https://api.github.com/repos/LandRegistry/digital-register-api/statuses/a66d5e8834091dc883f69283575a085e95a9067c"}}}}