-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modular search with separate vespa app
- Loading branch information
Showing
25 changed files
with
313 additions
and
233 deletions.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from typing import Callable, NamedTuple | ||
|
||
from .models import SearchResult | ||
|
||
|
||
class Search(NamedTuple): | ||
query: str | ||
offset: int = 0 | ||
page_size: int = 10 | ||
|
||
|
||
Searcher = Callable[[Search], SearchResult] | ||
|
||
|
||
class SearchHandler(NamedTuple): | ||
name: str | ||
searcher: Searcher | ||
template_name: str | ||
|
||
|
||
search_handlers: dict[str, SearchHandler] = {} | ||
|
||
|
||
def register_search_handler( | ||
name: str, | ||
searcher: Searcher, | ||
template_name: str, | ||
) -> None: | ||
"""Register a search handler. | ||
The name can be selected by the user in the search form. The searcher is called | ||
when the user submits the form and returns the results. The template name is | ||
the partial to be rendered as help below the search form. | ||
""" | ||
search_handlers[name] = SearchHandler(name, searcher, template_name) |
Oops, something went wrong.