-
Notifications
You must be signed in to change notification settings - Fork 98
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
Adding free-text extension. #655
Draft
rhysrevans3
wants to merge
4
commits into
stac-utils:main
Choose a base branch
from
rhysrevans3:freetext-search-ext
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
stac_fastapi/extensions/stac_fastapi/extensions/third_party/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
"""stac_api.extensions.third_party module.""" | ||
|
||
from .bulk_transactions import BulkTransactionExtension | ||
from .free_text import FreeTextExtension | ||
|
||
__all__ = ("BulkTransactionExtension",) | ||
__all__ = ( | ||
"BulkTransactionExtension", | ||
"FreeTextExtension", | ||
) |
5 changes: 5 additions & 0 deletions
5
stac_fastapi/extensions/stac_fastapi/extensions/third_party/free_text/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"""Query extension module.""" | ||
|
||
from .free_text import FreeTextExtension | ||
|
||
__all__ = ["FreeTextExtension"] |
46 changes: 46 additions & 0 deletions
46
stac_fastapi/extensions/stac_fastapi/extensions/third_party/free_text/free_text.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
"""Free-text extension.""" | ||
|
||
from typing import List, Optional | ||
|
||
import attr | ||
from fastapi import FastAPI | ||
|
||
from stac_fastapi.types.extension import ApiExtension | ||
|
||
from .request import FreeTextExtensionGetRequest, FreeTextExtensionPostRequest | ||
|
||
|
||
@attr.s | ||
class FreeTextExtension(ApiExtension): | ||
"""Free-text Extension. | ||
|
||
The Free-text extension adds an additional `q` parameter to `/search` requests which | ||
allows the caller to perform free-text queries against STAC metadata. | ||
https://github.com/stac-api-extensions/freetext-search/README.md | ||
""" | ||
|
||
GET = FreeTextExtensionGetRequest | ||
POST = FreeTextExtensionPostRequest | ||
|
||
conformance_classes: List[str] = attr.ib( | ||
factory=lambda: [ | ||
"https://api.stacspec.org/v1.0.0-rc.1/item-search#free-text", | ||
"https://api.stacspec.org/v1.0.0-rc.1/item-search#advanced-free-text", | ||
"https://api.stacspec.org/v1.0.0-rc.1/collection-search#free-text", | ||
"https://api.stacspec.org/v1.0.0-rc.1/collection-search#advanced-free-text", | ||
"https://api.stacspec.org/v1.0.0-rc.1/ogcapi-features#free-text", | ||
"https://api.stacspec.org/v1.0.0-rc.1/ogcapi-features#advanced-free-text", | ||
] | ||
) | ||
schema_href: Optional[str] = attr.ib(default=None) | ||
|
||
def register(self, app: FastAPI) -> None: | ||
"""Register the extension with a FastAPI application. | ||
|
||
Args: | ||
app: target FastAPI application. | ||
|
||
Returns: | ||
None | ||
""" | ||
pass |
21 changes: 21 additions & 0 deletions
21
stac_fastapi/extensions/stac_fastapi/extensions/third_party/free_text/request.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""Request model for the Free-text extension.""" | ||
|
||
from typing import Optional | ||
|
||
import attr | ||
from pydantic import BaseModel | ||
|
||
from stac_fastapi.types.search import APIRequest | ||
|
||
|
||
@attr.s | ||
class FreeTextExtensionGetRequest(APIRequest): | ||
"""Free-text Extension GET request model.""" | ||
|
||
q: Optional[str] = attr.ib(default=None) | ||
|
||
|
||
class FreeTextExtensionPostRequest(BaseModel): | ||
"""Free-text Extension POST request model.""" | ||
|
||
q: Optional[str] = attr.ib(default=None) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you advertise both basic and advanced at the same time, maybe we should first discuss stac-api-extensions/freetext-search#10 ?