Skip to content

Documentation fixes for document search and project creation #317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions documentcloud/documents/models/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@

logger = logging.getLogger(__name__)

# pylint:disable = too-many-lines


class Document(models.Model):
"""A document uploaded to DocumentCloud"""
Expand Down
22 changes: 20 additions & 2 deletions documentcloud/documents/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,15 @@ def bulk_destroy(self, request, *args, **kwargs):
],
)
def list(self, request, *args, **kwargs):
"""List documents with optional filters. This is not to be confused with search.
This endpoint does not support full text search of the document collection.
For that, you are looking for
[documents_search_across](https://api.www.documentcloud.org/api/schema/redoc/#tag/documents/operation/documents_search_across).
If you are looking for text search within a single document to return text highlights, then
[documents_search_within_single_document](https://api.www.documentcloud.org/api/schema/redoc/#tag/documents/operation/documents_search_within_single_document)
is the correct endpoint. For performance reasons, this endpoint will not return a count of all objects,
only a link to next and previous.
"""
return super().list(request, *args, **kwargs)

@extend_schema(
Expand Down Expand Up @@ -1116,7 +1125,11 @@ def _create_revision(self, document, old_processing, old_revision_control):
@extend_schema(operation_id="documents_search_across")
@action(detail=False, methods=["get"])
def search(self, request):
"""Search across all documents on DocumentCloud"""
"""
Search across all documents on DocumentCloud with full text search using Solr.
Consult our [search documentation](https://www.documentcloud.org/help/search/) for a full parameter list.
This endpoint does return a full count, but does not provide a previous link.
"""
if settings.SOLR_DISABLE_ANON and request.user.is_anonymous:
return Response(
{
Expand Down Expand Up @@ -1157,7 +1170,12 @@ def search(self, request):
@extend_schema(operation_id="documents_search_within_single_document")
@action(detail=True, url_path="search", methods=["get"])
def page_search(self, request, pk=None):
"""Search within a single document"""
"""
Search within a single document using Solr.
This will return up to 25 text highlights
per response page for your query.
Consult our [search documentation](https://www.documentcloud.org/help/search/) for a full parameter list.
"""
if settings.SOLR_DISABLE_ANON and request.user.is_anonymous:
return Response(
{
Expand Down
22 changes: 21 additions & 1 deletion documentcloud/projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,27 @@ def list(self, request, *args, **kwargs):
return super().list(request, *args, **kwargs)

@extend_schema(
request=ProjectSerializer,
request={
"application/json": {
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "Title of the project",
},
"description": {
"type": "string",
"maxLength": 1000,
"description": "Optional description of the project",
},
"private": {
"type": "boolean",
"description": "Whether the project is private",
},
},
"required": ["title"],
}
},
responses={201: ProjectSerializer},
examples=[
OpenApiExample(
Expand Down