SearchIndex
This class represents an inverted index that maps tokens to bookmark IDs. It is rebuilt from the repository upon initialization and updates incrementally as bookmarks are added or modified.
Constructor
Signature
def SearchIndex(self, repository: "BookmarkRepository") -> None: ...
Parameters
| Name | Type | Description |
|---|---|---|
| repository | "BookmarkRepository" | The bookmark repository to index from. |
Methods
index_bookmark()
def index_bookmark(self, bookmark: Bookmark) -> None: ...
Add or update a bookmark in the index.
Parameters
| Name | Type | Description |
|---|---|---|
| bookmark | [Bookmark](../../../models/bookmark/bookmark.md?sid=app_models_bookmark_bookmark) | The bookmark to index. |
Returns
| Type | Description |
|---|---|
None |
remove_bookmark()
def remove_bookmark(self, bookmark_id: str) -> None: ...
Remove a bookmark from the index.
Parameters
| Name | Type | Description |
|---|---|---|
| bookmark_id | str | The unique identifier of the bookmark to remove. |
Returns
| Type | Description |
|---|---|
None |
search()
def search(self, query: str, limit: int = 20) -> List[Bookmark]: ...
Search bookmarks matching the query string. Tokens are AND-ed together — all must appear for a result to match.
Parameters
| Name | Type | Description |
|---|---|---|
| query | str | Free-text search query. |
| limit | int = 20 | Maximum number of results. |
Returns
| Type | Description |
|---|---|
List[[Bookmark](../../../models/bookmark/bookmark.md?sid=app_models_bookmark_bookmark)] | List of matching bookmarks, ordered by relevance (number of token hits). |