{"action":"created","comment":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/79060301","id":79060301,"diff_hunk":"@@ -0,0 +1,583 @@\n+from modularodm import Q\n+from nose.tools import *  # flake8: noqa\n+\n+from api.base.settings.defaults import API_BASE\n+from api_tests.utils import create_test_file\n+\n+from framework.auth.core import Auth\n+from framework.mongo import database as database_proxy\n+\n+from tests.base import ApiTestCase, teardown_database\n+from tests.factories import (\n+    AuthUserFactory,\n+    NodeFactory,\n+    ProjectFactory,\n+)\n+from tests.utils import mock_archive\n+\n+from website.models import MetaSchema\n+from website.project.model import ensure_schemas\n+from website.project.metadata.schemas import LATEST_SCHEMA_VERSION\n+from website.search import search\n+\n+\n+class ApiSearchTestCase(ApiTestCase):\n+\n+    def setUp(self):\n+        super(ApiSearchTestCase, self).setUp()\n+\n+        # actually tear down the database and delete elastic indices for each test\n+        teardown_database(database=database_proxy._get_current_object())","path":"api_tests/search/views/test_views.py","position":30,"original_position":30,"commit_id":"232d845523cec739c857c6090370feab4e5b5bf8","original_commit_id":"232d845523cec739c857c6090370feab4e5b5bf8","user":{"login":"caseyrollins","id":7913604,"avatar_url":"https://avatars.githubusercontent.com/u/7913604?v=3","gravatar_id":"","url":"https://api.github.com/users/caseyrollins","html_url":"https://github.com/caseyrollins","followers_url":"https://api.github.com/users/caseyrollins/followers","following_url":"https://api.github.com/users/caseyrollins/following{/other_user}","gists_url":"https://api.github.com/users/caseyrollins/gists{/gist_id}","starred_url":"https://api.github.com/users/caseyrollins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caseyrollins/subscriptions","organizations_url":"https://api.github.com/users/caseyrollins/orgs","repos_url":"https://api.github.com/users/caseyrollins/repos","events_url":"https://api.github.com/users/caseyrollins/events{/privacy}","received_events_url":"https://api.github.com/users/caseyrollins/received_events","type":"User","site_admin":false},"body":"Actually, this is no longer necessary since I'm not creating users with specific usernames. And since I'm clearing out the ES index for each test, it doesn't matter that the database isn't being torn down. ","created_at":"2016-09-15T20:58:39Z","updated_at":"2016-09-15T20:58:39Z","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/6294#discussion_r79060301","pull_request_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/6294","_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/79060301"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/6294#discussion_r79060301"},"pull_request":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/6294"}}},"pull_request":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/6294","id":84504450,"html_url":"https://github.com/CenterForOpenScience/osf.io/pull/6294","diff_url":"https://github.com/CenterForOpenScience/osf.io/pull/6294.diff","patch_url":"https://github.com/CenterForOpenScience/osf.io/pull/6294.patch","issue_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/6294","number":6294,"state":"open","locked":false,"title":"[feature] API Search [OSF-4254]","user":{"login":"caseyrollins","id":7913604,"avatar_url":"https://avatars.githubusercontent.com/u/7913604?v=3","gravatar_id":"","url":"https://api.github.com/users/caseyrollins","html_url":"https://github.com/caseyrollins","followers_url":"https://api.github.com/users/caseyrollins/followers","following_url":"https://api.github.com/users/caseyrollins/following{/other_user}","gists_url":"https://api.github.com/users/caseyrollins/gists{/gist_id}","starred_url":"https://api.github.com/users/caseyrollins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caseyrollins/subscriptions","organizations_url":"https://api.github.com/users/caseyrollins/orgs","repos_url":"https://api.github.com/users/caseyrollins/repos","events_url":"https://api.github.com/users/caseyrollins/events{/privacy}","received_events_url":"https://api.github.com/users/caseyrollins/received_events","type":"User","site_admin":false},"body":"#### Purpose\r\n- Adds several search endpoints to API v2. Each endpoint can accept a search query via query parameters, e.g. `/v2/search/projects/?q=science` will search for projects with the word science in their title, description, tags, etc. \r\n - `/v2/search/`\r\n    - searches across files, projects, components, registrations, and users.\r\n    - all of the items returned from this search should be serialized appropriately in a single response (users serialized as users, registrations serialized as registrations, etc.)\r\n    - Additionally, this endpoint includes a `search_fields` dictionary in the response which contains the appropriate links and counts of results for each doc type. \r\n - `/v2/search/files/`\r\n   - searches across components -- query parameters will search within a file's name. \r\n - `/v2/search/projects/`\r\n   - searches across public projects -- query parameters will search within a project's title, description, tags, and contributor names. \r\n - `/v2/search/components/`\r\n   - searches across public components -- query parameters will search within a component's title, description, tags, and contributor names. \r\n - `/v2/search/registrations/`\r\n   - searches across public registrations -- query parameters will search within a registration's title, description, tags, and contributor names. \r\n - `/v2/search/users/`\r\n   - searches across public registrations -- query parameters will search within a user's given name, middle names, family name, jobs, and schools. \r\n\r\n#### Changes\r\n- views for each search type.\r\n- `SearchSerializer` to appropriately serialize the mixed models that are returned from the `/v2/search/` endpoint. \r\n- `SearchModelPaginator`, `SearchPaginator`, and `SearchPagination` classes to appropriately load the search results and paginate the endpoints since ES only returns 10 results at a time. \r\n\r\n#### Side Effects\r\n- None expected -- this PR contains additional endpoints for API v2 search, but does not alter existing ES functionality. \r\n\r\n#### Ticket\r\n- [OSF-4254](https://openscience.atlassian.net/browse/OSF-4254)\r\n","created_at":"2016-09-08T15:52:15Z","updated_at":"2016-09-15T20:58:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"76df998fe80c16997aa50a103523982ac331d100","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/6294/commits","review_comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/6294/comments","review_comment_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/6294/comments","statuses_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/232d845523cec739c857c6090370feab4e5b5bf8","head":{"label":"caseyrollins:feature/api-search","ref":"feature/api-search","sha":"232d845523cec739c857c6090370feab4e5b5bf8","user":{"login":"caseyrollins","id":7913604,"avatar_url":"https://avatars.githubusercontent.com/u/7913604?v=3","gravatar_id":"","url":"https://api.github.com/users/caseyrollins","html_url":"https://github.com/caseyrollins","followers_url":"https://api.github.com/users/caseyrollins/followers","following_url":"https://api.github.com/users/caseyrollins/following{/other_user}","gists_url":"https://api.github.com/users/caseyrollins/gists{/gist_id}","starred_url":"https://api.github.com/users/caseyrollins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caseyrollins/subscriptions","organizations_url":"https://api.github.com/users/caseyrollins/orgs","repos_url":"https://api.github.com/users/caseyrollins/repos","events_url":"https://api.github.com/users/caseyrollins/events{/privacy}","received_events_url":"https://api.github.com/users/caseyrollins/received_events","type":"User","site_admin":false},"repo":{"id":26963858,"name":"osf.io","full_name":"caseyrollins/osf.io","owner":{"login":"caseyrollins","id":7913604,"avatar_url":"https://avatars.githubusercontent.com/u/7913604?v=3","gravatar_id":"","url":"https://api.github.com/users/caseyrollins","html_url":"https://github.com/caseyrollins","followers_url":"https://api.github.com/users/caseyrollins/followers","following_url":"https://api.github.com/users/caseyrollins/following{/other_user}","gists_url":"https://api.github.com/users/caseyrollins/gists{/gist_id}","starred_url":"https://api.github.com/users/caseyrollins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caseyrollins/subscriptions","organizations_url":"https://api.github.com/users/caseyrollins/orgs","repos_url":"https://api.github.com/users/caseyrollins/repos","events_url":"https://api.github.com/users/caseyrollins/events{/privacy}","received_events_url":"https://api.github.com/users/caseyrollins/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/caseyrollins/osf.io","description":"Facilitating Open Science","fork":true,"url":"https://api.github.com/repos/caseyrollins/osf.io","forks_url":"https://api.github.com/repos/caseyrollins/osf.io/forks","keys_url":"https://api.github.com/repos/caseyrollins/osf.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/caseyrollins/osf.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/caseyrollins/osf.io/teams","hooks_url":"https://api.github.com/repos/caseyrollins/osf.io/hooks","issue_events_url":"https://api.github.com/repos/caseyrollins/osf.io/issues/events{/number}","events_url":"https://api.github.com/repos/caseyrollins/osf.io/events","assignees_url":"https://api.github.com/repos/caseyrollins/osf.io/assignees{/user}","branches_url":"https://api.github.com/repos/caseyrollins/osf.io/branches{/branch}","tags_url":"https://api.github.com/repos/caseyrollins/osf.io/tags","blobs_url":"https://api.github.com/repos/caseyrollins/osf.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/caseyrollins/osf.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/caseyrollins/osf.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/caseyrollins/osf.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/caseyrollins/osf.io/statuses/{sha}","languages_url":"https://api.github.com/repos/caseyrollins/osf.io/languages","stargazers_url":"https://api.github.com/repos/caseyrollins/osf.io/stargazers","contributors_url":"https://api.github.com/repos/caseyrollins/osf.io/contributors","subscribers_url":"https://api.github.com/repos/caseyrollins/osf.io/subscribers","subscription_url":"https://api.github.com/repos/caseyrollins/osf.io/subscription","commits_url":"https://api.github.com/repos/caseyrollins/osf.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/caseyrollins/osf.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/caseyrollins/osf.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/caseyrollins/osf.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/caseyrollins/osf.io/contents/{+path}","compare_url":"https://api.github.com/repos/caseyrollins/osf.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/caseyrollins/osf.io/merges","archive_url":"https://api.github.com/repos/caseyrollins/osf.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/caseyrollins/osf.io/downloads","issues_url":"https://api.github.com/repos/caseyrollins/osf.io/issues{/number}","pulls_url":"https://api.github.com/repos/caseyrollins/osf.io/pulls{/number}","milestones_url":"https://api.github.com/repos/caseyrollins/osf.io/milestones{/number}","notifications_url":"https://api.github.com/repos/caseyrollins/osf.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/caseyrollins/osf.io/labels{/name}","releases_url":"https://api.github.com/repos/caseyrollins/osf.io/releases{/id}","deployments_url":"https://api.github.com/repos/caseyrollins/osf.io/deployments","created_at":"2014-11-21T14:49:09Z","updated_at":"2016-01-20T14:34:47Z","pushed_at":"2016-09-15T20:01:39Z","git_url":"git://github.com/caseyrollins/osf.io.git","ssh_url":"git@github.com:caseyrollins/osf.io.git","clone_url":"https://github.com/caseyrollins/osf.io.git","svn_url":"https://github.com/caseyrollins/osf.io","homepage":"http://osf.io","size":134771,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"CenterForOpenScience:develop","ref":"develop","sha":"e74f86ce8d071aa0c47cbcdec1a1b403b12cab7c","user":{"login":"CenterForOpenScience","id":3344584,"avatar_url":"https://avatars.githubusercontent.com/u/3344584?v=3","gravatar_id":"","url":"https://api.github.com/users/CenterForOpenScience","html_url":"https://github.com/CenterForOpenScience","followers_url":"https://api.github.com/users/CenterForOpenScience/followers","following_url":"https://api.github.com/users/CenterForOpenScience/following{/other_user}","gists_url":"https://api.github.com/users/CenterForOpenScience/gists{/gist_id}","starred_url":"https://api.github.com/users/CenterForOpenScience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CenterForOpenScience/subscriptions","organizations_url":"https://api.github.com/users/CenterForOpenScience/orgs","repos_url":"https://api.github.com/users/CenterForOpenScience/repos","events_url":"https://api.github.com/users/CenterForOpenScience/events{/privacy}","received_events_url":"https://api.github.com/users/CenterForOpenScience/received_events","type":"Organization","site_admin":false},"repo":{"id":10199599,"name":"osf.io","full_name":"CenterForOpenScience/osf.io","owner":{"login":"CenterForOpenScience","id":3344584,"avatar_url":"https://avatars.githubusercontent.com/u/3344584?v=3","gravatar_id":"","url":"https://api.github.com/users/CenterForOpenScience","html_url":"https://github.com/CenterForOpenScience","followers_url":"https://api.github.com/users/CenterForOpenScience/followers","following_url":"https://api.github.com/users/CenterForOpenScience/following{/other_user}","gists_url":"https://api.github.com/users/CenterForOpenScience/gists{/gist_id}","starred_url":"https://api.github.com/users/CenterForOpenScience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CenterForOpenScience/subscriptions","organizations_url":"https://api.github.com/users/CenterForOpenScience/orgs","repos_url":"https://api.github.com/users/CenterForOpenScience/repos","events_url":"https://api.github.com/users/CenterForOpenScience/events{/privacy}","received_events_url":"https://api.github.com/users/CenterForOpenScience/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CenterForOpenScience/osf.io","description":"Facilitating Open Science","fork":false,"url":"https://api.github.com/repos/CenterForOpenScience/osf.io","forks_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/forks","keys_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/teams","hooks_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/hooks","issue_events_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/events{/number}","events_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/events","assignees_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/assignees{/user}","branches_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/branches{/branch}","tags_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/tags","blobs_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/{sha}","languages_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/languages","stargazers_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/stargazers","contributors_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/contributors","subscribers_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/subscribers","subscription_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/subscription","commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/contents/{+path}","compare_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/merges","archive_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/downloads","issues_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues{/number}","pulls_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls{/number}","milestones_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/milestones{/number}","notifications_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/labels{/name}","releases_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/releases{/id}","deployments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/deployments","created_at":"2013-05-21T15:53:37Z","updated_at":"2016-09-15T01:42:25Z","pushed_at":"2016-09-15T20:01:40Z","git_url":"git://github.com/CenterForOpenScience/osf.io.git","ssh_url":"git@github.com:CenterForOpenScience/osf.io.git","clone_url":"https://github.com/CenterForOpenScience/osf.io.git","svn_url":"https://github.com/CenterForOpenScience/osf.io","homepage":"http://osf.io","size":268740,"stargazers_count":260,"watchers_count":260,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":202,"mirror_url":null,"open_issues_count":211,"forks":202,"open_issues":211,"watchers":260,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/6294"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/6294"},"issue":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/6294"},"comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/6294/comments"},"review_comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/6294/comments"},"review_comment":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/6294/commits"},"statuses":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/232d845523cec739c857c6090370feab4e5b5bf8"}}}}
{"actor":{"display_login":"caseyrollins"}}