{"action":"created","comment":{"url":"https://api.github.com/repos/censusreporter/census-api/pulls/comments/73897170","id":73897170,"diff_hunk":"@@ -2009,6 +2021,303 @@ def table_geo_comparison_rowcount(table_id):\n \n     return resp\n \n+## COMBINED LOOKUPS ##\n+\n+@app.route(\"/2.1/full-text/search\")\n+@qwarg_validate({\n+    'q':   {'valid': NonemptyString()},\n+    'type': {'valid': OneOf(allowed_searches), 'default': allowed_searches[3]},\n+})\n+@crossdomain(origin='*')\n+def full_text_search():\n+\n+    def do_search(db, q, object_type):\n+        \"\"\" Search for objects (profiles, tables, topics) matching query q.\n+\n+        Return a list, because it's easier to work with than a SQLAlchemy \n+        ResultProxy object (notably, the latter does not support indexing).\n+        \"\"\"\n+\n+        q_profiles = \"\"\"SELECT text1 AS display_name, \n+                               text2 AS sumlevel,\n+                               text3 AS sumlevel_name,\n+                               text4 AS full_geoid,\n+                               text5 AS population, \n+                               text6 AS priority,\n+                               ts_rank(document, to_tsquery('simple', '{0}')) AS relevance,","path":"census_extractomatic/api.py","position":102,"original_position":102,"commit_id":"a3c42fbb9b182ea6678322a42dbf8985b2f4f25c","original_commit_id":"a3c42fbb9b182ea6678322a42dbf8985b2f4f25c","user":{"login":"iandees","id":261584,"avatar_url":"https://avatars.githubusercontent.com/u/261584?v=3","gravatar_id":"","url":"https://api.github.com/users/iandees","html_url":"https://github.com/iandees","followers_url":"https://api.github.com/users/iandees/followers","following_url":"https://api.github.com/users/iandees/following{/other_user}","gists_url":"https://api.github.com/users/iandees/gists{/gist_id}","starred_url":"https://api.github.com/users/iandees/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iandees/subscriptions","organizations_url":"https://api.github.com/users/iandees/orgs","repos_url":"https://api.github.com/users/iandees/repos","events_url":"https://api.github.com/users/iandees/events{/privacy}","received_events_url":"https://api.github.com/users/iandees/received_events","type":"User","site_admin":false},"body":"Rather than use Python's string formatting here, let's use the built-in string replacement stuff that SQLAlchemy has. [This is a fairly good article describing in more detail what I'm talking about](https://www.quantifiedcode.com/knowledge-base/security/Prevent%20SQL%20injections%20by%20avoiding%20string%20interpolations/3cObiWuF).","created_at":"2016-08-08T15:33:20Z","updated_at":"2016-08-08T15:33:20Z","html_url":"https://github.com/censusreporter/census-api/pull/46#discussion_r73897170","pull_request_url":"https://api.github.com/repos/censusreporter/census-api/pulls/46","_links":{"self":{"href":"https://api.github.com/repos/censusreporter/census-api/pulls/comments/73897170"},"html":{"href":"https://github.com/censusreporter/census-api/pull/46#discussion_r73897170"},"pull_request":{"href":"https://api.github.com/repos/censusreporter/census-api/pulls/46"}}},"pull_request":{"url":"https://api.github.com/repos/censusreporter/census-api/pulls/46","id":75542257,"html_url":"https://github.com/censusreporter/census-api/pull/46","diff_url":"https://github.com/censusreporter/census-api/pull/46.diff","patch_url":"https://github.com/censusreporter/census-api/pull/46.patch","issue_url":"https://api.github.com/repos/censusreporter/census-api/issues/46","number":46,"state":"open","locked":false,"title":"Full text search","user":{"login":"Joonpark13","id":7915735,"avatar_url":"https://avatars.githubusercontent.com/u/7915735?v=3","gravatar_id":"","url":"https://api.github.com/users/Joonpark13","html_url":"https://github.com/Joonpark13","followers_url":"https://api.github.com/users/Joonpark13/followers","following_url":"https://api.github.com/users/Joonpark13/following{/other_user}","gists_url":"https://api.github.com/users/Joonpark13/gists{/gist_id}","starred_url":"https://api.github.com/users/Joonpark13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Joonpark13/subscriptions","organizations_url":"https://api.github.com/users/Joonpark13/orgs","repos_url":"https://api.github.com/users/Joonpark13/repos","events_url":"https://api.github.com/users/Joonpark13/events{/privacy}","received_events_url":"https://api.github.com/users/Joonpark13/received_events","type":"User","site_admin":false},"body":"The API has been updated to support full text search. The most notable change is the addition of a new function in `census_extractomatic/api.py` called `full_text_search()`, which contains all of the functionality needed to perform such a search. The API is a superset of the original result format, staying faithful for existing fields and adding some new information.\r\n\r\nIt is necessary to build a search table before using the API; instructions to do so are written in `setup.md`, with further detail provided in `full-text-guide.md`. A Python script (`query_script.py`) is included for local testing of the search.\r\n\r\nAddresses #43 ","created_at":"2016-06-28T20:12:33Z","updated_at":"2016-08-08T15:33:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6404b03b2a2515d3f1efca9e75e5cead1497ae8d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/censusreporter/census-api/pulls/46/commits","review_comments_url":"https://api.github.com/repos/censusreporter/census-api/pulls/46/comments","review_comment_url":"https://api.github.com/repos/censusreporter/census-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/censusreporter/census-api/issues/46/comments","statuses_url":"https://api.github.com/repos/censusreporter/census-api/statuses/a3c42fbb9b182ea6678322a42dbf8985b2f4f25c","head":{"label":"censusreporter:full-text-search","ref":"full-text-search","sha":"a3c42fbb9b182ea6678322a42dbf8985b2f4f25c","user":{"login":"censusreporter","id":3924386,"avatar_url":"https://avatars.githubusercontent.com/u/3924386?v=3","gravatar_id":"","url":"https://api.github.com/users/censusreporter","html_url":"https://github.com/censusreporter","followers_url":"https://api.github.com/users/censusreporter/followers","following_url":"https://api.github.com/users/censusreporter/following{/other_user}","gists_url":"https://api.github.com/users/censusreporter/gists{/gist_id}","starred_url":"https://api.github.com/users/censusreporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/censusreporter/subscriptions","organizations_url":"https://api.github.com/users/censusreporter/orgs","repos_url":"https://api.github.com/users/censusreporter/repos","events_url":"https://api.github.com/users/censusreporter/events{/privacy}","received_events_url":"https://api.github.com/users/censusreporter/received_events","type":"Organization","site_admin":false},"repo":{"id":9879953,"name":"census-api","full_name":"censusreporter/census-api","owner":{"login":"censusreporter","id":3924386,"avatar_url":"https://avatars.githubusercontent.com/u/3924386?v=3","gravatar_id":"","url":"https://api.github.com/users/censusreporter","html_url":"https://github.com/censusreporter","followers_url":"https://api.github.com/users/censusreporter/followers","following_url":"https://api.github.com/users/censusreporter/following{/other_user}","gists_url":"https://api.github.com/users/censusreporter/gists{/gist_id}","starred_url":"https://api.github.com/users/censusreporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/censusreporter/subscriptions","organizations_url":"https://api.github.com/users/censusreporter/orgs","repos_url":"https://api.github.com/users/censusreporter/repos","events_url":"https://api.github.com/users/censusreporter/events{/privacy}","received_events_url":"https://api.github.com/users/censusreporter/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/censusreporter/census-api","description":"The home for the API that powers the Census Reporter project.","fork":false,"url":"https://api.github.com/repos/censusreporter/census-api","forks_url":"https://api.github.com/repos/censusreporter/census-api/forks","keys_url":"https://api.github.com/repos/censusreporter/census-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/censusreporter/census-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/censusreporter/census-api/teams","hooks_url":"https://api.github.com/repos/censusreporter/census-api/hooks","issue_events_url":"https://api.github.com/repos/censusreporter/census-api/issues/events{/number}","events_url":"https://api.github.com/repos/censusreporter/census-api/events","assignees_url":"https://api.github.com/repos/censusreporter/census-api/assignees{/user}","branches_url":"https://api.github.com/repos/censusreporter/census-api/branches{/branch}","tags_url":"https://api.github.com/repos/censusreporter/census-api/tags","blobs_url":"https://api.github.com/repos/censusreporter/census-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/censusreporter/census-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/censusreporter/census-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/censusreporter/census-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/censusreporter/census-api/statuses/{sha}","languages_url":"https://api.github.com/repos/censusreporter/census-api/languages","stargazers_url":"https://api.github.com/repos/censusreporter/census-api/stargazers","contributors_url":"https://api.github.com/repos/censusreporter/census-api/contributors","subscribers_url":"https://api.github.com/repos/censusreporter/census-api/subscribers","subscription_url":"https://api.github.com/repos/censusreporter/census-api/subscription","commits_url":"https://api.github.com/repos/censusreporter/census-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/censusreporter/census-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/censusreporter/census-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/censusreporter/census-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/censusreporter/census-api/contents/{+path}","compare_url":"https://api.github.com/repos/censusreporter/census-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/censusreporter/census-api/merges","archive_url":"https://api.github.com/repos/censusreporter/census-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/censusreporter/census-api/downloads","issues_url":"https://api.github.com/repos/censusreporter/census-api/issues{/number}","pulls_url":"https://api.github.com/repos/censusreporter/census-api/pulls{/number}","milestones_url":"https://api.github.com/repos/censusreporter/census-api/milestones{/number}","notifications_url":"https://api.github.com/repos/censusreporter/census-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/censusreporter/census-api/labels{/name}","releases_url":"https://api.github.com/repos/censusreporter/census-api/releases{/id}","deployments_url":"https://api.github.com/repos/censusreporter/census-api/deployments","created_at":"2013-05-06T05:24:57Z","updated_at":"2016-07-30T17:58:59Z","pushed_at":"2016-08-08T15:18:43Z","git_url":"git://github.com/censusreporter/census-api.git","ssh_url":"git@github.com:censusreporter/census-api.git","clone_url":"https://github.com/censusreporter/census-api.git","svn_url":"https://github.com/censusreporter/census-api","homepage":"","size":3990,"stargazers_count":61,"watchers_count":61,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":14,"forks":16,"open_issues":14,"watchers":61,"default_branch":"master"}},"base":{"label":"censusreporter:master","ref":"master","sha":"898a0919618c3cf4f29a66392af7e98a0691246b","user":{"login":"censusreporter","id":3924386,"avatar_url":"https://avatars.githubusercontent.com/u/3924386?v=3","gravatar_id":"","url":"https://api.github.com/users/censusreporter","html_url":"https://github.com/censusreporter","followers_url":"https://api.github.com/users/censusreporter/followers","following_url":"https://api.github.com/users/censusreporter/following{/other_user}","gists_url":"https://api.github.com/users/censusreporter/gists{/gist_id}","starred_url":"https://api.github.com/users/censusreporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/censusreporter/subscriptions","organizations_url":"https://api.github.com/users/censusreporter/orgs","repos_url":"https://api.github.com/users/censusreporter/repos","events_url":"https://api.github.com/users/censusreporter/events{/privacy}","received_events_url":"https://api.github.com/users/censusreporter/received_events","type":"Organization","site_admin":false},"repo":{"id":9879953,"name":"census-api","full_name":"censusreporter/census-api","owner":{"login":"censusreporter","id":3924386,"avatar_url":"https://avatars.githubusercontent.com/u/3924386?v=3","gravatar_id":"","url":"https://api.github.com/users/censusreporter","html_url":"https://github.com/censusreporter","followers_url":"https://api.github.com/users/censusreporter/followers","following_url":"https://api.github.com/users/censusreporter/following{/other_user}","gists_url":"https://api.github.com/users/censusreporter/gists{/gist_id}","starred_url":"https://api.github.com/users/censusreporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/censusreporter/subscriptions","organizations_url":"https://api.github.com/users/censusreporter/orgs","repos_url":"https://api.github.com/users/censusreporter/repos","events_url":"https://api.github.com/users/censusreporter/events{/privacy}","received_events_url":"https://api.github.com/users/censusreporter/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/censusreporter/census-api","description":"The home for the API that powers the Census Reporter project.","fork":false,"url":"https://api.github.com/repos/censusreporter/census-api","forks_url":"https://api.github.com/repos/censusreporter/census-api/forks","keys_url":"https://api.github.com/repos/censusreporter/census-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/censusreporter/census-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/censusreporter/census-api/teams","hooks_url":"https://api.github.com/repos/censusreporter/census-api/hooks","issue_events_url":"https://api.github.com/repos/censusreporter/census-api/issues/events{/number}","events_url":"https://api.github.com/repos/censusreporter/census-api/events","assignees_url":"https://api.github.com/repos/censusreporter/census-api/assignees{/user}","branches_url":"https://api.github.com/repos/censusreporter/census-api/branches{/branch}","tags_url":"https://api.github.com/repos/censusreporter/census-api/tags","blobs_url":"https://api.github.com/repos/censusreporter/census-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/censusreporter/census-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/censusreporter/census-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/censusreporter/census-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/censusreporter/census-api/statuses/{sha}","languages_url":"https://api.github.com/repos/censusreporter/census-api/languages","stargazers_url":"https://api.github.com/repos/censusreporter/census-api/stargazers","contributors_url":"https://api.github.com/repos/censusreporter/census-api/contributors","subscribers_url":"https://api.github.com/repos/censusreporter/census-api/subscribers","subscription_url":"https://api.github.com/repos/censusreporter/census-api/subscription","commits_url":"https://api.github.com/repos/censusreporter/census-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/censusreporter/census-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/censusreporter/census-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/censusreporter/census-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/censusreporter/census-api/contents/{+path}","compare_url":"https://api.github.com/repos/censusreporter/census-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/censusreporter/census-api/merges","archive_url":"https://api.github.com/repos/censusreporter/census-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/censusreporter/census-api/downloads","issues_url":"https://api.github.com/repos/censusreporter/census-api/issues{/number}","pulls_url":"https://api.github.com/repos/censusreporter/census-api/pulls{/number}","milestones_url":"https://api.github.com/repos/censusreporter/census-api/milestones{/number}","notifications_url":"https://api.github.com/repos/censusreporter/census-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/censusreporter/census-api/labels{/name}","releases_url":"https://api.github.com/repos/censusreporter/census-api/releases{/id}","deployments_url":"https://api.github.com/repos/censusreporter/census-api/deployments","created_at":"2013-05-06T05:24:57Z","updated_at":"2016-07-30T17:58:59Z","pushed_at":"2016-08-08T15:18:43Z","git_url":"git://github.com/censusreporter/census-api.git","ssh_url":"git@github.com:censusreporter/census-api.git","clone_url":"https://github.com/censusreporter/census-api.git","svn_url":"https://github.com/censusreporter/census-api","homepage":"","size":3990,"stargazers_count":61,"watchers_count":61,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":14,"forks":16,"open_issues":14,"watchers":61,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/censusreporter/census-api/pulls/46"},"html":{"href":"https://github.com/censusreporter/census-api/pull/46"},"issue":{"href":"https://api.github.com/repos/censusreporter/census-api/issues/46"},"comments":{"href":"https://api.github.com/repos/censusreporter/census-api/issues/46/comments"},"review_comments":{"href":"https://api.github.com/repos/censusreporter/census-api/pulls/46/comments"},"review_comment":{"href":"https://api.github.com/repos/censusreporter/census-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/censusreporter/census-api/pulls/46/commits"},"statuses":{"href":"https://api.github.com/repos/censusreporter/census-api/statuses/a3c42fbb9b182ea6678322a42dbf8985b2f4f25c"}}}}
{"actor":{"display_login":"iandees"}}